Documentation

DocGen4.RenderedCode

Rendered Code #

Lean's pretty printer produces CodeWithInfos (a TaggedText SubexprInfo), which carries rich metadata such as expression types, universe levels, elaboration state, etc. This is too large to serialize to disk.

RenderedCode is a TaggedText RenderedCode.Tag that keeps only the information needed for HTML rendering: which tokens are declaration references (for linking), which are sorts (for linking to the foundational types page), and which are keywords or strings (for syntax highlighting). The conversion from CodeWithInfos to RenderedCode happens in renderTagged at the bottom of this file.

RenderedCode is serialized to the database as a binary blob via ToBinary/FromBinary instances. If the RenderedCode.Tag or TaggedText types change, the type hash in DocGen4.DB.Schema will detect the mismatch and require a rebuild.

Used in RenderedCode.Tag to track what kind of sort this is.

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

      Tags for code elements in rendered code. Used to indicate semantic meaning for HTML rendering (linking, syntax highlighting).

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

          A simplified representation of code with semantic tags for rendering. Unlike CodeWithInfos, this only contains the information needed for HTML rendering (links to declarations, syntax highlighting) and can be serialized to/from the database.

          Equations
          Instances For

            In Lean syntax declarations the following pattern is quite common:

            syntax term " + " term : term
            

            that is, we place spaces around the operator in the middle. When the InfoTree framework provides us with information about what source token corresponds to which identifier it will thus say that " + " corresponds to HAdd.hadd. This is however not the way we want this to be linked, in the HTML only + should be linked, taking care of this is what this function is responsible for.

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

              Convert CodeWithInfos (from Lean's pretty printer) to RenderedCode by extracting only the information needed for HTML rendering.