rsms / markdown-wasm

Very fast Markdown parser and HTML generator implemented in WebAssembly, based on md4c
https://rsms.me/markdown-wasm/
MIT License
1.51k stars 62 forks source link

How does this compare to GitHub Flavored? #1

Closed trusktr closed 4 years ago

trusktr commented 4 years ago

Nice project! I'm curious to know the differences. Thanks!

mity commented 4 years ago

There is a CommonMark specification and its reference implementation Cmark.

Github forked Cmark as Cmark-gfm and added their extensions there. (And added docs of the extension into a fork of the specification, see https://github.github.com/gfm/)

MD4C (the parser used under the hood of this project) is fully compliant to CommonMark specs as well, and it also implements all the Github's extensions as described in that documentation. However the description of those extensions is much less detailed then the original CommonMark specification so in some specific corner case the behavior is little bit more likely to differ then in the core features.

Also note that Github does some additional processing (outside the cmark-gfm code) to turn e.g. #123 into a link to Github issues etc. MD4C naturally does not do that at all.

EDIT: Forgot to mention one exception. cmark-gfm has an extension called Disallowed raw HTML which can filter only some HTML tags. MD4C does not have that, it only allows to turn raw HTML blocks/spans on or off completely. On the other side, AFAIK, GitHub site does not use that tag filter extension and instead they use some more powerful HTML sanitation lib or framework outside cmark-gfm, likely as a part of some post-processing of the Cmark-gfm output.

trusktr commented 4 years ago

Cool, thanks! I'm using Docsify to create a static doc site based on Markdown files (the markdown files are served statically). So I'm thinking it'd be neat to replace the JS markdown renderer with this WebAssembly renderer for speed.