Markpad icon indicating copy to clipboard operation
Markpad copied to clipboard

Preview: code blocks are no longer syntax-highlighted in 2.9.1 (works in 2.8.4)

Open liny01-nbsa opened this issue 1 month ago • 2 comments

Version: 2.9.1, portable Markpad_2.9.1_x64.exe, Windows 11, Default Light theme

What happens: In the preview, fenced code blocks with a language (python, json, powershell, clojure, bash) show the language label but no colours at all. The editor view colours the same blocks correctly. Maths (KaTeX) and Mermaid render fine in the same preview.

Expected: Coloured code in the preview, as in 2.8.4. The same file and the same settings, opened with the 2.8.4 portable exe, highlight all five languages in the preview.

To reproduce:

```python
def greet(name: str) -> str:
    # a comment
    return f"hello {name}" if name else "hello"
```

```json
{"name": "markpad", "ok": true}
```

Open the file in 2.9.1 and switch to the preview: both blocks are plain text.

Possibly related: the preview changes between 2.8.4 and 2.9.1, e.g. #1024 (process and sanitize only the blocks that changed) and #1010 (drop async results that a newer action has replaced).

liny01-nbsa avatar Nov 01 '26 22:11 liny01-nbsa

Thanks for the report, and for checking it against 2.8.4. I can reproduce it, on macOS too, and the fix is in #1058.

A build tool upgrade in 2.9.1 made the app load the wrong version of a small add-on that highlights Svelte code. That version crashes when it loads, and it took the whole highlighter down with it, so every language lost its colours. The language labels, maths and diagrams don't depend on the highlighter, so they kept working. Your files and settings are fine, and colours should come back once the fix ships.

The technical side — you can skip this

highlightjs-svelte has a browser entry that expects a global hljs. Vite stopped preferring the package's ES build over that entry in 8.0.10 (vitejs/vite#22297), and 2.9.1 moved from Vite 6 to 8. The import then threw hljs is not defined. It was loaded in the same Promise.all as highlight.js, so highlight.js was lost as well. The fix imports the ES build and keeps a Svelte grammar failure from affecting other languages.

Tested on a macOS build, with your sample and the other three languages you listed. Not tested on Windows, so please tell us if your build still shows plain text once this is released.

PathGao avatar Nov 02 '26 06:11 PathGao

repaird in 2.9.2

PathGao avatar Nov 02 '26 12:11 PathGao