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

downlit_md_path() doesn't (necessarily?) write to out_path #157

Open
jennybc opened this issue Aug 17, 2022 · 0 comments
Open

downlit_md_path() doesn't (necessarily?) write to out_path #157

jennybc opened this issue Aug 17, 2022 · 0 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@jennybc
Copy link
Member

jennybc commented Aug 17, 2022

I was playing with downlit_md_path() for possible use in reprex (tidyverse/reprex#367) and noticed that I could not successfully use out_path. It does seem to work if one is doing everything below temp dir, as one might do in a test.

This reprex shows me working not below session temp dir and out_path is not honoured. (But I show that the downlit-ified file IS left is the session temp dir.)

Related to #41

library(downlit)

md_lines <- c(
  "``` r",
  "(x <- rnorm(3))",
  "#> [1] -0.3454356  1.2070087 -1.0364874",
  "mean(x)",
  "#> [1] -0.05830476",
  "```"
)

input_file <- "sly-fox.md"
brio::write_lines(md_lines, input_file)

file.exists(input_file)
#> [1] TRUE
brio::read_lines(input_file)
#> [1] "``` r"                                  
#> [2] "(x <- rnorm(3))"                        
#> [3] "#> [1] -0.3454356  1.2070087 -1.0364874"
#> [4] "mean(x)"                                
#> [5] "#> [1] -0.05830476"                     
#> [6] "```"

output_file <- "sly-fox-DOWNLIT.md"
file.exists(output_file)
#> [1] FALSE

retval <- downlit_md_path(input_file, out_path = output_file)
file.exists(output_file)
#> [1] FALSE
file.exists(retval)
#> [1] FALSE

fs::dir_ls(tempdir(), regexp = "sly-fox", recurse = TRUE)
#> /tmp/Rtmp9DYJsw/sly-fox-DOWNLIT.md

unlink(input_file)
unlink(output_file)

Created on 2022-08-17 with reprex v2.0.2.9000

@hadley hadley added the bug an unexpected problem or unintended behavior label Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants