Behaviour SwRS-MDOKFSTUDIO-MYST-024
Maths is typeset offline by KaTeX and bad formulas stay readable
When a document holds `$...$`, `$$...$$`, the `{math}` role or directive, or an align-style environment inside `$$` or `{math}`, the extension SHALL typeset it as maths with KaTeX from the extension bundle without network or inline styles, keep a formula that cannot be parsed readable, refuse active content, and scroll a long display equation inside its own box.
Step 1 of path 1 in StRS-MDOKFSTUDIO-MYST-006: from “A document holds `$...$`, `$$...$$` or a `{math}` role or directive” to “The formula is typeset”.
Scenarios 9
The situations the tests check; open one to read it.
nominalInline maths is typeset in the text line
Given`$x^2$` and `$a + b$` in a sentence
Whenthe preview renders
Thenboth inline math spans sit in the text line
boundaryDisplay maths is typeset in its own block
Given`$$ ... $$` and a `\begin{align}` block
Whenthe preview renders
Thendisplay math is typeset in its own block
nominalMaths typesets offline without inline styles
Givena document with display math
Whenthe preview renders offline
Thenthe equation is typeset with the KaTeX stylesheet and fonts of the extension bundle, with no script, no network request and no inline style attribute, the styles being classes in one nonce-protected style block
refusalA style declaration that could leave its rule
Giventypeset maths whose style value holds a declaration with a brace, an angle bracket, an at sign or a backslash
Whenthe nonce style block is built
Thenthat declaration is dropped and the other declarations stay
refusalThe KaTeX bundle is missing
Giventhe KaTeX bundle is missing
Whenthe preview renders
Thenequations stay as raw TeX text
refusalUnparsable formulas stay readable
Givena document with one invalid and one valid formula, or with only an invalid formula
Whenthe preview renders
Thenthe outcomes of the table hold
| Document | Outcome |
|---|---|
| one invalid and one valid formula | the invalid one keeps its raw TeX with a wavy underline and the tooltip This equation could not be rendered by KaTeX, and the valid one is typeset |
| only an invalid formula | the same raw TeX with underline and tooltip, and no warning is listed in the status region or Problems view |
refusalMaths cannot run active content
Givena formula that uses `\href`, `\htmlStyle`, another trusted command, or a runaway macro
Whenthe preview renders
Thenthe outcomes of the table hold
| Formula | Outcome |
|---|---|
| `\href{...}{x}` | error text is shown and no link exists |
| `\htmlStyle` | no style is applied |
| runaway macro | expansion stays within 1000 (maxExpand) and size within 100 (maxSize); trust is off |
boundarySphinx-style math delimiters are typeset
Givena math span `\(x^2\)` and a math block `\[...\]`, then plain text with `$...$` outside math nodes, code, and a second typesetting pass
Whenthe preview renders
Thenboth delimiters are typeset, the text with `$...$` outside math nodes and the code are unchanged, and the second pass changes nothing
boundaryLong display equations scroll inside their box
Givena very long display equation wider than the pane, and the long chapter scrolled to its display equation
Whenthe preview renders and the scroll lands
Thenthe equation box has overflow-x auto, the page has no horizontal overflow and the equation block stays in the frame
Implemented in 2
Tested by 6
Replaces
SwRS-MDOKFSTUDIO-MYST-025Maths typesets offline without inline styles superseded superseded by SwRS-MDOKFSTUDIO-MYST-024 Markdown file
SwRS-MDOKFSTUDIO-MYST-026Unparsable formulas stay readable superseded superseded by SwRS-MDOKFSTUDIO-MYST-024 Markdown file
SwRS-MDOKFSTUDIO-MYST-027Maths cannot run active content superseded superseded by SwRS-MDOKFSTUDIO-MYST-024 Markdown file
SwRS-MDOKFSTUDIO-MYST-028Sphinx-style math delimiters are typeset superseded superseded by SwRS-MDOKFSTUDIO-MYST-024 Markdown file
SwRS-MDOKFSTUDIO-MYST-029Long display equations scroll inside their box superseded superseded by SwRS-MDOKFSTUDIO-MYST-024 Markdown file