Documentation

Lean.Data.Html.Syntax

Parsers for HTML syntax #

Helpers #

Character references #

Decodes one character reference starting at i, which must point at at the character & in s. Returns the decoded string, and the position just after ;.

Errors are reported at refAt, which should produce the subsyntax between two offsets into s.

Instances For

    Decodes HTML character references in ref, leaving other characters unchanged.

    Instances For

      Raw symbols #

      def Lean.Html.Syntax.rawSymbol (sym : String) (trailingWs : Bool := false) (expected : List String := [toString "'" ++ toString sym ++ toString "'"]) :

      Parses sym as an atom. Unlike symbol, this parser does not consult the token table, and sym is not registered as a token.

      Trailing whitespace (including Lean-style comments) is consumed and stored in the atom only if trailingWs is set; otherwise it is left to the next parser.

      Instances For

        Interpolations #

        def Lean.Html.Syntax.interpWith (kind : SyntaxNodeKind) (openSym : String) (trailingWs : Bool) :

        Parses an interpolation: a Lean term between openSym and }. Trailing whitespace is consumed only if trailingWs is set.

        Instances For
          Instances For
            Instances For
              @[reducible, inline]
              Instances For
                @[reducible, inline]
                abbrev Lean.Html.Syntax.Interp (isMany : Bool) :
                Instances For
                  structure Lean.Html.Syntax.InterpView (isMany : Bool) :

                  A single-element { term } or many-element {... term } interpolation.

                  • openBrace : Syntax

                    { or {....

                  • term : Term

                    The interpolated term.

                  • closeBrace : Syntax

                    }.

                  Instances For
                    @[instance_reducible]
                    instance Lean.Html.Syntax.instReprInterpView {isMany✝ : Bool} :
                    Repr (InterpView isMany✝)
                    Instances For
                      @[instance_reducible]
                      @[instance_reducible]
                      instance Lean.Html.Syntax.instBEqInterpView {isMany✝ : Bool} :
                      BEq (InterpView isMany✝)
                      def Lean.Html.Syntax.instBEqInterpView.beq {isMany✝ : Bool} :
                      InterpView isMany✝ → InterpView isMany✝ → Bool
                      Instances For
                        def Lean.Html.Syntax.Interp.view {m : Type → Type} {isMany : Bool} [Monad m] [MonadError m] (stx : Interp isMany) :
                        m (InterpView isMany)
                        Instances For
                          def Lean.Html.Syntax.InterpView.of {m : Type → Type} {isMany : Bool} [Monad m] [MonadError m] (stx : Interp isMany) :
                          m (InterpView isMany)
                          Instances For

                            Text content #

                            @[reducible, inline]
                            Instances For
                              @[reducible, inline]
                              Instances For

                                Comments #

                                @[reducible, inline]
                                Instances For
                                  @[reducible, inline]
                                  Instances For

                                    Text contents of an HTML comment, excluding start and end markers.

                                    Instances For

                                      Tag names #

                                      An HTML tag name: an ASCII letter followed by characters other than ASCII whitespace, U+0000 NULL, /, >. This includes custom element names.

                                      Instances For
                                        @[reducible, inline]
                                        Instances For
                                          @[reducible, inline]
                                          Instances For
                                            Instances For

                                              Attribute names #

                                              An HTML attribute name. Attribute names may not start with { (which would conflict with interpolation).

                                              Instances For
                                                @[reducible, inline]
                                                Instances For
                                                  @[reducible, inline]
                                                  Instances For

                                                    Attribute values #

                                                    @[reducible, inline]
                                                    Instances For
                                                      @[reducible, inline]
                                                      Instances For
                                                        Instances For

                                                          Provides a view on the attribute value, decoding character references when the value is a string literal.

                                                          Instances For
                                                            Instances For

                                                              Attributes #

                                                              An HTML attribute. We support double-quoted attribute values <tag name="val">, empty attributes <tag name>, interpolations of one value <tag name={ term }>, and interpolations of a sequence of attributes <tag {... term }/>. Character references are decoded in double-quoted values.

                                                              Instances For
                                                                @[reducible, inline]
                                                                Instances For
                                                                  @[reducible, inline]
                                                                  Instances For
                                                                    Instances For
                                                                      Instances For
                                                                        @[instance_reducible]
                                                                        Instances For
                                                                          Instances For

                                                                            Elements and content #

                                                                            Content is not a syntax category because a category parser starts by reading a Lean token, which fails on text that begins with whitespace or, for example, '. Instead, contentItemFn dispatches to item parsers based on the next character.

                                                                            @[reducible, inline]
                                                                            Instances For
                                                                              @[reducible, inline]
                                                                              Instances For
                                                                                @[reducible, inline]
                                                                                Instances For
                                                                                  @[reducible, inline]

                                                                                  A sequence of HTML text nodes, comments, elements, and interpolations.

                                                                                  Instances For
                                                                                    Instances For
                                                                                      @[instance_reducible]
                                                                                      @[instance_reducible]
                                                                                      Instances For
                                                                                        Instances For
                                                                                          Instances For

                                                                                            A sequence of HTML content nodes: text contents, comments, elements, single-item interpolations { term }, and many-item interpolations {... term } (see interpMany).

                                                                                            Instances For

                                                                                              An HTML element: <tag attr*/> or <tag attr*>content</tag>.

                                                                                              Tags must be closed: void element syntax such as <br>, and implied end tags such as <ul><li>item</ul>, are not supported.

                                                                                              Instances For

                                                                                                Consecutive run of text nodes and comments.

                                                                                                Instances For

                                                                                                  Returns the normalized text contents of this sequence of text nodes and comments:

                                                                                                  • Whitespace that contains a newline (U+000A or U+000D), and is not surrounded by text on both sides, is removed.

                                                                                                  • Other consecutive whitespace is collapsed into a single space (U+0020).

                                                                                                  • HTML character references are decoded into the Unicode characters they represent.

                                                                                                  Throws if an invalid character reference is encountered in the text.

                                                                                                  Instances For

                                                                                                    A syntax spanning all nodes in this view. Useful for reporting elaboration errors.

                                                                                                    Instances For
                                                                                                      Instances For

                                                                                                        Returns the sequence of items in an HTML content node.

                                                                                                        Runs of text interspersed with comments are merged into a single item. This is because their text must be processed together into a single output (see TextCommentsView.getText).

                                                                                                        Instances For

                                                                                                          An HTML literal.

                                                                                                          Instances For