cmark

A CommonMark toolkit for MoonBit

commonmark
markdown
moon add moonbit-community/cmark@0.4.6
Download zip
Version
0.4.6
License
Apache-2.0
Last updated
2 days ago
Downloads
21K
README

#cmark

Cmark is a CommonMark toolkit for the MoonBit programming language, started as a MoonBit rewrite of the cmarkit library from the OCaml ecosystem.

So far, it supports the following use cases:

  • Parsing CommonMark documents with best-effort source-aware layout preservation:
  • Rendering CommonMark documents via the Renderer API, along with a ready-to-use HTML renderer.

Supported CommonMark features include:

  • Vanilla CommonMark syntax;
  • Common syntax extensions, including:
    • Strikethroughs
    • Task lists
    • Footnotes
    • Tables
    • Inline math
    • Math blocks

#Building

To begin, you will need to install a recent MoonBit toolchain. To do so, please refer to instructions at MoonBit's official website.

Also, a Python installation is required to run the pre-build scripts. You can find relevant instructions from Python's official website.

Once you have the toolchain installed, you can build this project by running the following command:

moon build

#CLI

The repository includes a native command-line renderer that follows the basic cmark input model: read Markdown from stdin, -, or one or more file paths and write rendered HTML to stdout.

printf '# Hello\n' | moon run src/cmark_cli -- - moon run src/cmark_cli -- README.md moon run src/cmark_cli -- --safe --to xhtml README.md

For reference comparisons, install the upstream CommonMark CLI and compare against the MoonBit executable:

brew install cmark printf '# Hello\n' | cmark --unsafe printf '# Hello\n' | moon run src/cmark_cli -- -

#Testing

With the MoonBit toolchain installed, you can run the tests by executing the following command:

moon test

#Acknowledgements

cmark is built on top several pre-existing projects. Thanks go to: