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

pandoc_convert() evaluates output argument in wrong directory #1889

Closed
krlmlr opened this issue Sep 3, 2020 · 1 comment · Fixed by #1890
Closed

pandoc_convert() evaluates output argument in wrong directory #1889

krlmlr opened this issue Sep 3, 2020 · 1 comment · Fixed by #1890

Comments

@krlmlr
Copy link
Contributor

krlmlr commented Sep 3, 2020

In pandoc_convert(), the output argument is forced after changing the working directory. This is unexpected, not documented, and breaks downlit::downlit_md_path() and perhaps others. PR follows.

input <- tempfile("in", fileext = ".md")
input
#> [1] "/tmp/Rtmpl3bcya/in6d94718e979a.md"
writeLines("# Document", input)

output <- "out.md"

# Breaks
writeLines("bogus", output)
normalizePath(output, mustWork = FALSE)
#> [1] "/tmp/Rtmp9ZZAHN/reprex6bed4897d478/out.md"
rmarkdown::pandoc_convert(input, output = normalizePath(output, mustWork = FALSE), verbose = TRUE)
#> /usr/lib/rstudio/bin/pandoc/pandoc +RTS -K512m -RTS /tmp/Rtmpl3bcya/in6d94718e979a.md --output out.md
readLines(output)
#> [1] "bogus"

# Works if we compute output outside of call
writeLines("bogus", output)
output <- normalizePath(output, mustWork = FALSE)
rmarkdown::pandoc_convert(input, output = output, verbose = TRUE)
#> /usr/lib/rstudio/bin/pandoc/pandoc +RTS -K512m -RTS /tmp/Rtmpl3bcya/in6d94718e979a.md --output /tmp/Rtmp9ZZAHN/reprex6bed4897d478/out.md
readLines(output)
#> [1] "Document" "========"

Created on 2020-09-03 by the reprex package (v0.3.0)

yihui pushed a commit that referenced this issue Sep 7, 2020
jonathan-g added a commit to jonathan-g/rmarkdown that referenced this issue Sep 24, 2020
* rstudio_origin/master:
  fix rstudio#1905: a chunk with the class "fold-hide" should only hide itself (rstudio#1906)
  bump version after merging rstudio#1899
  lua filter -> Lua filter
  Add an argument `lua_filters` to pandoc_options() to store them in the output format object (rstudio#1899)
  recursve into the parent dir at the end
  also suppor dir input in proj_root()
  list.files() with full.names = TRUE (so the files could be read with corret paths), and pass down the `file`/`pattern` arguments in the recursion
  use our own proj_root() instead of introducing a dependency
  rename package_root() to proj_root()
  generalize the package_root() function to work with more types of projects
  Discover site generators in index.Rmd files in parent directories (rstudio#1898)
  only install pkgdown for website build (rstudio#1900)
  Generalize number sections (rstudio#1879)
  enable figure cropping in pdf_document() only when both pdfcrop and ghostscript are found (yihui/knitr#954), and do not limit this feature to non-Windows platforms
  add the citation entry for the R Markdown Cookbook
  add lua filter vignette to pkgdown website (rstudio#1894)
  close rstudio#1889: evaluate the output argument before changing working directory in pandoc_convert() (rstudio#1890)
jonathan-g added a commit to jonathan-g/rmarkdown that referenced this issue Sep 24, 2020
Merge remote-tracking branch 'rstudio_origin/master' into css-slash-fix

# By Yihui Xie (12) and others
# Via GitHub
* rstudio_origin/master: (22 commits)
  fix rstudio#1905: a chunk with the class "fold-hide" should only hide itself (rstudio#1906)
  bump version after merging rstudio#1899
  lua filter -> Lua filter
  Add an argument `lua_filters` to pandoc_options() to store them in the output format object (rstudio#1899)
  recursve into the parent dir at the end
  also suppor dir input in proj_root()
  list.files() with full.names = TRUE (so the files could be read with corret paths), and pass down the `file`/`pattern` arguments in the recursion
  use our own proj_root() instead of introducing a dependency
  rename package_root() to proj_root()
  generalize the package_root() function to work with more types of projects
  Discover site generators in index.Rmd files in parent directories (rstudio#1898)
  only install pkgdown for website build (rstudio#1900)
  Generalize number sections (rstudio#1879)
  enable figure cropping in pdf_document() only when both pdfcrop and ghostscript are found (yihui/knitr#954), and do not limit this feature to non-Windows platforms
  add the citation entry for the R Markdown Cookbook
  add lua filter vignette to pkgdown website (rstudio#1894)
  close rstudio#1889: evaluate the output argument before changing working directory in pandoc_convert() (rstudio#1890)
  tweak news
  require Pandoc >= 1.14
  xfun 0.16 is on CRAN now
  ...

# Conflicts:
#	NEWS.md
@github-actions
Copy link

github-actions bot commented Mar 9, 2021

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant