Cmarkit parses the CommonMark specification. It provides:
See the quick start.
cmarkit
Cmarkit
CommonMark parser and abstract syntax tree.Cmarkit_renderer
Renderer abstraction.Cmarkit_commonmark
Rendering CommonMark to CommonMark.Cmarkit_html
Rendering CommonMark to HTML.Cmarkit_latex
Rendering CommonMark to LATEX.The following functions render CommonMark snippets using the built-in renderers. The parsing bit via Cmarkit.Doc.of_string
is always the same except for CommonMark rendering where we make sure to keep the layout for source layout preservation.
If strict
is true
the CommonMark specification is strictly followed otherwise the built-in extensions are enabled.
let cmark_to_html : strict:bool -> safe:bool -> string -> string =
fun ~strict ~safe md ->
let doc = Cmarkit.Doc.of_string ~strict md in
Cmarkit_html.of_doc ~safe doc
let cmark_to_latex : strict:bool -> string -> string =
fun ~strict md ->
let doc = Cmarkit.Doc.of_string ~strict md in
Cmarkit_latex.of_doc doc
let cmark_to_commonmark : strict:bool -> string -> string =
fun ~strict md ->
let doc = Cmarkit.Doc.of_string ~layout:true ~strict md in
Cmarkit_commonmark.of_doc doc
If you want to:
Cmarkit.Mapper
.Cmarkit.Folder
.