DocsSettings

Code Blocks

Whaatcher can draw code blocks in Markdown previews as diagrams, math, maps and 3D models. The Code Blocks tab in Settings sets which languages it draws.

Open the tab

Choose Whaatcher › Settings… (⌘,) and click Code Blocks. If the tab doesn't fit, choose it from » at the end of the toolbar.

Where blocks are drawn

Code blocks are drawn only in the Preview of Markdown files in Files. The first word on a block's opening line names its language:

```mermaid
flowchart LR
  Edit --> Review
```

Blocks in languages you turned on are drawn in place of their code; others stay as code. If drawing fails, the code stays, with Couldn’t draw this block and the reason.

Languages

Each row shows a language, its renderer (the one package that draws it) and version, the status and a switch:

  • mermaid (mermaid): flowcharts, sequence diagrams and other Mermaid diagrams.
  • math (katex): one formula per block. Typesetting can differ slightly from GitHub, which uses MathJax.
  • plantuml (@plantuml/core): PlantUML diagrams, drawn without a server or Java. @startuml is optional.
  • geojson (leaflet): shapes on a blank background, without a base map.
  • topojson (leaflet and topojson-client): drawn like geojson.
  • stl (three): ASCII STL models that you drag to rotate.

Turn a language on

Turn on a language's switch, and Whaatcher downloads its package from npm and bundles it into one file. The first install also downloads esbuild, which does the bundling. The row shows Installing…, then On with the bundle's size. After that, previews draw without npm or a network connection.

Whaatcher installs only when you turn a language on or click Reinstall. After an update changes a renderer, that language's blocks show as code, and the row says Needs reinstalling — this version of Whaatcher uses a different renderer. Click Reinstall.

npm and Node.js

Installing needs npm, which comes with Node.js. The top of the tab shows the npm Whaatcher found, with its version and path. It looks in the app's PATH, then Volta, nvm (the newest installed version), fnm, mise, asdf, nodenv and Homebrew.

If it says npm wasn’t found. Install Node.js, or choose npm., install Node.js. Whaatcher looks again when you open the tab or turn a language on, so you don't need to restart it.

To use another npm, click Choose npm… and choose the bin folder that has both npm and node, such as ~/.nvm/versions/node/<version>/bin. Find Automatically goes back to searching.

When an install fails

The row shows the reason, such as npm not reaching the registry. A renderer installed earlier keeps working: click Reinstall to retry, or turn the switch on again if none was installed.

The preview shows the same states on a line above the language's first block, such as Installing the mermaid renderer….

Turn a language off

Turning a switch off cancels any install in progress and deletes that language's bundle from ~/Library/Application Support/Whaatcher/CodeBlockRenderers. Its blocks show as code again.

Network requests

Installing sends requests to the npm registry, with packages' install scripts turned off. Renderers send nothing that carries your blocks' content, such as map tile requests. See Data and privacy.