-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
Cannot inject grammar to some scopes in Markdown #221682
Comments
Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.91.1. Please try upgrading to the latest version and checking whether this issue remains. Happy Coding! |
you can only inject in-between
https://github.com/mjbvz/vscode-fenced-code-block-grammar-injection-example |
Thanks for your reply. Then how can I inject grammars into the For example, the following grammar is a modified version of Markdown grammar which works injected to "fenced_code_block_ts": {
"begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?i:(typescript|ts)((\\s+|:|,|\\{|\\?)[^`]*)?$)",
"beginCaptures": {
"3": {
"name": "punctuation.definition.markdown"
},
"4": {
"name": "fenced_code.block.language.markdown"
},
"5": {
"name": "fenced_code.block.language.attributes.markdown",
"patterns": [
{
"include": "#codeblock-attributes" // <--- My grammar
}
]
}
},
"end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$",
"endCaptures": {
"3": {
"name": "punctuation.definition.markdown"
}
},
"name": "markup.fenced_code.block.markdown",
"patterns": [
{
"begin": "(^|\\G)(\\s*)(.*)",
"contentName": "meta.embedded.block.typescript",
"patterns": [
{
"include": "source.ts"
}
],
"while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)"
}
]
}, However, this is only for TypeScript, and in this way all embedded languages need a new pattern. |
as far as I'm aware you could maybe ask @mjbvz kindly to add an empty |
Thanks for your advice. In that case I may generate all the code blocks on my grammar file to simplify the task. However, I am wondering why the Thanks a lot! |
What's the goal with these injections? |
Slidev.js has some special attributes for code blocks. For example, line highlighting. And the expected highlighting is: which is exactly the And it is common for Markdown-based CMS to add its syntax into this scope, for example, VitePress
|
Thanks. Can you test if adding the empty patterns element to We can pretty easily add this for all of our built-in languages |
Yes, it works. In fact, I've used some code to generate new grammars with May I ask if is there any way to to support injection to any scope without |
Thanks. Can you please file an issue against https://github.com/microsoft/vscode-textmate for the injection issue Also if you want to add the empty patterns element, you can do so over in this repo: https://github.com/microsoft/vscode-markdown-tm-grammar Should just require changing |
Does this issue occur when all extensions are disabled?: Yes. Except the current extension
Steps to Reproduce:
The "Success Injection" is injected correctly, while the "Failed Injection" is not.
5. Open
./synatxes/failed.json
and./synatxes/success.json
, they are all the same except theinjectionSelector
.After some testing, I think most of the scopes can be injected, while the following can't:
fenced_code.block.language.attributes.markdown
fenced_code.block.language.markdown
punctuation.definition.markdown
The text was updated successfully, but these errors were encountered: