💾 Archived View for warmedal.se › ~bjorn › posts › i-wrote-a-general-gemtext-parser.gmi captured on 2022-04-29 at 11:24:08. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2021-12-03)
-=-=-=-=-=-=-
https://notabug.org/tinyrabbit/gemtextparser
You can clone it and install with pip locally (I haven't published it to PyPI).
It's not a big deal, really. Despite the opinions aired in my last post gemtext is, as I mentioned, not hard to parse.
This module provides a general parser and validator. Where gmi2html reads a file line by line and determines how to translate what it gets to HTML, gemtextparser reads a file and determines what each line semantically is. What you do with those lines is up to you.
Oh, yeah, you can run it as a CLI program that validates given files as well. There's not many errors you can make when writing gemtext, but it catches two: unclosed preformatted block and empty lines (plain text and preformatted lines can be empty, of course).
-- CC0 ew0k, 2021-07-25