Yet another static site generator. This one in GNU Prolog.
Pass through syntax tag for PRE blocks.
Add Mastodon link.
Misc. blah blah


browse  log 



You can also use your local clone with git send-email.

#Gemini-to-HTML Converter.

This one in GNU Prolog!

I want a really simple site with no bells or whistles. The two fancy things I really want are my beloved EB Garmond font and syntax highlighting for code blocks. Other than that there's not much else.


Python 3 and Pygments. And GNU Prolog, of course.

Syntax highlighting is provided through Pygments. (I might add some sort of math rendering.) Since Python is required for Pygments already I also shell out to it for HTML escaping. It's slow but I avoid reinventing that wheel.


Run make in the src/ dir to build the executable gemini2html.


The gemini2html binary reads Gemini text from stdin and writes HTML5 to stdout. There are no command line arguments.


Preformatted text with a comment is passed through Pygments for conversion to HTML. In theory the comment could select various syntaxes but right now it is hard-coded to only use Prolog.

There is a footer added to each page that is specific to my own site, and it's also hard-coded. You have to edit the source and recompile to change it or any other part of the boilerplate HTML. (That includes the CSS links to files which I have since removed from the project, but not from my private repo where I maintain my blog (the only client of this code.) D'oh!)


Generate HTML from Prolog:

pygmentize -l prolog -o build/pagemage.html pagemage.pl
pygmentize -l prolog -f html < in > out

Generate CSS:

pygmentize -S lovelace -f html > build/css/hilite.css

List styles:

pygmentize -L styles | less

One of the interesting things about this code is that it's not much larger than the grammar of Gemini plus the HTML template. It approaches the Kolmolgov complexity of the domain, yet remains fairly readable. (In other words it's not so compressed that the meaning is obscured.)

Both HTML escaping and syntax highlighting are Prolog-shaped problems, so in theory the condition holds even if I were to implement that functionality in Prolog. (It would be fun, but in this case I went with off-the-shelf solutions to get to the desired end result faster. It's slow to shell out so many times, but I rarely need to rebuild anyway, so it's not a big deal, even with Python's relatively long start-up time. (I have to admit it's been getting faster.) HTML escaping is simple enough that rewriting it in Prolog might be well worth the effort in terms of time saved waiting for builds. The obvious question arises, someone else has had this problem? There must be HTML escapin' code out there already? In fact, where is the GNU Prolog std lib? Does such a thing exist?)