ZMarkdown is the markdown engine used by Zeste de Savoir. It translates Markdown input to an AST, then the AST to LaTeX or HTML. So, we can render markdown in a web page or generate PDF from our tutorials. This project is based on Remark and created in NodeJs.
Similar projects don’t use AST (like the previous iteration of ZMarkdown to translate Markdown and they are difficult to improve with modules or translate in another text language. Because Remark is extremely modulable and uses an AST, it’s the best solution to craft a markdown engine to translate a custom markdown into any format (HTML, slides, PDF, generate Table Of Contents, generate man pages, etc).
How it works?
Remark is based on unified which process text with AST. Syntax trees are a representation of an entity (a text) in a understandable structure for programs.
text |->Chapter |-> paragraph |-> text |-> link |-> text |-> paragraph
Will represent a text which contains a Chapter with 2 paragraph. The first paragraph got a link surrounded by two simple texts.
Then you can use this tree to generate a text, for example the link will be transformed by
The code eating text to produce an AST or which eats the AST to produce a text are separated into several plugins. And so, you can build your own markdown in taking the module you want.
So you have something like
| ....................... process() ......................... | | ......... parse() ..... | run() | ..... stringify() ....... | +--------+ +----------+ Input ->- | Parser | ->- Syntax Tree ->- | Compiler | ->- Output +--------+ | +----------+ X | +--------------+ | Transformers | +--------------+
ZMarkdown can be tested here: https://zestedesavoir.github.io/zmarkdown/public/
This project is under the MIT License and you can find the code on Github