Skip to content
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

Preview of Rmarkdown #103

Closed
Ikuyadeu opened this issue Mar 23, 2019 · 18 comments
Closed

Preview of Rmarkdown #103

Ikuyadeu opened this issue Mar 23, 2019 · 18 comments

Comments

@Ikuyadeu
Copy link
Member

Currently, the Markdown file can get a preview.
I believe R markdown file can also get a preview by calling preview command on Markdown.
I put this issue as the TODO

@andycraig
Copy link
Collaborator

By adding the below to settings.json, you can use Markdown: Open Preview on R markdown files. It doesn't do anything special with the R code blocks, though.

"files.associations": {
     "*.Rmd": "markdown"
}

From https://qiita.com/yutannihilation/items/1f71c0fedae6e4b8038c

@Ikuyadeu
Copy link
Member Author

@andycraig Thank you! It is working well.

@Ikuyadeu
Copy link
Member Author

Ikuyadeu commented Apr 15, 2019

I can not use R markdown syntax and inline execution by this change.
We should call Markdown: Open Preview as the R markdown mode.

@andycraig
Copy link
Collaborator

That's right, that change doesn't do anything special with R code blocks.

A better R markdown experience could be gained by adding a command that calls the knitr package, and then previews a resulting HTML or PDF file (maybe using https://marketplace.visualstudio.com/items?itemName=hdg.live-html-previewer and https://marketplace.visualstudio.com/items?itemName=tomoki1207.pdf). This could be a Good First Issue.

RStudio-like inline output from R code blocks would be tougher. I'm not sure if the VSCode editor supports non-text objects.

@andycraig
Copy link
Collaborator

andycraig commented Apr 20, 2019

It looks like the neuron extension might be very helpful here:

https://marketplace.visualstudio.com/items?itemName=neuron.neuron-IPE

I haven't managed to get it running successfully yet though, and it sounds like others are having trouble too: neuron-team/vscode-ipe#187

I've had more success with this fork:
https://marketplace.visualstudio.com/items?itemName=pavan.VSNotebooksBeta
It connects to Jupyter and displays the output of R code sent to it.

@andycraig
Copy link
Collaborator

Using VSNotebooks:

notebook

This setting was necessary to get VSNotebooks to recognise Rmd files:

"files.associations": {
    "*.Rmd": "r"
}

@RobJamesRamos
Copy link

Is this still being worked on? Rmarkdown support is one of the major reasons I don't switch to vscode.

@andycraig
Copy link
Collaborator

Hi @rjBadger, as shown in the video above, the VSNotebooksBeta extension (a fork of the neuron extension) provides some support of R Markdown files, although there is a lot of room for improvement. I'd like to see work on R Markdown support for VSCode made on neuron or one of its forks, so that the improvements also benefit Julia etc. I'm not currently working on anything related to this, though.

@andycraig
Copy link
Collaborator

There is an issue open for adding support for other languages to the (very good) Jupyter component of the Python extension. If you are interested in better notebook support for R, please consider voting for it here: https://github.com/microsoft/vscode-python/issues/5078#issuecomment-507751659

Thank you!

@andycraig andycraig removed their assignment Oct 24, 2019
@renkun-ken
Copy link
Member

With #150, we can use rmarkdown::run(file) to start an HTTP server to show an RMarkdown document, instantly.

@vnijs
Copy link

vnijs commented Dec 18, 2019

That sounds great @renkun-ken! Would this also allow to show chunks of text, math, and or code separately? For an illustration of what I mean, see the GIF below:

vscode-shiny-rmd

@adamaltmejd
Copy link

Would love to have a pdf preview option as well.

@eitsupi
Copy link
Contributor

eitsupi commented Jun 28, 2021

Now that R session watcher is enabled by default in #670, how about adding a button that runs rmarkdown::run(file) and opens a tab, like the button that shows the VSCode default Markdown preview?

@ElianHugh
Copy link
Collaborator

I wonder if it's possible to have run as a task, so that it's non-blocking. Hmm... Live preview would be very neat ;)

@ElianHugh
Copy link
Collaborator

I've tinkered with this idea a bit. A little proof of concept:
pof

@renkun-ken
Copy link
Member

There is an issue with rmarkdown::run() that mathjax and syntax highlight are lost when the document is refreshed. Didn't have time to investigate at the moment. @ElianHugh Are you interested in digging into this?

@ElianHugh
Copy link
Collaborator

ElianHugh commented Jun 30, 2021

Ah, I see what you mean - happy to look into it!

Edit:
A couple of observations:

  • text decoration disappears when the shiny app refreshes the content, not when the page is refreshed manually. i.e., if auto_reload = FALSE, and you refresh the page, the decoration will still be there
  • this issue is not specific to vscode-R, as I could replicate it in RStudio
  • xaringan::inf_mr does not have this problem (although it is slower to load at times)

Syntax highlighting is maintained if a specific highlight theme is declared in the yaml, e.g.

---
title: "My R Doc"
output:
  html_document:
    highlight: kate
---

@ElianHugh
Copy link
Collaborator

Closed by #692.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants