Skip to content

Preview of Rmarkdown #103

Closed
Closed

Description

@Ikuyadeu

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

Activity

  1. andycraig commented on Apr 14, 2019

    @andycraig
    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

  2. Ikuyadeu commented on Apr 15, 2019

    @Ikuyadeu
    MemberAuthor

    @andycraig Thank you! It is working well.

  3. Ikuyadeu commented on Apr 15, 2019

    @Ikuyadeu
    MemberAuthor

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

  4. andycraig commented on Apr 16, 2019

    @andycraig
    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.

  5. andycraig commented on Apr 20, 2019

    @andycraig
    Collaborator

    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.

  6. andycraig commented on Apr 24, 2019

    @andycraig
    Collaborator

    Using VSNotebooks:

    notebook

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

    "files.associations": {
        "*.Rmd": "r"
    }
    
  7. RobJamesRamos commented on Jul 12, 2019

    @RobJamesRamos

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

  8. andycraig commented on Jul 14, 2019

    @andycraig
    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.

  9. andycraig commented on Jul 15, 2019

    @andycraig
    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!

  10. removed their assignment
    on Oct 24, 2019
  11. renkun-ken commented on Dec 18, 2019

    @renkun-ken
    Member

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

  12. vnijs commented on Dec 18, 2019

    @vnijs

    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

  13. adamaltmejd commented on Feb 25, 2021

    @adamaltmejd

    Would love to have a pdf preview option as well.

  14. eitsupi commented on Jun 28, 2021

    @eitsupi
    Member

    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?

  15. ElianHugh commented on Jun 29, 2021

    @ElianHugh
    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 ;)

  16. ElianHugh commented on Jun 30, 2021

    @ElianHugh
    Collaborator

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

  17. renkun-ken commented on Jun 30, 2021

    @renkun-ken
    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?

  18. ElianHugh commented on Jun 30, 2021

    @ElianHugh
    Collaborator

    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
    ---
  19. ElianHugh commented on Jul 21, 2021

    @ElianHugh
    Collaborator

    Closed by #692.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions