-
-
Notifications
You must be signed in to change notification settings - Fork 977
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
Pandoc args conditional to version should be set in pre_processor #2513
Comments
Doing this change could be breaking, if any other package is looking into rmarkdown::html_document()$pandoc$args
#> [1] "--embed-resources"
#> [2] "--standalone"
#> [3] "--variable"
#> [4] "bs3=TRUE"
#> [5] "--section-divs"
#> [6] "--template"
#> [7] "C:\\Users\\chris\\AppData\\Local\\R\\win-library\\4.3\\rmarkdown\\rmd\\h\\default.html"
#> [8] "--no-highlight"
#> [9] "--variable"
#> [10] "highlightjs=1" If we move some of the args into It seems that it is common practice to do this: Even distill does it But can't find on github any other occurrence of this on Github search. A different approach could to revisit this: https://bookdown.org/yihui/rmarkdown-cookbook/install-pandoc.html The problem is when changing the pandoc version from within knitr chunk itself. In a way, this is a bit too late to do that here. Doing it in R console, before rendering works as expected. pandoc::with_pandoc_version("2.7.3", rmarkdown::render("test.Rmd")) From within the document, following the logic of changing pandoc version before rmarkdown happen, we could also use custom knit function ---
title: test
output:
html_document:
self_contained: true
knit: ( \(input, ...) pandoc::with_pandoc_version("2.7.3", rmarkdown::render(input)) )
---
# Header I could even provide this type of function in the Pandoc package to be used that way. knit: pandoc::render_with_pandoc_version So we could also either document it differently, for one of those solution. or propose a new mechanism to allow changing the pandoc version used for rmarkdown, like a specific YAML option (and Suggest usage of pandoc package behind the scene). I believe we could also detect any change of Pandoc version during
Anyhow, there are several ways it seems, and not sure that moving every conditional args definition is possible - it could be too late for doing that in rmarkdown |
I guess it should not be common to change the Pandoc version dynamically inside Rmd. Supporting this is indeed tricky. If the goal is to be able to test different versions of Pandoc, it seems |
I agree with yihui. |
Thanks for you feedback. This confirms my intuitions. I'll handle that with a new function in pandoc package (cderv/pandoc#37)
And in rmarkdown I will do that so that users are aware this is not adviced to change Pandoc version from a code chunk, maybe using |
Please would you update the Rmarkdown bookdown site (https://bookdown.org/yihui/rmarkdown-cookbook/install-pandoc.html) to reflect the latest advice on this. Just now on a work machine I tried setting the pandoc version and directory to use a different version of pandoc and found that it wasn't enough to fix the error; I had to also set RSTUDIO_PANDOC to the other version to get the .Rmd file to knit correctly.
|
Thanks for the reminder @lfmcmillan - I added an update |
What we describe in https://bookdown.org/yihui/rmarkdown-cookbook/install-pandoc.html to run
rmarkdown::find_pandoc()
in setup chunk does not work in some case.My pandoc version is
But now I am trying to use an old one.
This will throw an error
As we can see above Pandoc 2.7.3 is correctly use but
--embed-resources
flag is still used. Though we havermarkdown/R/pandoc.R
Lines 846 to 849 in 8d2d9b8
but this is evaluated when format function are evaluated
rmarkdown/R/html_document_base.R
Lines 42 to 48 in 8d2d9b8
rmarkdown/R/render.R
Lines 474 to 484 in 8d2d9b8
So it is too soon for the change of pandoc version to happen in the setup chunk. That is why
rmarkdown::pandoc_available("2.19")
returns TRUE (on a system where 3.1.2 is available)So we should
pre_processor
stepThe second case would be breaking change. The first seems fine to me.
Weirdly, no one reported. So should not be that often. But I hit that when debugging pagedown and this when changing pandoc version is useful.
The text was updated successfully, but these errors were encountered: