-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add syntax highlighting for code fencing using codebraid
syntax
#57
Conversation
…ages except julia (not included in textmate file)
That's weird, when I run |
Thanks for the PR. The file you modified is actually generated from a template using a script. See https://github.com/microsoft/vscode-markdown-tm-grammar#contributing for more detail. The file you specifically want to modify is https://github.com/microsoft/vscode-markdown-tm-grammar/blob/master/build.js#L8 Could you also look into adding a test case for this change |
Ah, my mistake! I will do another pull request with the correct changes then. Or can I modify this existing pull request? Edit: Thanks for your patience on this. I changed the build file, and created a test and running |
Thanks! This should be included in VS Code 1.39 (it's too late for the 1.38 release) |
No thank you for the great work! |
In microsoft#57 support for Codebraid syntax was added, which essentially is just Pandoc attribute syntax, but with a specific class attribute added. The support was added as an extra `identifier` in the list of languages, for which Codebraid has support, such as for python: `\\{\\.python.+?\\}`. The below example would give the following scope: "text.html.markdown markup.fenced_code.block.markdown fenced_code.block.language.markdown" to the entire line: ```{.python .cb.nb jupyter_kernel=python3} ``` However the "language scope" should only be given to the "python" part, and the current support doesn't allow spaces between the curly braces, and it lacks support for all languages. MkDocs allows a few ways to annotate fenced code blocks, but if additional classes, id or key/value pairs are used, then the curly braces must be used and the language must be prefixed with a dot. In simple cases where only the language is specified, then the curly braces and the dot may be omitted. The following are quick examples: ``` { .python #id .class title="My Title"} ``` or ``` python ``` This change removes the Codebraid support from the specific languages as an `identifier` attribute, and moved into the RegEx by defining it as two alternative cases: surrounded by curly braces or allowing them after the language: 1. The case where the entire line after the code fence is wrapped in curly braces. In this case the curly braces is not part of the language and attribute scope. 2. The case where the attributes follows the language specification in all sorts of ways (I'm specifically thinking of you Gatsby microsoft#62). In this case the curly braces are included in the attribute scope as it is not trivial to handle all the various ways it may be used, and since this is the current behavior. @microsoft-github-policy-service agree Closes microsoft#153 Refs: https://github.com/Python-Markdown/markdown/blob/master/docs/extensions/fenced_code_blocks.md
In microsoft#57 support for Codebraid syntax was added, which essentially is just Pandoc attribute syntax, but with a specific class attribute added. The support was added as an extra `identifier` in the list of languages, for which Codebraid has support, such as for python: `\\{\\.python.+?\\}`. The below example would give the following scope: "text.html.markdown markup.fenced_code.block.markdown fenced_code.block.language.markdown" to the entire line: ```{.python .cb.nb jupyter_kernel=python3} ``` However the "language scope" should only be given to the "python" part, and the current support doesn't allow spaces between the curly braces, and it lacks support for all languages. MkDocs allows a few ways to annotate fenced code blocks, but if additional classes, id or key/value pairs are used, then the curly braces must be used and the language must be prefixed with a dot. In simple cases where only the language is specified, then the curly braces and the dot may be omitted. The following are quick examples: ``` { .python #id .class title="My Title"} ``` or ``` python ``` This change removes the Codebraid support from the specific languages as an `identifier` attribute, and moved into the RegEx by defining it as two alternative cases: surrounded by curly braces or allowing them after the language: 1. The case where the entire line after the code fence is wrapped in curly braces. In this case the curly braces is not part of the language and attribute scope. 2. The case where the attributes follows the language specification in all sorts of ways (I'm specifically thinking of you Gatsby microsoft#62). In this case the curly braces are included in the attribute scope as it is not trivial to handle all the various ways it may be used, and since this is the current behavior. @microsoft-github-policy-service agree Closes microsoft#153 Refs: https://github.com/Python-Markdown/markdown/blob/master/docs/extensions/fenced_code_blocks.md
In microsoft#57 support for Codebraid syntax was added, which essentially is just Pandoc attribute syntax, but with a specific class attribute added. The support was added as an extra `identifier` in the list of languages, for which Codebraid has support, such as for python: `\\{\\.python.+?\\}`. The below example would give the following scope: "text.html.markdown markup.fenced_code.block.markdown fenced_code.block.language.markdown" to the entire line: ```{.python .cb.nb jupyter_kernel=python3} ``` However the "language scope" should only be given to the "python" part, and the current support doesn't allow spaces between the curly braces, and it lacks support for all languages. MkDocs allows a few ways to annotate fenced code blocks, but if additional classes, id or key/value pairs are used, then the curly braces must be used and the language must be prefixed with a dot. In simple cases where only the language is specified, then the curly braces and the dot may be omitted. The following are quick examples: ``` { .python #id .class title="My Title"} ``` or ``` python ``` This change removes the Codebraid support from the specific languages as an `identifier` attribute, and moved into the RegEx by defining it as two alternative cases: surrounded by curly braces or allowing them after the language: 1. The case where the entire line after the code fence is wrapped in curly braces. In this case the curly braces is not part of the language and attribute scope. 2. The case where the attributes follows the language specification in all sorts of ways (I'm specifically thinking of you Gatsby microsoft#62). In this case the curly braces are included in the attribute scope as it is not trivial to handle all the various ways it may be used, and since this is the current behavior. @microsoft-github-policy-service agree Closes microsoft#153 Refs: https://github.com/Python-Markdown/markdown/blob/master/docs/extensions/fenced_code_blocks.md
I'd like to add this to the tm grammar so that there is syntax highlighting for code fencing when writing code fences with
codebraid
codebraid
allows writing markdown documents that run the code snippets:https://github.com/gpoore/codebraid/tree/master/examples