diff --git a/DESCRIPTION b/DESCRIPTION index e0513926c..61a563656 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: sandpaper Title: Create and Curate Carpentries Lessons -Version: 0.11.15 +Version: 0.11.16 Authors@R: c( person(given = "Zhian N.", family = "Kamvar", diff --git a/NEWS.md b/NEWS.md index 31a22c16e..491557abf 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,10 @@ +# sandpaper 0.11.16 (unreleased) + +## BUG FIX + +- links to markdown files under `episodes/{data,fig,files}` folders are no + longer converted to html extensions. + # sandpaper 0.11.15 (2023-04-05) ## BUG FIX diff --git a/inst/rmarkdown/lua/lesson.lua b/inst/rmarkdown/lua/lesson.lua index 2e226f333..e94d1e34d 100644 --- a/inst/rmarkdown/lua/lesson.lua +++ b/inst/rmarkdown/lua/lesson.lua @@ -422,8 +422,15 @@ flatten_links = function(el) -- rename local markdown/Rmarkdown -- link.md goes to link.html -- link.md#section1 goes to link.html#section1 - local proto = text.sub(tgt, 1, 4) - if proto ~= "http" and proto ~= "ftp:" then + -- We want to transformt the links only for local markdown files + -- TODO: revisit this to allow/disallow/retransform files that should be + -- included. + local our_prose = tgt:find("^https?:") == nil and + tgt:find("^ftp:") == nil and + tgt:find("^data/") == nil and + tgt:find("^files/") == nil and + tgt:find("^fig/") == nil + if our_prose then tgt,_ = tgt:gsub("%.R?md(#[%S]+)$", ".html%1") tgt,_ = tgt:gsub("%.R?md$", ".html") end diff --git a/tests/testthat/_snaps/render_html.md b/tests/testthat/_snaps/render_html.md index d5643bf7d..d77d57d1a 100644 --- a/tests/testthat/_snaps/render_html.md +++ b/tests/testthat/_snaps/render_html.md @@ -31,7 +31,8 @@ ,Para [Str "This",Space,Link ("",[],[]) [Str "rmd",Space,Str "link",Space,Str "also"] ("01-Introduction.html","")] ,Para [Str "This",Space,Link ("",["newclass"],[]) [Str "rmd",Space,Str "is",Space,Str "safe"] ("https://example.com/01-Introduction.Rmd","")] ,Para [Str "This",Space,Link ("",[],[]) [Str "too"] ("Setup.html#windows-setup","windows setup")] - ,Para [Image ("fig-first",["imgclass"],[("alt","alt text")]) [Str "link",Space,Str "should",Space,Str "be",Space,Str "transformed"] ("fig/Setup.png","fig:")]]]] + ,Para [Image ("fig-first",["imgclass"],[("alt","alt text")]) [Str "link",Space,Str "should",Space,Str "be",Space,Str "transformed"] ("fig/Setup.png","fig:")] + ,Para [Str "This",Space,Link ("",[],[]) [Str "markdown",Space,Str "data",Space,Str "file",Space,Str "is",Space,Str "also",Space,Str "safe"] ("data/markdown-example.md","")]]]] ,Div ("accordionSolution1",["accordion","challenge-accordion","accordion-flush"],[]) [Div ("",["accordion-item"],[]) [RawBlock (Format "html") "" @@ -119,6 +120,7 @@
+ diff --git a/tests/testthat/examples/ex.md b/tests/testthat/examples/ex.md index bc67f8e58..da64cc65b 100644 --- a/tests/testthat/examples/ex.md +++ b/tests/testthat/examples/ex.md @@ -31,6 +31,8 @@ This [too](learners/Setup.md#windows-setup 'windows setup') ![link should be transformed](../episodes/fig/Setup.png){#fig-first .imgclass alt='alt text'} +This [markdown data file is also safe](data/markdown-example.md) + ::: solution # Write now