markbind icon indicating copy to clipboard operation
markbind copied to clipboard

Fenced code syntax highlighting not working when language flag has leading/trailing whitespaces

Open yyccbb opened this issue 10 months ago • 1 comments

Please confirm that you have searched existing issues in the repo

Yes, I have searched the existing issues

Any related issues?

No response

Tell us about your environment

MacOS 15.3 / Windows 11

MarkBind version

5.5.3

Describe the bug and the steps to reproduce it

For example, "```python" is correctly recognized. "``` python " however, is not recognised and the resulting fenced code block does not show syntax highlighting.

Expected behavior

The markdown-it implementation automatically removes leading and trailing whitespaces when parsing the flag.

Anything else?

I wonder whether this is a design choice of MarkBind.

yyccbb avatar Feb 16 '25 15:02 yyccbb

I have attempted to trace through the processing flow within the markdown-it part using the debugger, adding breakpoints in "node_modules/markdown-it/lib/rules_block/fence.js" and "node_modules/markdown-it/lib/renderer.js", but I do not quite understand how token.info is further processed by MarkBind for syntax highlighting. (@lhw-1 )

yyccbb avatar Feb 17 '25 06:02 yyccbb