Converting Markdown to Gemtext
Published by Beto Dealmeida on
How I ended up implementing my own Markdown to Gemtext converter in Python
I received an email from Sandra Snan today, recommending two different programs to convert Markdown to Gemtext, since I've been having problems with multi-line blockquotes with md2gemini
. Sandra suggested gemgen
and 7off
, mentioning the latter was slower but better with links.
Since I'm not really worried about performance I cloned the 7off
repo, installed CHICKEN scheme, and gave it a try. It was my first time compiling a scheme program, so it took me a couple minutes to figure out that I had to run chicken-install
. Once I did that 7off
worked great with my blog posts, except that it doesn't support triple backticks for code blocks, only 4-space indentation.
While scheme looks interesting, I was really looking for a Python solution, since it's easier to integrate with my static site generator. Since I'm already using marko to parse Markdown in order to extract links I decided to write my own GeminiRenderer
, and it turned out to be much simpler than I expected. My Gemini renderer is <100 LOC, and most of that is comments and whitespace.