-
-
Notifications
You must be signed in to change notification settings - Fork 21
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 other languages inside tagged template strings and commented template strings #484
Comments
We can’t support all possible embedded languages inside MDX files. It’s out of scope of this project. Neither can the builtin TypeScript syntax, that’s why you have those third party extensions. We have documented how extensions can do this specifically for code blocks in
|
This comment has been minimized.
This comment has been minimized.
This comment was marked as resolved.
This comment was marked as resolved.
Yeah, if you mean the 3-backtick Markdown-style code blocks (aka code fences), that's not what I'm trying to get at with this issue (code blocks are mentioned under "Current Solutions") It's about tagged template literals in JSX expressions:
I'm not proposing that MDX Analyzer perform the syntax highlighting - I'm proposing that MDX Analyzer should expose / identify template strings in such a way so that third party extensions also work in MDX documents:
But maybe I'm wrong that MDX Analyzer has anything to do here - maybe this is on the third party extensions, that they support highlighting in JSX expressions inside of MDX documents? They would need to parse the MDX I guess...?
|
Syntax highlighting is done using TextMate grammers. The other extensions need to inject the right grammar into the right scope. There’s no difference between say injecting Mermaid or CSS syntax into markdown code blocks, JavaScript template literals, or block comments. There’s no parsing involved and no work to be done on MDX analyzer. |
Ok got it, so if I'm understanding correctly, it would need to be a grammar update on these other extensions to add template string highlighting support within MDX. |
Created a first issue over here, let's see if the other extensions are open to implementing: |
Initial checklist
Problem
Using the following VS Code extensions allows for highlighting inside of tagged template strings (eg.
css
orhtml
orsql
tagged template strings) and template strings with a comment before them, see right side of VS Code editorOn the MDX side (left side):
Current solutions
I haven't seen a full solution to this with MDX, no.
I have seen that
markdown-tm-language
highlights other languages inside of Markdown code blocks (aka code fences), shown in the demo:But this is not a tagged template string or comment template string, which can be important for features of template strings.
Proposed solutions
Identify template strings within MDX as template strings which the other extensions can add highlighting to.
Alternatives considered
markdown-tm-language
, but then, thinking through it more, it doesn't seem to fit, because this is only a TextMate grammar.The text was updated successfully, but these errors were encountered: