gmi2html2 - convert a Gemini file to an HTML body

gmi2html2.awk

I already list a program called "gmi2html" on this server, so I have named this program "gmi2html2". Just like gmi2html, which is written in Python, this program aims to convert a Gemscript file to HTML.

The program is written in AWK. I remember that my first attempts at writing a Gemini-to-HTML converter were also in AWK instead of Python. But I didn't want to look for the remnants of those attempts, so I just wrote this program from scratch.

This program is simpler than gmi2html in the way that it doesn't attempt to check for "prettiness" of the input or collate adjacent text lines to a single <p> element. Instead, line breaks are rendered by just putting everything into <pre> elements. This is not semantically incorrect - the <pre> element was designed for such cases (and not only for code).

In order to distinguish the "text" <pre> elements from the "code" <pre> elements, they have to be styled appropriately. The program supplies the <pre> elements with 2 CSS classes, "code" and "text", for this purpose. Because the program only outputs the HTML body content, you have to supply the HTML boilerplate and styling yourself. I suggest something like the following:

If you save that as "boilerplate.html", you could apply the program as follows in order to convert all Gemini files in a directory:

EOF