#markdown-parser #markdown-html #markdown #markdown-syntax #error-reporting #ast #mathml

bin+lib markdowny

Markdown parser with focus on error reporting, and with support for hairy templates, HTML, HTML-attributes, HTML-spans, HTML-blocks specified in Markdown

7 releases (4 breaking)

0.5.0 Nov 11, 2024
0.4.0 May 3, 2024
0.3.0 Dec 10, 2023
0.2.1 Mar 25, 2023
0.1.1 May 29, 2022

#807 in Parser implementations

Download history 2/week @ 2024-09-14 14/week @ 2024-09-21 6/week @ 2024-09-28 1/week @ 2024-10-05 4/week @ 2024-10-12 1/week @ 2024-10-19 112/week @ 2024-11-09 22/week @ 2024-11-16 3/week @ 2024-11-23

137 downloads per month

Apache-2.0

610KB
13K SLoC

markdowny

A Markdown parser with strict error handling, generating an AST that can be easily adjusted and converted to text or HTML. It supports some additional syntax:

  • spans between [ and ];
  • divs without block elements (such as div and p) between [[ and ]];
  • divs with block elements (such as div and p) between [[[ and ]]];
  • literals between [[[[ and ]]]];
  • setting styles/classes/ids etc with {#id; style: value; .classname}.
  • HTML tags such as div with a newline after are assumed to contain block elements. HTML tags without a newline after are assumed to not contain block elements.
  • !![description](image-src) is a block level image (not wrapped in <p>)

This library also has a resolve_markdown() function that does a number of things:

  • makes sections around headings (h1,h2,..), and make links to them;
  • highlight source code (if syntect feature is enabled);
  • converts math to mathml (if latex2mathml feature is enabled);
  • creates figures (start blockquote with figure_type #reference_key: caption, figure type can be listing/figure/etc, #reference_key can be used in links);
  • resolves section and figure counters (start headings and figures with ?, if link body contains ?, replace by actual number).

Neovim LSP config

vim.api.nvim_create_autocmd('FileType', {
  pattern = 'markdown',
  callback = function(args)
    vim.lsp.start({
      cmd = { 'markdowny-lsp' },
      name = 'markdowny',
    })
  end,
})

Dependencies

~2–11MB
~115K SLoC