question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Text of non-'.Rmd' markdown files is analyzed as R code

See original GitHub issue

I would like to use the VSCode R extension to “knit” plain Markdown files in addition to R Markdown files. To do so, I associated the file extension md with the R Markdown language. In settings.json:

    "files.associations": {
        "*.md": "rmd"
    },

That works, and I can now press Ctrl+Shift+K to knit the document.

However, I get a strange linting (?) error:

image

It seems to be triggered by short words, but only by the first one in the text, later repetitions are ignored.

In this case, the error details are

[{
	"resource": "/home/ca/Store/lab/pandoc-ng/notes.md",
	"owner": "_generated_diagnostic_collection_name_#0",
	"severity": 8,
	"message": "unexpected symbol",
	"source": "error",
	"startLineNumber": 1,
	"startColumn": 6,
	"endLineNumber": 1,
	"endColumn": 7
}]

Hovering over the word opens documentation for the R function is(object, class2). It therefore appears as if the text is analyzed as R code?

This interpretation is supported by another observation: If I write a few letters and then activate suggestions (e.g. by Ctrl+Space) I get R-language suggestions:

image

Describe the bug

The text of non-‘.Rmd’ markdown files is analyzed as R code

To Reproduce Steps to reproduce the behavior:

  1. Create a file with the extension .md and open it.
  2. Associate .md with the language rmd
  3. Write “what is this”.
  4. A red squiggle appears under “is”.

Do you want to fix by self? (We hope your help!)

I tried to simply disable linting, but couldn’t find an option to do so.

(If yes,) what kind of help do you want? (e.g. Which file should I fix, Survey (related documents)

Since this same behavior does not appear for .Rmd files, I suspect that some kind of exception is hard-coded for this file extension. I propose to create an option which allows to configure which file extension(s) are excepted. This would allow to use Markdown processing to be used in VS Code in the same way as it can be used in RStudio.

Environment (please complete the following information):

  • OS: Debian 11.2
  • VSCode Version: 1.63.2
  • R Version: 4.0.4
  • vscode-R version: 2.3.5

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
renkun-kencommented, Jan 5, 2022

No need to close this one. Will close both together in the PR.

0reactions
allefeldcommented, Jan 6, 2022

The linting error does not occur anymore.

Thanks for the quick fix!

Read more comments on GitHub >

github_iconTop Results From Across the Web

12.2 Text Formatting in R Markdown - R Programming
Here, text in the .Rmd file is called the marked up text, and text in the output document is called the formatted text....
Read more >
Sharing common code across analyses
To share text and code chunks across R Markdown files, you can use child documents, a feature of the knitr package. Here is...
Read more >
9 Documenting your results with R Markdown | Data Analysis ...
With R Markdown, you can easily create a document which combines your code, the results from your code, as well as any text...
Read more >
27 R Markdown | R for Data Science
27.1 Introduction R Markdown provides an unified authoring framework for data science, combining your code, its results, and your prose commentary.
Read more >
R Markdown and Reading Data Into R
Rmd file anatomy: Text ... The R Markdown file is a text file where you save all the R commands you want to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found