While Verso genres may generate whatever output is necessary, some aspects of the Verso infrastructure make assumptions about generated HTML.
In particular, Verso assumes that HTML follows these conventions:
-
Each page contains a <base> tag that points at the site root, and all URLs are relative to the site root.
-
Pages are served as directories that contain an index.html file, rather than as bare HTML files. In other words, instead of page.html, the page should be served as page/index.html. This affects the meaning of relative URLs.
5.1.1.1. CSS🔗
The names of CSS variables that are intended for customization begin with --verso-, with a single - before the variable's name.
Variables that are a part of the Verso implementation and are not intended to be directly customized use two - characters, and thus begin with --verso--.
The customizable variables and their default values are defined in verso-vars.css, which is included as the string constant Html.«verso-vars.css».
Each page should include this stylesheet.
🔗def
CSS variables used by all genres that should support HTML output.
5.1.1.2. Lean Code in HTML🔗
Lean code is rendered using a set of built-in CSS rules.
The colors and fonts that they use are controlled by CSS variables, documented in verso-vars.css.
Each category of token that can be highlighted supports customization of its color, font weight, font style, and font family.
Constants (such as List or id) are controlled by the --verso-code-const- family, keywords (such as def or induction) by the --verso-code-keyword- family, and local bindings (such as x in let x := 5) by the --verso-code-var- family.
For example, keywords are styled by --verso-code-keyword-color, --verso-code-keyword-weight, --verso-code-keyword-style, and --verso-code-keyword-font-family.
Each message severity (info, warning, and error) has four sets of related styles, exemplified here for the error severity:
-
the affected code itself, via --verso-code-error-color, --verso-code-error-bg-color, --verso-code-error-hover-color, and --verso-code-error-hover-bg-color, plus --verso-error-indicator-color for the wavy underline that marks the presence of a message,
-
the text of the message, via --verso-message-error-color,
-
the tooltip that displays the message, via --verso-tooltip-error-color, --verso-tooltip-error-bg-color, and --verso-tooltip-error-border-color, and
-
the marker bar on output blocks, via --verso-output-error-color.
For readability, message text is rendered in a single color.
Syntax highlighting of embedded Lean code is limited to typographic properties such as weight.
Tooltips share a generic palette (--verso-tooltip-color, --verso-tooltip-bg-color, --verso-tooltip-border-color, and --verso-tooltip-separator-color) that the severity-specific tooltip colors default to.
Proof states are styled by the --verso-tactic-state- and --verso-tactic-toggle- variable families, and the hover highlight on interactive code by --verso-code-hover-bg-color.
Data intended for hovers is deduplicated while generating HTML.
The content of all hovers is saved in -verso-docs.json in the site root.
The data-verso-hover attribute stores the index of the hover information in this file.
Rendering highlighted code requires supporting CSS and JavaScript on each page that contains it:
-
highlightingStyle contains the CSS rules that style highlighted code.
-
highlightingJs produces JavaScript code that displays hovers and highlights other occurrences of an identifier. By default, it obtains hover content using fetchDocsJson.
-
Hovers are displayed using the tippy.js and popper.js libraries. Copies of them are included as the string constants Highlighted.WebAssets.tippy and Highlighted.WebAssets.popper, with source maps Highlighted.WebAssets.tippy.map and Highlighted.WebAssets.popper.map and a stylesheet Highlighted.WebAssets.tippy.border.css.
-
Markdown in documentation shown in hovers is rendered by the marked library, included as the string constant Highlighted.WebAssets.marked with source map Highlighted.WebAssets.marked.map.
🔗def
CSS rules that style highlighted Lean code, including its tokens, messages, and proof states.
Pages that contain highlighted code should include these rules in a stylesheet. The colors and
fonts that the rules apply are controlled by CSS variables, documented in verso-vars.css.
🔗def
JavaScript code that implements the interactive features of highlighted Lean code, displaying
hovers and highlighting other occurrences of an identifier.
The parameter highlightJsonPromise is a JavaScript expression that evaluates to a promise
that provides the hover content.
🔗def
A JavaScript expression that fetches hover content from -verso-docs.json in the site root.
This is the default means by which the code generated by highlightingJs obtains hover content.
5.1.1.3. Math🔗
TeX-style mathematical notation (written $`f(x)` or $$`f(x)`, and represented by the Inline.math constructor) is rendered to a <code> element with the class math, together with the class inline or display according to the requested mode.
The element's text content is the TeX code, which is not processed while generating HTML.
For example, $`\frac{1}{2}` is represented in HTML as <code class="math inline">\frac{1}{2}</code>.
Math is typeset in the browser using the bundled KaTeX library.
When a page has loaded, the script in Html.math.js renders every element with these classes.
Pages that contain mathematical notation should include this script together with KaTeX itself: its stylesheet (Html.katex.css), its code (Html.katex.js), and its fonts (Html.katexFonts).
The stylesheet refers to the fonts by relative paths, so the file layout described in their docstrings should be preserved.
🔗def
The minified KaTeX CSS file's contents, to be placed parallel to the JS and fonts, in a file named katex/katex.min.css.
🔗def
The minified KaTeX JS file's contents, to be placed parallel to the CSS and fonts, in a file named katex/katex.min.js.
🔗def
The KaTeX font files. Keys are filenames of the form katex/fonts/....
🔗def
A short script that renders all Verso math using KaTeX.