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

Style Quarto documents (.qmds) #913

Closed
mine-cetinkaya-rundel opened this issue Feb 17, 2022 · 13 comments · Fixed by #931
Closed

Style Quarto documents (.qmds) #913

mine-cetinkaya-rundel opened this issue Feb 17, 2022 · 13 comments · Fixed by #931

Comments

@mine-cetinkaya-rundel
Copy link

Currently, running the "Style active file" addin (styler:::style_active_file()) on a Quarto document (.qmd) gives the error Can only style .R, .Rmd and .Rnw files.. This is a feature request to extend styler functionality to Quarto documents. Thank you!

@lorenzwalthert
Copy link
Collaborator

It seems to me as .qmd has the same semantics to declare code blocks as .Rmd, only the file extension is different. Can you confirm that?

@MichaelChirico
Copy link
Contributor

it looks like there's likely to be some divergence, now or in the future:

Quarto is a multi-language, next generation version of R Markdown from RStudio, and includes dozens of new features and capabilities (while at the same being able to render most existing Rmd files without modification).

@lorenzwalthert
Copy link
Collaborator

@JohannesNE are you interested in contributing this feature? It seems quite similar to your work in #824. @MichaelChirico I think the specs might change in the future, but I think it's unlikely that something as fundamental as how code fences are declared will change. These are stable things since the introduction of R Markdown and are also recognized by Jupyter (which quarto relies on also)

@mine-cetinkaya-rundel
Copy link
Author

It seems to me as .qmd has the same semantics to declare code blocks as .Rmd, only the file extension is different. Can you confirm that?

@lorenzwalthert Yes, that is correct!

@JohannesNE
Copy link
Contributor

JohannesNE commented Feb 19, 2022 via email

@lorenzwalthert
Copy link
Collaborator

lorenzwalthert commented Feb 19, 2022

Ok @JohannesNE, I appreciate the quick response.

@lorenzwalthert
Copy link
Collaborator

@MichaelChirico or @mine-cetinkaya-rundel, if you are interested to contribute that feature, I'd be more than happy to provide guidance and code review. The git diff from #824 should be very helpful in implementing that feature, it's essentially the same.

@lorenzwalthert
Copy link
Collaborator

lorenzwalthert commented Mar 17, 2022

@mine-cetinkaya-rundel you want to try out renv::install("r-lib/styler#931") and tell me if it works for you?

@mine-cetinkaya-rundel
Copy link
Author

@lorenzwalthert Just tried this on a .qmd file and it doesn't seem to work for me.

The error about not being able to style this type of file isn't there, but the style is not being corrected. This is the document I'm trying it on:

    ---
    format: html
    ---
    
    ## Quarto
    
    Some text...
    
    ```{r}
    library(tidyverse)
    
    ggplot(mtcars,aes(x=mpg,y=disp))+geom_point()
    ```
    
    ```{r}
    mtcars%>%
    filter(mpg>30)
    ```

@lorenzwalthert
Copy link
Collaborator

The Addin has not worked (with the file error), so I pushed 68e846d to fix this. However, I can't reproduce your problem. Can you provide more context of how you run {styler}. Also, RStudio sometimes requires re-opening the file I figured to see changes made by other processes.

@mine-cetinkaya-rundel
Copy link
Author

@lorenzwalthert This works now, thank you!

@RoyalTS
Copy link

RoyalTS commented Aug 4, 2022

Now that Quarto has hit prime time, time to cut a release?

@lorenzwalthert
Copy link
Collaborator

Releases are generally a bit of work. You have voiced in several places that that you'd want one, which I understand, but there is no release planned in the next few weeks, maybe not months. You can already use that functionality now, also with pre-commit. If you want to contribute to {styler}, I suggest you contribute an easy issue like lorenzwalthert/precommit#437. Interested?

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

Successfully merging a pull request may close this issue.

5 participants