Documentation

Lean.Data.Markdown.Inline

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

    The title of a link, image, or link reference definition, which is written "…", '…', or (…).

    • opener : s.Subslice

      The opening ", ', or (.

    • content : Lines s

      The text between the delimiters.

    • closer : s.Subslice

      The closing ", ', or ).

    Instances For

      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.

        • angles? : Option (s.Subslice × s.Subslice)

          The < and > around the URL, if the destination is bracketed.

        • url : s.Subslice

          The URL as written, excluding any angle brackets.

        Instances For

          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.

            • title? : Option (LinkTitle s)

              The optional title.

            Instances For

              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.

              • title? : Option String

                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

                What a reference link may resolve to.

                Instances For

                  The destination of a reference target, with backslash escapes and character references decoded.

                  Equations
                  Instances For

                    The title of a reference target, if it has one, with backslash escapes and character references decoded.

                    Equations
                    Instances For

                      The surface form of a reference-style link or image.

                      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 refTarget is what the label resolved to, and label is 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

                          The content of inline code (CommonMark §6.1), between its backtick strings. The lines are verbatim source, and text is the string that the inline code denotes.

                          • lines : Lines s

                            The source lines.

                          Instances For

                            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

                              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.

                                  • 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 alt attribute.

                                  • hardBreak {s : String.Slice} (marker newline : s.Subslice) : Inline s

                                    A hard line break (CommonMark §6.7). marker is the backslash or the two or more trailing spaces that make the line ending a hard break, and newline is the line ending.

                                  • math {s : String.Slice} (openDollars : s.Subslice) (content : MathContent s) (closeDollars : s.Subslice) (display : Bool) : Inline s

                                    LaTeX math, produced only when the latexMath extension is enabled.

                                    This extension uses $…$ for inline math and $$…$$ for display math, with display set to true for 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 CDATA section. 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 \X of an ASCII punctuation character (CommonMark §2.4). backslash is the \ and char is X, which is the text the escape denotes.

                                  • entity {s : String.Slice} (range : s.Subslice) (value : String) : Inline s

                                    A character reference such as &amp;, &#35;, or &#x1F600; (CommonMark §2.5). The subslice extends from & through ;. value is the text that the entity denotes.

                                  Instances For

                                    The whole destination, including its angle brackets if it has them.

                                    Equations
                                    Instances For

                                      The position just past the closing delimiter of a link target, if it has one.

                                      Equations
                                      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
                                        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
                                          Instances For

                                            The destination of the link or image, with backslash escapes and character references decoded.

                                            Equations
                                            Instances For

                                              The title of the link or image, if it has one, with backslash escapes and character references decoded.

                                              Equations
                                              Instances For

                                                The whole inline element, from its first to its last character.

                                                Equations
                                                Instances For

                                                  The subslice from the start of the first element to the end of the last, if there are any.

                                                  Equations
                                                  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
                                                      Instances For

                                                        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

                                                          The normalized form of label, for a label that is given as a string.

                                                          Equations
                                                          Instances For
                                                            @[reducible, inline]

                                                            A mapping from normalized link labels to a document's reference targets.

                                                            Equations
                                                            Instances For