CodeMirror's hypermd syntax highlighter stops working inside a code block
See original GitHub issuePreviously I have reported a bug with CodeMirror’s implementation in the Obsidian knowledge base editor.
Initially, you were hesitant to fix the issue, but eventually, after Obsidian’s developer chimed in, the issue was pinpointed to the Obsidian code and resolved. Hurray! 👍
Now I am coming to you with another issue that has to do with Obsidian and CodeMirror. I reported the bug to the Obsidian and the Admonition plugin developers, but they say that the issue is outside of their reach. I hope that you can check the bug and either fix it or tell me that the bug is not on CodeMirror’s end and thus try to convince the Obsidian/plugin developers that it’s them who should fix it.
Copy of the original bug report (please check for more comments):
How to reproduce the bug
- Add 3 test lines inside the admonition:
- Use Obsidian/markdown quote feature(
>
) on the second line. BUG: Notice that syntax highlighter stopped working on all the lines even below the quoted one.
Other interesting detail
Putting a code block returns highlighting back to normal.
Versions
- Obsidian 0.12.10
- Admonition 6.2.2
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
There seems to be a problem with highlighting code blocks in ...
When initializing the editor, I assigned a long text to the doc attribute. Then, when the page first enters or refreshes, the editor...
Read more >Syntax highlighter stops working after using Obsidian ...
I reported the bug, but the developer said " I think this is the default behavior for the hypermd CodeMirror syntax highlighter inside...
Read more >HTML formatting inside highlighted code blocks is no longer ...
Why is text formatting in code blocks now broken? This is caused by a change to the syntax highlighter used by Stack Overflow,...
Read more >Not highlighting on post page but highlighting on edit page
[This thread is closed.] When I'm editing a post, codemirror blocks is properly highlighting the syntax for me, and in real-time too, very…...
Read more >obsidian syntax highlighting not working - Moneywecan
This imports a bunch of syntax highlighting modes from CodeMirror, ... To insert a code block use the ` (Found Under your escape...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This appears to be a bug in the CodeMirror 5 markdown mode. You can replicate the issue on the demo site https://codemirror.net/mode/markdown/ with the following code
This appears to happen due to the local code block mode state not being reset for quotes. Once a quote is detected on a line. Quote is set to 1 in the local mode state and never reset.
I was able to resolve this by patching the markdown.js mode to add the line:
state.quote = 0;
after this line https://github.com/codemirror/CodeMirror/blob/47e850575ea314f768ca8539de54ab7a6d8f3779/mode/markdown/markdown.js#L826@nothingislost Since it was you who discovered the solution, I think it would only be fair for you to do the honors. 😃