Papyrix vendors "md_parser" to actually parse Markdown files, though it might be better to call it a lexer. Though at the same time Papyrix's "parsers" perform a fair bit of layout logic.
Reportedly md_parser was specifically designed for ESP32 microcontrollers like what Papyrix runs on, yet Papyrix adds logic around it to cut down on RAM use.
For datastructures md_parser defines an enum of different tokens. Furthermore it has a struct adding sized-text & possibly an int to these tokens.
1/?
Other datastructures define a callback type, as well as a struct turning it into a closure & adding some bitflags indicating enabled features. Macros define these different bitflags.
A 3rd macro references this "config" alongside bytes for the current state & substate, header level, list number, & various flags. Furthermore it stores a max-4-char lookahead buffer, & a current slice of text.
An internal enum defines these states.
A helper assembles a token & passes it to the callback.
2/?