This page permanently redirects to gemini://dkalak.de/software/gmi2html2/.
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 element. Instead, line breaks are rendered by just putting everything into elements. This is not semantically incorrect - the element was designed for such cases (and not only for code).
In order to distinguish the "text" elements from the "code" elements, they have to be styled appropriately. The program supplies the 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:
Gemini document automatically converted to HTML
If you save that as "boilerplate.html", you could apply the program as follows in order to convert all Gemini files in a directory:
find -name '*.gmi' | while read -r f do awk -f gmi2html2.awk "$f" | # Replace local links (i.e. those that do not have a :// part) # to .gmi files with .html links. The substitution doesn't need # to be global because there is at most 1 link per line. Also # note that the pattern cannot match user input because double # quotes are escaped by the program. sed 's/href="\([^:]*\)\.gmi"/href="\1.html"/' | cat boilerplate.html - > "${f%.gmi}.html" rm -v "$f" done
EOF
text/gemini; lang=en
This content has been proxied by September (ba2dc).