Documentation

Lean.Data.Markdown.Parser

partial def Lean.Markdown.parseInlinesInBlock {s : String.Slice} (refs : RefTable s) (block : Block.Raw s) (extensions : Extensions := { }) :

Parses the inline content of a block from the first pass, with refs set to the document's link reference definitions. This is the second pass of the algorithm described in the CommonMark specification.

Two passes are necessary because the presence of a link definition later in the document affects the syntactic interpretation of reference-style links earlier in the document.

def Lean.Markdown.parseDocument (s : String.Slice) (indent : Nat := 0) (extensions : Extensions := { }) (externalRefs : Std.HashMap String ExternalRef := ∅) :

Parses s as a Markdown document.

Up to indent leading spaces of each line are skipped.

By default, the parser adheres to CommonMark with one exception. It compares link labels modulo Unicode case folding only for the Latin-1 and Greek ranges, while CommonMark specifies full Unicode case folding. Use extensions to enable non-standard extensions like LaTeX math.

The externalRefs table maps labels to reference definitions beyond the document's own link reference definitions. Its labels are normalized like those in the document, and when several of them normalize to the same label, the definition of the lexicographically least of them is used. A reference definition in the document takes precedence over an external definition with the same label unless the external definition has overrideDocument set.

This parser is based on the two-pass algorithm described in the CommonMark specification.

Equations
  • One or more equations did not get rendered due to their size.
Instances For