highlight.js occasionally does not highlight Haskell/Nix code blocks when editing
Describe the bug When editing a page with a Haskell/Nix/any non-default-highlight.js language code block, syntax highlighting will occasionally break. When this happens, the following warning is displayed in the browser console:
WARN: Could not find the language 'haskell', did you forget to load/include a language module?
WARN: Falling back to no-highlight mode for this block.
The issue is fixed whenever the page is reloaded, or by calling hljs.highlightAll() in the console.
Additional edits will sometimes fix the problem, sometimes not.
To Reproduce Steps to reproduce the behavior:
- Download the emanote-template and start the server.
- Add the following code block to
Tutorials/Slug.md:
```haskell
data Foo = A | B
```
-
- Add/remove lines of text. It may take several edits for the highlighting to stop working. I find that adding a new line of text and then deleting it frequently causes the error.
- Alternatively, refresh the page several times until the highlighting breaks.
Expected behavior Code blocks should be correctly highlighted whenever the page is being edited.
Screenshots
Desktop (please complete the following information):
- Browser: Firefox 120.0.1
- emanote 1.2.0.0
Additional context
The problem seems to only occur with languages that are not included by default in highlight.js. As seen in the screenshot, the syntax highlighting for the yaml code block never breaks. I tried updating the version of highlight.js to 11.9.0, but this had no effect.
Aside: another case for #337 I suppose ...