~tagglink/node

ref: 7416d9f5a91afbd375aa4fda63507870c64b4777 node/README.md -rw-r--r-- 2.9 KiB
7416d9f5 — Tomas Granlund fixed the readme 1 year, 2 months ago

#Node

Node is a tool that allows anyone to write a website in simple Markdown. Node automatically generates a <nav> that allows users to navigate your content easily and intuitively.

The layout of the website is described in a .tree file.

My Node index.md
<Projects projects.md
<<BMP2CHR bmp2chr.md
<Blog blog.md
<<Awesome Blog Post awesome.md
<Now now.md

When Node is run, it parses the .md file at the end of each line and produces a HTML document with a nav for each one. The <nav> for "Awesome Blog Post" would look like this:

<nav>
	<ul>
		<li><a href="projects.html">Projects</a></li>
		<li><a href="blog.html">Blog</a></li>
		<ul>
			<li><a href="awesome.html">Awesome Blog Post</a></li>
		</ul>
	</ul>
</nav>
<main> ... content generated from awesome.md ... </main>

#Build

clang src/main.c src/md4c/md4c.c -std=c99

Clang is the most accessible C compiler for windows users and the one I use, but it should compile with any C compiler that supports C99.

#Use

node tree-file.tree -h head.html -f foot.html -c path/to/md/content -o path/to/html/output

Each line in the tree file is parsed in the following way:

  1. The number of < characters at the beginning of the line is the depth of the nav entry.
  2. The first non-< character is the start of the Title of the nav entry.
  3. The last sequence of non-whitespace characters before the newline is the file entry. This will be interpreted as one of two things:
  4. If the file entry ends with .md, the file is parsed as Markdown and the resulting HTML file is the href target for this nav entry.
  5. Otherwise the file entry is directly interpreted as the href target for this nav entry.

The file given to -h must contain two occurrences of %s, where the first will be replaced by the note's title, and the second with the site's nav.

Example head.html:

<!DOCTYPE html>
<html>
<head>
  <meta charset='UTF-8' />
  <title>%s - node</title>
  <link rel="stylesheet" href="/css/style.css" />
  <link rel="icon" href="/res/icon-128x128.png" type="image/png" sizes="128x128" />
  <link rel="icon" href="/res/icon-64x64.png" type="image/png" sizes="64x64" />
  <link rel="icon" href="/res/icon-32x32.png" type="image/png" sizes="32x32" />
  <link rel="icon" href="/res/icon-16x16.png" type="image/png" sizes="16x16" />
</head>
<body>
  <header>
    <a href="/index.html">node</a>
  </header>
  <nav><ul>%s</ul></nav>
  <main>

Example foot.html:

</main>
  <footer>
    <a href="https://sr.ht/~MeOnSourcehut/"><img src="/res/sourcehut.svg"></a>
    <span>My Name</span>
  </footer>
</body>
</html>
```

## Dependencies
Node uses [MD4C](https://github.com/mity/md4c).

## Improvements
* Cross-platform directory creation when a directory is missing from a path
* Better error messages when parsing tree files