Skip to content

Commit

Permalink
pkg_file_lua() should have thrown an error if the expected Lua file d…
Browse files Browse the repository at this point in the history
…oes not exist, but it didn't because we only checked the existence of the rmarkdown/lua folder, then we used file.path() to construct the paths, which doesn't check for the existence of files
  • Loading branch information
yihui committed Oct 12, 2020
1 parent 7837718 commit e1a3fb6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: rmarkdown
Type: Package
Title: Dynamic Documents for R
Version: 2.4.2
Version: 2.4.3
Authors@R: c(
person("JJ", "Allaire", role = "aut", email = "[email protected]"),
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666")),
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ rmarkdown 2.5

- `html_document` gains the `anchor_sections` argument, which is `TRUE` by default, so that readers can get links to section headers easily---when you mouse over a section hader, you will see a hash symbol `#` at the end of the header, which contains the anchor link to this header. You can click on this link and get the URL in the addres bar of your web browser, or right-click on it and copy the URL from the context menu. The hash symbol is defined by the CSS rule `a.anchor-section::before {content: '#';}`. You can customize it by overriding this rule (e.g., via the `css` argument of `html_document`) and use any other symbols or icons, e.g., `content: "\02AD8;"` (thanks, @atusy, #1884).

- `pkg_file_lua()` should have thrown an error if the expected Lua file does not exist.

- Provide `files_dir` as attribute on return from `render()` when `run_pandoc = FALSE`.


Expand Down
11 changes: 8 additions & 3 deletions R/util.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,14 @@ pkg_file_arg <- function(..., package = "rmarkdown") {
#' # get a specific filter
#' pkg_file_lua(c("pagebreak.lua", "latex_div.lua"))
pkg_file_lua <- function(filters = NULL, package = "rmarkdown") {
lua_folder <- pkg_file("rmarkdown", "lua", package = package, mustWork = TRUE)
if (is.null(filters)) filters <- list.files(lua_folder, "[.]lua$")
pandoc_path_arg(file.path(lua_folder, filters))
files <- pkg_file(
"rmarkdown", "lua", if (is.null(filters)) '.' else filters,
package = package, mustWork = TRUE
)
if (is.null(filters)) {
files <- list.files(dirname(files), "[.]lua$", full.names = TRUE)
}
pandoc_path_arg(files)
}

#' @rdname rmarkdown_format
Expand Down

0 comments on commit e1a3fb6

Please sign in to comment.