Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax highlighting of injected language not shown in Preview #7

Closed
ThFriedrich opened this issue Jun 30, 2020 · 4 comments
Closed

Comments

@ThFriedrich
Copy link

Thanks @mjbvz for this super helpful example.
Running the example as it is I get the following behavior:
image
It seems within the md.-file the injected Syntax is highlighted but in the Preview, it isn't. Is that by design? Is it possible to transfer the Syntax highlighting functionality into the Preview as well?

My Setup:
Version: 1.46.1
Electron: 7.3.1
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Linux x64 5.3.0-61-generic

@mjbvz
Copy link
Owner

mjbvz commented Jul 2, 2020

This is a known limitation. The markdown preview uses highlight.js for highlighting, not VS Code's highlighting

@mjbvz
Copy link
Owner

mjbvz commented Oct 21, 2020

Closing this as this is current design of VS Code.

microsoft/vscode#56356 would let the preview use VS Code's built-in highlighter instead

@mjbvz mjbvz closed this as completed Oct 21, 2020
@tjpalmer
Copy link

tjpalmer commented Apr 11, 2022

For those finding this in the future, the mermaid markdown example also by @mjbvz shows where to plug in custom syntax highlighting in markdown preview. And vscode-textmate can be used to adapt tokens to hljs class names. It would be nice if vscode did this automatically, but it's possible to wire up manually at this point.

@ThFriedrich
Copy link
Author

Thanks @tjpalmer
I had reached a very similar conclusion back then, indeed using vscode-textmate and vscode-oniguruma. You can check the StackOverflow Question and my implementation for the details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants