ssg

Kris Yotamssg 1.1ad5ef0d1 month agoHistory
NameLast commit messageLast commit date
tests
.gitignore
config.def.h
config.mk
LICENSE
Makefile
README.md
ssg.1
ssg.c
README.md

ssg

ssg converts Markdown and MDX to HTML. It is one C99 file with no dependencies. It implements CommonMark and the GitHub extensions (tables, strikethrough, task lists, autolink literals, footnotes), reads MDX the way @mdx-js/mdx does with remark-gfm and remark-math, and renders MDX components from a table you compile in.

Build

make
make check
make install        # /usr/local/bin/ssg and ssg(1)

Use

ssg post.mdx > post.html        # MDX, the default
ssg -p README.md                # plain CommonMark and GFM, raw HTML kept
ssg -s < comment.md             # safe: raw HTML escaped, unsafe URLs dropped
printf '%s' "$title" | ssg -i   # one paragraph, no <p>
ssg -o out.html a.md b.md       # each file is its own document
ssg -0                          # NUL-separated documents, one process

ssg -h lists the options and any configured commands; man ssg has the details. Exit status is 0 on success, 1 on read, write or command errors, and 2 on usage errors.

Configure

ssg is configured like the suckless tools: copy config.def.h to config.h (the first make does it), edit, rebuild. The configuration holds the classes and attributes written for headings, links, code, tables and math, the MDX components, and optional extra commands (ssg NAME ARGS...). The defaults write plain, semantic HTML.

A component is a template or a C function:

static const Component components[] = {
	{ "Collapse", NULL,
	  "<details{open? open}>{title?<summary>{title}</summary>}{}</details>" },
	{ "Chart",    chart, NULL },  /* void chart(Buf *, Elem *, const char *) */
};

The configuration is included after ssg's declarations, so its functions can use the same helpers ssg does.

A site can keep its configuration in its own repository and build ssg against it:

make CONFIG=/path/to/site/config.h

krisyotam.com does this: its components and its notebooks generator (ssg notebooks SRC OUT) live in the site's repository, and the site's build calls the resulting ssg binary.

License

MIT; see LICENSE.