gmi-web 1.0.0


Shortly after releasing RC.1, the author of gmi2html reached out to me, a pleasant surprise! He suggested a more unix-like API would increase the versatility of the tool.

I have a different approach as I use gmi2html in a pipeline, since the web pages I create have more on them than just what is in the gemini source.

This made plenty of sense to me and so I added the --body option to gmi-web(1) which will output just the blocks for the Gemini lines themselves and nothing else. Charlie goes on to mention using the style property on each element instead of a <style> tag in the <head>—a practical decision due to there being no <head> in this scenario.

I don't think I want to add any CSS that might mess with the rest of the page, so I'm gonna make all the styles inline

RC.1 shipped with gmi.css but how could I easily stuff that into the HTML inline‽ A question soon answered by the css package on npm. By manipulating the abstract syntax tree I could pluck out specific selectors to sequence the declarations into style properties. In other words, I now had the power to treat CSS like just another object.

After wrestling the code needed to implement the --inline feature it became clear that a maximally minimal stylesheet was desired to address precisely the vertical layout rules in the default CSS Normal Flow. This way --body could be used without worrying about <a> tags rendering as "display: inline;" and so empty lines would not be subject to margin collapsing. Thus the new gmi.css was born.

I still wanted the options to update font and colors easily and now with my new AST knowledge I had the ability to deeply integrate those variables with the tool. Once again I wrestled together the code, this time to reduce the variables in a CSS file down to just regular declarations and expose them to the command-line options. Now I could develop the CSS and the HTML logic separately and it would get pulled in automatically by the API. Perhaps more fun though: this opened the path to let users supply their own stylesheet, if you have strong style opinions and you don't like the variables I've shipped with gmi-web.css, you can use your own!

gmi-web --body --css custom.css < doc.gmi

So, thank you Charlie, for instigating that journey! Check out gmi2html, it's written in zig which is unique and fun!


With those changes and a new snapshot testing harness gmi-web has reached a stable condition and so I've published 1.0.0 to npm! It has been a lot of fun to put this together and has inspired many future projects for which I'm hopeful this will be a solid foundation. Bouncing around my brain currently is a dual https/gemini --serve option and html-to-gmi contemplations.

For now, writing semantic HTML is as easy as learning gemtext:

npm install --global gmi-web-cli

more entries