downlit icon indicating copy to clipboard operation
downlit copied to clipboard

downlit_md_path() should only modify R CodeBlocks

Open maelle opened this issue 3 years ago • 1 comments

At least I didn't expect the YAML chunk below to be modified?

just_yaml <- c("```yaml", "layout: single", "```")
tmp <- tempfile()
file.create(tmp)
#> [1] TRUE
tmp2 <- tempfile()
file.create(tmp2)
#> [1] TRUE
writeLines(just_yaml, tmp)
downlit::downlit_md_path(tmp, tmp2)
readLines(tmp2)
#> [1] "<pre class='chroma'>"                                                                 
#> [2] "<span class='nv'>layout</span><span class='o'>:</span> <span class='nv'>single</span>"
#> [3] "</pre>"

Created on 2021-01-04 by the reprex package (v0.3.0.9001)

maelle avatar Jan 04 '21 16:01 maelle

Re-opening — this is fiddly because the CodeBlock AST differs between versions. Probably no point in tackling this until the pandoc package is available.

hadley avatar Apr 27 '21 20:04 hadley