vscode-R icon indicating copy to clipboard operation
vscode-R copied to clipboard

Rmarkdown snippets not working with ".Rmd" extension but work with ".rmd" extension.

Open marvel64 opened this issue 2 years ago • 3 comments

Hello,

Using the ".Rmd" extension will not allow me to insert Markdown snippets in the file. The Insert Snippets command treats Markdown lines as R language and offers to insert R code snippets. Changing the file extension to ".rmd" resolves that issue and everything works as expected. I have not seen any other issues when using ".Rmd" as extension as the file seems to otherwise be properly recognized as Rmarkdown.

I am intermittently experimenting with VS Code, so I may have changed a setting in the past that causes this behavior but I could not find anything. The file.associations for instance are empty. Any help on how to fix this is appreciated.

Thanks, Marc

VS Code 1.65.2 macOS 12.2.1 vscode-R 2.4.0

marvel64 avatar Mar 13 '22 19:03 marvel64

Does the file have language rmd instead of r?

Could you install the latest languageserver which included https://github.com/REditorSupport/languageserver/pull/511?

renkun-ken avatar Mar 14 '22 01:03 renkun-ken

It is and I have the most recent languageserver version languageserver_0.3.12 .

I tested a little more and it turned out the issue was that one of the earliest code chunks had a trailing space after the three closing backticks. This affects the following scope. After fixing this things work as intended. I attached two screen shots that highlight the issue. The first shows a working situation with no trailing space, and the next two screen shots show the trailing space resulting in the following scope being interpreted as R code. The Markdown heading is not rendered as expected.

Thanks for getting back!

Screen Shot 2022-03-13 at 22 21 43 Screen Shot 2022-03-13 at 22 22 07 Screen Shot 2022-03-13 at 22 22 22

marvel64 avatar Mar 14 '22 03:03 marvel64

OK. I can reproduce what you have observed. Looks like the rmd syntax defined for code chunks is too strict:

https://github.com/REditorSupport/vscode-R/blob/6547330cb10a16f7bd3cdd578139cabf27f82ac0/syntax/Markdown%20Redcarpet.json#L44-L51

renkun-ken avatar Mar 14 '22 05:03 renkun-ken

This issue is stale because it has been open for 365 days with no activity.

github-actions[bot] avatar Mar 15 '23 01:03 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Mar 29 '23 01:03 github-actions[bot]