Skip to content

MichaelHatherly/CommonMark.jl

Repository files navigation

CommonMark.jl

A CommonMark-compliant parser for Julia.

Quick Start

using CommonMark

parser = Parser()
ast = parser("Hello *world*")
html(ast)  # "<p>Hello <em>world</em></p>\n"

Output Formats

html(ast)      # HTML
latex(ast)     # LaTeX
typst(ast)     # Typst
term(ast)      # Terminal with ANSI colors
markdown(ast)  # Normalized markdown
notebook(ast)  # Jupyter notebook

Extensions

Enable syntax beyond CommonMark:

enable!(parser, TableRule())
enable!(parser, FootnoteRule())
enable!(parser, MathRule())

Available extensions: TableRule, FootnoteRule, MathRule, DollarMathRule, AdmonitionRule, FrontMatterRule, AttributeRule, CitationRule, AutoIdentifierRule, TypographyRule, StrikethroughRule, SubscriptRule, SuperscriptRule, TaskListRule, GitHubAlertRule, FencedDivRule, ReferenceLinkRule, RawContentRule.

See the documentation for details.

Writer Configuration

Configuration can be provided via a Dict{String,Any} or front matter:

html(ast, Dict("title" => "My Document"))

Template Variables

  • template-engine::Function — Mustache-compatible renderer for standalone documents
  • <format>.template.file::String — Custom template file
  • <format>.template.string::String — Custom template string
  • title, subtitle, authors, abstract, keywords, lang, date
  • html.css, html.js, html.header, html.footer
  • latex.documentclass, latex.preamble

About

A CommonMark-compliant Markdown parser for Julia.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 14