On Tuesday, 1 October 2019 at 16:02:47 UTC, bachmeier wrote:
On Monday, 30 September 2019 at 23:06:42 UTC, Guillaume Piolat wrote:
Hello,

commonmark-d is a D translation of MD4C, a fast SAX-like Markdown parser. MD4C achieves remarkable parsing speed through the lack of AST and careful memory usage.

The route of translation was choosen because parsing Markdown is much more involved that first thought. The D translation largely preserve the speed benefits of M4DC.


Usage:

    // Parse CommonMark, generate HTML
    import commonmarkd;
    string html = convertMarkdownToHTML(markdown);

Key Performance Numbers:
- commonmark-d compiles 3x faster than dmarkdown and 40x faster than hunt-markdown. - commonmark-d parses Markdown 2x faster than dmarkdown and 15x faster than hunt-markdown (see GitHub for benchmark details)

I haven't measured memory usage of either compile time or run time, but I feel like it's also better.

Available now on DUB: http://code.dlang.org/packages/commonmark-d
GitHub page: https://github.com/p0nce/commonmark-d

This is really nice. The examples show only conversion to html. Is there an easy way to get the intermediate output and convert to PDF through latex, to org-mode, etc., or to change the html conversion? One use case that is easy with Pandoc is to copy just the code from markdown into its own source file as a simple form of literate programming.

MD4C is a push parser without AST so you have to give it callbacks to generate any koind of intermediate output. You'd have to make md_parse public in commonmark-d, this is a C-style API

My long term goal is indeed super fast conversion of markdown to PDF, now we have the commonmark parser and the PDF generation, I just need the time to manage layout. Possibly making a minimal browser is a better route, dunno.

Reply via email to