Inline Elements #
The inline elements of a parsed Markdown document, the parts of a link, and the link reference definitions and external references that reference links resolve to.
Non-standard extensions that can be optionally enabled.
- latexMath : Bool
LaTeX math, which is
$…$for inline math and$$…$$for display math.
Instances For
Equations
Equations
The title that t denotes, with backslash escapes and character references decoded.
Equations
Instances For
The destination of a link, image, or link reference definition, which is a URL, optionally in angle brackets.
The
<and>around the URL, if the destination is bracketed.- url : s.Subslice
The URL as written, excluding any angle brackets.
Instances For
Equations
The URL that d denotes, with backslash escapes and character references decoded.
Equations
Instances For
The structural parts of a link reference definition. The label is the bracket interior (excluding the brackets themselves).
- openBracket : s.Subslice
The opening
[of the label. - label : Lines s
The label's interior, between the brackets (un-normalized).
- closeBracket : s.Subslice
The closing
]of the label. - colon : s.Subslice
The
:that separates the label from the destination. - destination : LinkDestination s
The destination.
The optional title.
Instances For
Equations
A reference definition from outside the document that is supplied by the parser's caller. The destination URL and title are used as-is. Backslash escapes and character references in them are not decoded.
- destination : String
The destination URL.
The optional title.
- overrideDocument : Bool
Whether this definition takes precedence over a link reference definition in the document that has the same label.
Instances For
Equations
What a reference link may resolve to.
- inDocument {s : String.Slice} (definition : RefDef s) : RefTarget s
A link reference definition in the document.
- external {s : String.Slice} (ref : ExternalRef) : RefTarget s
A definition from outside the document.
Instances For
Equations
The destination of a reference target, with backslash escapes and character references decoded.
Equations
- (Lean.Markdown.RefTarget.inDocument definition).destination = definition.destination.text
- (Lean.Markdown.RefTarget.external ref).destination = ref.destination
Instances For
The title of a reference target, if it has one, with backslash escapes and character references decoded.
Equations
- (Lean.Markdown.RefTarget.inDocument definition).title? = Option.map (fun (x : Lean.Markdown.LinkTitle s) => x.text) definition.title?
- (Lean.Markdown.RefTarget.external ref).title? = ref.title?
Instances For
The surface form of a reference-style link or image.
- full {s : String.Slice} (openBracket closeBracket : s.Subslice) : ReferenceLinkForm s
Full form
[text][label], in which the second brackets contain an explicit label, distinct from the link's text.openBracket/closeBracketare the second bracket pair. - collapsed {s : String.Slice} (openBracket closeBracket : s.Subslice) : ReferenceLinkForm s
Collapsed form
[text][]. The second brackets are empty, and the link's text serves as the label.openBracket/closeBracketare the empty second bracket pair. - shortcut {s : String.Slice} : ReferenceLinkForm s
Shortcut form
[label]. There aren't any second brackets, and the link's text serves as the label.
Instances For
The destination of a link or image.
- inline {s : String.Slice} (openParen : s.Subslice) (destination : LinkDestination s) (closeParen : s.Subslice) (title? : Option (LinkTitle s) := none) : LinkTarget s
An inline target
(url)or(url "title"). - reference {s : String.Slice} (refTarget : RefTarget s) (label : Lines s) (form : ReferenceLinkForm s) : LinkTarget s
A reference target, in which
refTargetis what the label resolved to, andlabelis the label's text.The label text is the interior of the second bracket pair in full form, and the link's text in collapsed and shortcut form. In Markdown, seeming links to labels that don't match any definition in the document are not in fact links (they are just plain text), so every reference link has a resolved target.
Instances For
Equations
The content of LaTeX math between the dollar signs. The lines are verbatim source.
Use MathContent.text to extract the normalized single-line string representation.
- lines : Lines s
The source lines.
Instances For
Equations
The normalized single-line string representation of LaTeX math.
Leading spaces and tabs are removed from all lines after the first, and line endings become spaces unless the line already ends with a space.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The string that inline code denotes (CommonMark §6.1), which is its lines joined by spaces, with one space removed from each end when the result begins and ends with a space and is not all spaces.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A parsed inline element of the source string s.
- text {s : String.Slice} (range : s.Subslice) : Inline s
Plain text.
- code {s : String.Slice} (openTicks : s.Subslice) (content : InlineCodeContent s) (closeTicks : s.Subslice) : Inline s
Inline code (CommonMark §6.1).
- italic {s : String.Slice} (openDelim : s.Subslice) (content : Array (Inline s)) (closeDelim : s.Subslice) : Inline s
Italic emphasis.
- bold {s : String.Slice} (openDelim : s.Subslice) (content : Array (Inline s)) (closeDelim : s.Subslice) : Inline s
Bold/strong emphasis.
- link {s : String.Slice} (openBracket : s.Subslice) (text : Array (Inline s)) (closeBracket : s.Subslice) (target : LinkTarget s) : Inline s
Inline or reference link. The text is recursively parsed.
- image {s : String.Slice} (bang openBracket : s.Subslice) (alt : Array (Inline s)) (closeBracket : s.Subslice) (target : LinkTarget s) : Inline s
An image. The alt content is recursively parsed as inline content (CommonMark §6.4); HTML rendering should flatten it to plain text for the
altattribute. - hardBreak {s : String.Slice} (marker newline : s.Subslice) : Inline s
A hard line break (CommonMark §6.7).
markeris the backslash or the two or more trailing spaces that make the line ending a hard break, andnewlineis the line ending. - autolink {s : String.Slice} (openAngle url closeAngle : s.Subslice) (isEmail : Bool) : Inline s
An autolink, which is
<https://...>or<scheme:...>for URI form, or<user@domain>for email form (CommonMark §6.5). The URL between the angle brackets is verbatim. Backslash escapes, character references, and other Markdown syntax are not processed inside it.isEmaildistinguishes the email form, whose href gets amailto:prefix when rendered to HTML. - math {s : String.Slice} (openDollars : s.Subslice) (content : MathContent s) (closeDollars : s.Subslice) (display : Bool) : Inline s
LaTeX math, produced only when the
latexMathextension is enabled.This extension uses
$…$for inline math and$$…$$for display math, withdisplayset totruefor the latter. - html {s : String.Slice} (lines : Lines s) : Inline s
Raw HTML (CommonMark §6.6), which is an open or closing tag, a comment, a processing instruction, a declaration, or a
CDATAsection. The HTML is stored verbatim. - softBreak {s : String.Slice} (range : s.Subslice) : Inline s
A soft line break (CommonMark §6.8), which is the line ending between two lines of a paragraph.
- escape {s : String.Slice} (backslash char : s.Subslice) : Inline s
A backslash escape
\Xof an ASCII punctuation character (CommonMark §2.4).backslashis the\andcharisX, which is the text the escape denotes. - entity {s : String.Slice} (range : s.Subslice) (value : String) : Inline s
A character reference such as
&,#, or😀(CommonMark §2.5). The subslice extends from&through;.valueis the text that the entity denotes.
Instances For
Equations
The whole destination, including its angle brackets if it has them.
Instances For
The position just past the closing delimiter of a link target, if it has one.
Equations
- (Lean.Markdown.LinkTarget.inline openParen destination closeParen title?).stop? = some closeParen.endExclusive
- (Lean.Markdown.LinkTarget.reference refTarget label (Lean.Markdown.ReferenceLinkForm.full openBracket closeBracket)).stop? = some closeBracket.endExclusive
- (Lean.Markdown.LinkTarget.reference refTarget label (Lean.Markdown.ReferenceLinkForm.collapsed openBracket closeBracket)).stop? = some closeBracket.endExclusive
- (Lean.Markdown.LinkTarget.reference refTarget label Lean.Markdown.ReferenceLinkForm.shortcut).stop? = none
Instances For
The source of the destination of the link or image in the original document.
This may be that of an inline target's, or that of the reference definition that a label resolved to. A reference that resolved to an external definition has none.
Equations
- (Lean.Markdown.LinkTarget.inline openParen destination closeParen title?).destinationSource? = some destination
- (Lean.Markdown.LinkTarget.reference (Lean.Markdown.RefTarget.inDocument definition) label form).destinationSource? = some definition.destination
- (Lean.Markdown.LinkTarget.reference (Lean.Markdown.RefTarget.external ref) label form).destinationSource? = none
Instances For
The source of the title of the link or image, if it has one.
This may be that of an inline target, or that of the link reference definition that the reference resolved to. References that resolve to external definitions have none.
Equations
- (Lean.Markdown.LinkTarget.inline openParen destination closeParen title?).titleSource? = title?
- (Lean.Markdown.LinkTarget.reference (Lean.Markdown.RefTarget.inDocument definition) label form).titleSource? = definition.title?
- (Lean.Markdown.LinkTarget.reference (Lean.Markdown.RefTarget.external ref) label form).titleSource? = none
Instances For
The destination of the link or image, with backslash escapes and character references decoded.
Equations
- (Lean.Markdown.LinkTarget.inline openParen destination closeParen title?).destination = destination.text
- (Lean.Markdown.LinkTarget.reference refTarget label form).destination = refTarget.destination
Instances For
The title of the link or image, if it has one, with backslash escapes and character references decoded.
Equations
- (Lean.Markdown.LinkTarget.inline openParen destination closeParen title?).title? = Option.map (fun (x : Lean.Markdown.LinkTitle s) => x.text) title?
- (Lean.Markdown.LinkTarget.reference refTarget label form).title? = refTarget.title?
Instances For
The whole inline element, from its first to its last character.
Equations
- (Lean.Markdown.Inline.text range).extent = range
- (Lean.Markdown.Inline.code openTicks content closeTicks).extent = Lean.Markdown.span openTicks closeTicks
- (Lean.Markdown.Inline.italic openDelim content closeDelim).extent = Lean.Markdown.span openDelim closeDelim
- (Lean.Markdown.Inline.bold openDelim content closeDelim).extent = Lean.Markdown.span openDelim closeDelim
- (Lean.Markdown.Inline.link openBracket text closeBracket target).extent = Lean.Markdown.subsliceClamped openBracket.startInclusive (target.stop?.getD closeBracket.endExclusive)
- (Lean.Markdown.Inline.image bang openBracket alt closeBracket target).extent = Lean.Markdown.subsliceClamped bang.startInclusive (target.stop?.getD closeBracket.endExclusive)
- (Lean.Markdown.Inline.hardBreak marker newline).extent = Lean.Markdown.span marker newline
- (Lean.Markdown.Inline.autolink openAngle url closeAngle isEmail).extent = Lean.Markdown.span openAngle closeAngle
- (Lean.Markdown.Inline.math openDollars content closeDollars display).extent = Lean.Markdown.span openDollars closeDollars
- (Lean.Markdown.Inline.html lines).extent = lines.extent
- (Lean.Markdown.Inline.softBreak range).extent = range
- (Lean.Markdown.Inline.escape backslash char).extent = Lean.Markdown.span backslash char
- (Lean.Markdown.Inline.entity range value).extent = range
Instances For
The subslice from the start of the first element to the end of the last, if there are any.
Equations
- Lean.Markdown.Inline.extentOf? inlines = do let first ← inlines[0]? let last ← inlines.back? pure (Lean.Markdown.span first.extent last.extent)
Instances For
The plain text of inline content, as for an image's alt attribute:
- Markup is dropped
- Text, escapes, and entities are mapped to their plain text
- Inline code and math are mapped to their literal content
- Line breaks are mapped to newlines
- Autolinks are mapped to their URLs
- Raw HTML is deleted
A normalized link label.
According to the CommonMark spec §4.7, link labels are normalized as follows:
- They are case-folded (though this implementation does not implement full Unicode case folding)
- Internal whitespace is collapsed to a single space
- Leading and trailing whitespace are removed
The constructor is private. Build values via normalizeLabel.
- name : String
The label's text after normalization.
Normalization consists of case folding, collapsing internal whitespace to single spaces, and trimming leading and trailing whitespace.
Instances For
Equations
Equations
Instances For
Equations
- Lean.Markdown.instReprLinkLabel.repr x✝ prec✝ = Std.Format.bracket "{ " (Std.Format.nil ++ Std.Format.text "name" ++ Std.Format.text " := " ++ (Std.Format.nest 8 (repr x✝.name)).group) " }"
Instances For
Equations
Normalizes a CommonMark link label (§6.3). lines are the label's source lines, and each boundary
between two lines counts as whitespace. Then:
- Each character is case folded with
caseFold, which covers ASCII, Latin-1, and Greek. - Internal sequences of whitespace become single spaces.
- Leading and trailing whitespace is removed.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A mapping from normalized link labels to a document's reference targets.