Code, diagrams and math
In writing view, code blocks are highlighted by language, Mermaid code is shown as a diagram, and LaTeX formulas are shown typeset.
Code blocks
- Click Code block in the formatting toolbar.
- Choose a language in Code language. The block is highlighted for that language.
The code block’s handle moves or copies the whole block. Blocks longer than 1,500 lines are not highlighted.
Mermaid diagrams
A code block with the language set to mermaid is shown as a diagram. When the cursor moves into the diagram, the source appears above and a live preview below. If the syntax has an error, a line of text below describes it, and the last correct diagram stays.

Math
- Inline math:
$…$or\(…\). - Block math:
$$…$$or\[…\].
When the cursor moves into a formula, the formula expands to its source, which you can edit directly.

Notes
- HTML and PDF exports output formulas and diagrams as they appear on screen. DOCX exports keep formulas as TeX source and convert diagrams to images.
- The first time a diagram or formula is shown, it has to load, and “Loading the diagram engine…” or “Loading the formula engine…” appears briefly.