~tagglink/node

ref: 1a3e3c3bc3fbc070205a5a7570f317def9d5ea44 node/README.md -rw-r--r-- 3.3 KiB
1a3e3c3b — Tomas Granlund readme changes 1 year, 5 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.

My own site is generated with node.

#Features

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.

The file entry will be interpreted as one of two things:

  1. 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.
  2. 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 for parsing Markdown (very, very quickly!).

#Contributing

You are more than welcome to contribute, but as this is a quite personal project, if your contribution does not align with my personal vision, the contribution will not be accepted.

I highly encourage you to only make changes to this program that are useful to you, regardless if I choose to accept them or not.

#Improvements

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