Skip to content

highlight.js occasionally does not highlight Haskell/Nix code blocks when editing #463

@tmoux

Description

@tmoux

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:

  1. Download the emanote-template and start the server.
  2. Add the following code block to Tutorials/Slug.md:
```haskell
data Foo = A | B
```
    1. 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.
    2. 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

Screenshot 2023-11-30 at 2 24 42 PM

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions