[ANN] CommonMark.jl

Version 0.10.0 is now available. It’s been a fair while since the previous release. This is likely the last 0.x release before 1.0.0.

A couple of new extensions have been added, we’re starting to run out of useful ones to add at this point:

  • StrikethroughRule (~~text~~), SubscriptRule (~text~), SuperscriptRule (^text^)
  • TaskListRule for - [ ]/- [x] checkboxes
  • GitHubAlertRule for > [!NOTE] style alerts
  • FencedDivRule for Pandoc-style ::: class blocks with nesting support
  • MarkRule for ==highlighted== text
  • ReferenceLinkRule to preserve reference-style links in the AST, plus UnresolvedReference for detecting undefined refs

CommonMark.Node is now part of the public API with programmatic constructors Node(Type, children...) for all container types which allows for constructing complete document ASTs. Tree manipulation functions are also public: append_child, prepend_child, insert_after, insert_before, unlink, and isnull. These mutation functions have been part of the package since its initial creation and haven’t really changed, so worth having them officially available now.

A new typst writer joins html, latex, markdown, notebook, and term. We also now have Pandoc interop via a json(ast) writer for export and Node(dict) for importing directly into CommonMark’s AST representation. These match Pandoc’s JSON AST format. The Node constructor can also be used to convert from stdlib Markdown AST with Node(md::Markdown.MD).

The markdown writer is now properly roundtrippable after several long-standing bugs were fixed. This can be used as a markdown formatter, though without any kind of configuration of the styling of the output.

Writers now accept a transform keyword for intercepting AST nodes during rendering, which can be used for any number of things, such as highlighting code, rewriting links, or wrapping document content in user-provided templates. It replaces a previously semi-private API for doing those kinds of modifications, which was always a bit of a hack.

Finally, documentation has moved from the lengthy README to a real Documenter.jl site: https://michaelhatherly.github.io/CommonMark.jl/

18 Likes