Markdown Parsers for Javascript

Posted Wednesday, March 2, 2022 by Sri.Tagged MEMO
EDIT STATUS:new

INTENT: Looking for a Javascript Markdown parser that I can add my own TOML-style extensions.

Q. What does GitHub use? A. They use a fork of the Commonmark C library

Q. What does GitLab use? A. They use the Redcarpet Ruby library, but other accounts say they use Kramdown now (also Ruby)

Q. Are their Markdown parsers that also have TOML support? A. Not obviously

Q. What are some Javascript Markdown implementations I can hack?

By popularity in NPM:

  • marked - extendable via lexer providing a pattern recognizer to produce "tokens" that are rendered by the "parser"
  • markdown-it also allows overriding the rules
  • commonmark - markdown-it is the implementation they suggest
  • markdown-wasm is a WebAssembly wrapper for MD4C, a C library.

Other libraries:

  • iarna-toml is a JS lib that supported the 1.0 TOML spec (others support 0.4 or 0.5). Here's the official 1.0.0 spec.
  • R Markdown is a variant of Markdown for data scientist notebooks leveraging R, Python, etc.
  • Text File Formats review to see if there is a "Sectioned Text" format that I could adapt.
  • AsciiDoc has the support for "include files" but uses headers as section markers. NO GOOD.
  • WordStar (!) I remember having block markers, but it's a super old format that uses inline embedded control characters like an old-style line printer 😄 Also 7-bit ASCII only
  • Scrivener .scriv files are a folder of multipl RTF files.