Rmd Color coding doesn't work if there is a space after the backticks and the bracket.
Image for clarity:

Apparently this is still valid for Rmd and will still render without issue -.-
Posted in wrong place please ignore - Sorry
Syntax highlighting is handled in vscode-R.
Looks like Rmd chunk could start with at least three backticks, maybe some spaces, and left brace (`{3,}\s*\{), all marked as code chunk in RStudio and valid for knitr to render.
@andycraig Should we adjust the syntax highlighting to be consistent with RStudio and knitr?
Interesting, I never knew spaces were allowed there! Yes, let鈥檚 adjust the syntax highlighting.
@gowerc This should be a fairly straightforward fix. Are you interested in putting together a PR for it? :)
Happy to try though I caveat I don't know JS or node at all (but could be a good learning experience :) )
@gowerc Great! The R Markdown highlighting is defined in this file: https://github.com/Ikuyadeu/vscode-R/blob/master/syntax/Markdown%20Redcarpet.tmLanguage It's the only file that should need editing. The lines that needed editing are like this: https://github.com/Ikuyadeu/vscode-R/blob/b27399c9bbd2711454367fe0ce73bd77b7b239e6/syntax/Markdown%20Redcarpet.tmLanguage#L97 That one's for R chunks, and there are some for other languages as well.
Instructions for how to get set up for contributing are here: https://github.com/Ikuyadeu/vscode-R/wiki/Contributing
Let us know if you have any difficulties!
@andycraig - Can I just double check my understanding of how this works:
package.json - specifies the new grammars introduced by the package (amongst lots of other stuff)
This then adds the scope text.html.rmarkdown to files that meet the requirements set out by ./syntax/RMarkdown.json which within that file is defined for Rmd and rmd however the actual langauge grammar for text.html.rmarkdown is defined (or inherted/injected) from / within Markdown Redcarpet.tmLanguage ?
How come Rmd grammar is using the xml format and split across 2 files opposed to the R grammar which is just 1 single json file ? Am I missing something ?
On a separate note, the current regex pattern matches on any number of leading/trailing { is this expected ?
ie. it would on any of the following:
{r}
{{r}}
{r
r}
{{{{{{r}
I don't think knitr will render R code unless it is exactly { r <options>} so should we adapt the regex to only match this setup ?
I don't think knitr will render R code unless it is exactly { r
} so should we adapt the regex to only match this setup ?
Matching what knitr will render sounds like a good approach to me. Thank you!
How come Rmd grammar is using the xml format and split across 2 files opposed to the R grammar which is just 1 single json file ? Am I missing something ?
Good questions.
XML/JSON
VS Code supports both. Markdown Redcarpet.tmLanguage existed first, and when I added RMarkdown.json I used a JSON file because I find them easier to work with.
Split across 2 files
The R Markdown definition is complicated because it combines features of multiple languages.
Markdown Redcarpet.tmLanguage: Defines highlighting for R Markdown-specific structuresRMarkdown.json: Causes Rmd files to also use VS Code's built-in Markdown highlightingr.json is the equivalent of Markdown Redcarpet.tmLanguage. For R, there's no equivalent of RMarkdown.json because it doesn't use highlighting defined elsewhere.
The current set up for R Markdown still has some limitations and may not be optimal (#289).
Hopefully that makes things a bit clearer but let me know if you'd like anything else clarified.
Any objections to me converting the .tmLanguage file into Json, my opinion is that it will make it much easier to read and edit in the future and the conversion doesn't look too painful to do
Any objections to me converting the .tmLanguage file into Json, my opinion is that it will make it much easier to read and edit in the future and the conversion doesn't look too painful to do
I agree that it would be easier to read and edit, so it鈥檚 okay by me! My only request is that there鈥檚 a commit that contains ONLY that change.
@Ikuyadeu Is this okay with you?
@andycraig @gowerc Great discussion!
Making syntax files to JSON is good.
Most helpful comment
Happy to try though I caveat I don't know JS or node at all (but could be a good learning experience :) )