Skip to content
Anjunar/ DOCS

Markdown

A CommonMark 0.31.2 parser and writer in Scala, without a DOM or a JavaScript dependency. What Markdown cannot say is reported, not dropped.

Round trip

Decode, edit, encode

The editor below was decoded from Markdown. Change it and watch the Markdown the writer produces.

Markdown, live

Written from the document on every commit.

A small document

A paragraph with strong and emphasized text, a link and inline code.

  1. First item

  2. Second item

20 words · 21 nodes
## A small document A paragraph with **strong** and *emphasized* text, a [link](https://anjunar.com) and `inline code`. 1. First item 2. Second item
scala
val rules = MarkdownSupports.everything(LinkUrlPolicy.default, MediaUrlPolicy.default) val decoded = MarkdownCodec.decode(source, resolved.schema, rules, generator, NodeId("document")) val written = MarkdownCodec.encode(session.document, rules, LossPolicy.Strict)
Losses

Strict or lossy, never silent

Underline, strikethrough, image dimensions and media IDs have no CommonMark form. Under Strict the export fails; under AllowLossy each loss appears in EncodedMarkdown.losses.

scala
MarkdownCodec.encode(document, rules, LossPolicy.AllowLossy) match case Right(result) => result.losses.foreach(loss => println(loss.message)) case Left(error) => println(error.message)
Coverage

Measured, not asserted

The parser reproduces 651 of the 652 examples of the official conformance suite character for character; 628 survive writing and parsing again unchanged. Both numbers are checked exactly in CI.

MarkdownProfile.commonMarkSafe
CommonMark blocks and inlines.
MarkdownProfile.commonMarkSafeWithTables
The same plus GFM tables.
MarkdownProfile.untrustedPaste
The same rules under paste-sized limits.