ExtraMark is a superset of CommonMark that includes syntax extensions that are commonly used by other Markdown dialects. The list and syntax for the extensions are decided by looking at the most popular Markdown dialects and selecting the most common syntax for each feature. The goal of the project is to create a (somewhat) standard superset of CommonMark that supports the features that are requested by most. The parser is based on markdown-it and uses plugins for syntax extensions.
Install via npm:
npm install extramarkThe extramark package exposes two functions, parse() and render(). The parse() function creates an abstract syntax tree from the input while the render() function returns the generated HTML code (see markdown-it).
const { parse, render } = require("extramark");
parse("# Heading");
// [Object] - AST of the Markdown code
render("# Heading");
// <h1>Heading</h1>In a browser environment you can access the parse() and render() functions via the ExtraMark global object.
const { parse, render } = ExtraMark;To transform documents in the command line you have to install the extramark package globally.
npm install -g extramarkAfter the installation the extramark command becomes available. The command can be used to transform the input text (file or stdin) to HTML (file or stdout).
extramark input.md -o output.html -c style.cssTo see all options of the extramark see it's help:
extramark --help- Defined clearly as a superset of CommonMark
- Syntax extensions
- Integrated CLI tool for command-line conversion to HTML
All ideas, recommendations, bug reports, pull requests are welcome. 🙂