Documentation

Lean.Data.Markdown.InlineCursor

Inline Cursor #

InlineCursor steps through the lines of an InlineSource with drop1, skipping the gaps between lines that contain block markers and removed indentation. InlineContext is the reader state of the inline parser.

A cursor into an InlineSource, analogous to a slice of a String. It consists of the current position, the end of the input, and the index of the line that contains the current position. A parser that is given a cursor reads the text from the current position to the end of the input and nothing else.

  • source : InlineSource s

    The source that is being tokenized.

  • line : Nat

    The index in source.lines of the line that contains startPos, or source.lines.size if it is not contained in any line.

  • startPos : s.Pos

    The position of the next character to read.

  • stopPos : s.Pos

    The position after the last character that the cursor may read.

    It is at most the end of the last line of source. It is before the end of the last line when the cursor is limited to a part of the source, such as the text between a pair of brackets.

Instances For
    def Lean.Markdown.InlineSource.cursor {s : String.Slice} (src : InlineSource s) (startPos stopPos : s.Pos) :

    A cursor at startPos whose input ends at stopPos.

    Equations
    • src.cursor startPos stopPos = { source := src, line := src.lineIndex startPos, startPos := startPos, stopPos := stopPos }
    Instances For

      Whether the input has been fully consumed.

      Equations
      Instances For

        The character at the cursor, if input remains.

        Equations
        Instances For

          The character at the cursor, or the default character if no input remains.

          Equations
          Instances For

            The input after the cursor, as a subslice.

            Equations
            Instances For

              The character at the cursor as a subslice, if input remains.

              Equations
              Instances For

                Advances the cursor by one character. At the end of a line, the cursor moves to the start of the next line, skipping the gap between them.

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

                  Parses a line ending, which is \r\n, \r, or \n (CommonMark §2.1), at cur. Returns the ending as a subslice together with the cursor after it. The ending stops at the end of the input, so a \r just before it is a line ending by itself.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    @[specialize #[]]

                    Advances past the characters at the start of cur that satisfy p.

                    If cur begins with c, returns that character as a subslice together with cur advanced past it.

                    Equations
                    Instances For

                      Advances past a sequence of cs at the start of cur. Returns the cursor after the sequence and its length.

                      Equations
                      Instances For

                        Information needed during parsing the inline contents of a block.

                        • refs : RefTable s

                          The link reference definitions of the entire document.

                        • src : InlineSource s

                          The content to be parsed.

                        • extensions : Extensions

                          The non-standard Markdown extensions that are enabled.

                        Instances For
                          @[inline]

                          The link reference definitions of the entire document.

                          Equations
                          Instances For
                            @[inline]

                            The content to be parsed.

                            Equations
                            Instances For
                              @[inline]

                              The non-standard Markdown extensions that are enabled.

                              Equations
                              Instances For