Code, diagrams & math
Fenced code blocks get real syntax highlighting, and Mermaid diagrams and LaTeX math render right in the file.
Any fenced code block (/code in the slash menu, or typing ```` ```lang ```` yourself) is syntax-highlighted as you type, for any language CodeMirror recognizes from the fence's language tag. Inserting one from the slash menu offers a language picker.
Format Code (SHIFT+ALT+F, or the palette) tidies the code block under the caret with Prettier: JavaScript, TypeScript, JSON, CSS, SCSS, Less, HTML, Vue, YAML and GraphQL. It follows the nearest Prettier config in the vault (see Code files), runs only when you ask, and is one undo step.
Insert a diagram with /mermaid or type a ```mermaid fence. Once the fence is closed, the editor shows the rendered diagram in its place. Double-click it (or use its Edit button, or press CTRL/CMD+SHIFT+ENTER with the cursor next to it) to edit the source with a live preview. From there, Open viewer lets you zoom, fit-to-width, and download the SVG. Syntax errors show in place of the diagram.
Display math works the same way: put LaTeX between $$ lines (or on one line, as $$ E = mc^2 $$), or in a ```math fence, and it renders with KaTeX.
```mermaid
graph TD
A[Start] --> B{Decision}
B -->|Yes| C[Do it]
B -->|No| D[Skip it]
```