markdown

Options

The full MarkdownConfig surface — every flag, callback, and prefab — in one table.

MarkdownConfig is the single source of truth for parser and renderer behaviour. Construct one explicitly, or copy MarkdownConfig.default (pure CommonMark) or MarkdownConfig.all (every extension on).

Prefabs

ValueMeaning
MarkdownConfig.defaultPure CommonMark. No extensions. Predictable spec-only output.
MarkdownConfig.allEvery boolean extension on; emoji = Unicode; autoHeadingIds = true.

Full reference

OptionTypeDefaultNotes
tablesBooleanfalseGFM-style pipe tables.
definitionListsBooleanfalseTerm\n: defn style definition lists.
mathBooleanfalse$$…$$ block math, $…$ inline math.
calloutsBooleanfalse> [!TYPE] admonition blocks.
strikethroughBooleanfalseGFM ~~strikethrough~~.
taskListItemsBooleanfalseGFM - [ ] / - [x] checkbox list items.
extendedAutolinksBooleanfalseBare URL / www. autolinks (no <> brackets needed).
footnotesBooleanfalse[^label] references with [^label]: … definitions.
smartPunctuationBooleanfalseCurly quotes, en/em-dashes, ellipsis.
attributesBooleanfalse{#id .class key=value} on headings, fenced blocks, images.
autoHeadingIdsBooleanfalseAuto-populate heading ids. Explicit ids (via attributes) win.
slugifyString => StringdefaultSlugifySlug function used by autoHeadingIds.
emojiEmojiConfigDisabledDisabled / Unicode / Image(baseURL).
docTagsDocTagConfigdisabled@name [target] — body annotation parsing.
codeHighlighterOption[(String, String) => Option[String]]NonePluggable code-block syntax highlighter.
indentedCodeLanguageOption[String]NoneDefault language tag applied to indented code blocks.
indentedCodeBreaksListBooleanfalseIf true, an indented code block after a blank line ends the enclosing list item instead of being absorbed.

EmojiConfig

enum EmojiConfig:
  case Disabled
  case Unicode
  case Image(baseURL: String)

Unicode substitutes the Unicode glyph (e.g. :smile:😄). Image("/emoji") substitutes <img src="/emoji/smile.svg" alt=":smile:" /> — the baseURL is prefixed verbatim.

slugify

Default behaviour (MarkdownConfig.defaultSlugify):

  • lowercase the input
  • collapse runs of non-alphanumeric characters into a single -
  • strip leading and trailing -
  • return "" if the input has no letter/digit content

Same algorithm Hugo, mkdocs, and GitHub use. Override when your URL scheme differs:

val cfg = MarkdownConfig.default.copy(
  autoHeadingIds = true,
  slugify = s => s.toLowerCase.replaceAll("[^a-z0-9]+", "_").stripPrefix("_").stripSuffix("_"),
)

codeHighlighter

codeHighlighter: Option[(String, String) => Option[String]]

The function receives the raw code body and the language tag (from the info string, or from indentedCodeLanguage for indented blocks). Return Some(html) to inject custom HTML inside <code>…</code>; return None to fall back to the default <pre><code>{escaped}</code></pre> output.

The renderer does not escape your highlighter’s output — it’s assumed to be valid HTML already.

DocTagConfig

case class DocTagConfig(
  enabled:           Boolean      = false,
  registry:          TagRegistry  = TagRegistry.empty,
  strictUnknownTags: Boolean      = false,
)

See Extensions → Doc-tags for the integration model and a full example.

Worked configurations

val cfg = MarkdownConfig.default.copy(
  tables             = true,
  extendedAutolinks  = true,
  smartPunctuation   = true,
  autoHeadingIds     = true,
)

“Obsidian-flavoured”: callouts, footnotes, math, tables

val cfg = MarkdownConfig.default.copy(
  tables    = true,
  callouts  = true,
  footnotes = true,
  math      = true,
)
val cfg = MarkdownConfig.default.copy(
  tables             = true,
  strikethrough      = true,
  taskListItems      = true,
  extendedAutolinks  = true,
)

Everything

val cfg = MarkdownConfig.all