Skip to content

Commit

Permalink
fix #103: mark the content in I() after reading the files, so that is…
Browse files Browse the repository at this point in the history
…_file() won't check if the strign is a file again

also suppressWarnings() on file.exists() (this may be unneccesary but just to be conservative here)
  • Loading branch information
yihui committed Aug 21, 2023
1 parent 3cf3125 commit 5cf5733
Show file tree
Hide file tree
Showing 3 changed files with 6 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: markdown
Type: Package
Title: Render Markdown with 'commonmark'
Version: 1.7.1
Version: 1.7.2
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666")),
person("JJ", "Allaire", role = "aut"),
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# CHANGES IN markdown VERSION 1.8

- Fixed the superfluous warning about path lengths in `mark_html()` (thanks, @kenjisato, #103).

# CHANGES IN markdown VERSION 1.7

Expand Down
7 changes: 4 additions & 3 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ match_replace = function(x, pattern, replace = identity, ..., perl = TRUE) {

# test if an input is a file path; if shouldn't be treated as file, use I()
is_file = function(x) {
length(x) == 1 && !inherits(x, 'AsIs') && xfun::file_exists(x)
length(x) == 1 && !inherits(x, 'AsIs') && suppressWarnings(xfun::file_exists(x))
}

# substitute a variable in template `x` with its value; the variable may have
Expand Down Expand Up @@ -314,7 +314,7 @@ get_option = function(name, default = NULL) {
one_string = function(x) {
if (!is.character(x)) return('')
if (is_file(x)) x = xfun::read_utf8(x)
paste(x, collapse = '\n')
I(paste(x, collapse = '\n'))
}

# find headings and build a table of contents as an unordered list
Expand Down Expand Up @@ -725,7 +725,8 @@ resolve_files = function(x, ext = 'css') {
)
x[i] = files[match(x[i], b)]
x = c(x[i], x[!i])
if (ext %in% c('css', 'js')) gen_tags(x, ext) else xfun::read_all(x)
x = if (ext %in% c('css', 'js')) gen_tags(x, ext) else xfun::read_all(x)
I(x)
}

# generate tags for css/js depending on whether they need to be embedded or offline
Expand Down

0 comments on commit 5cf5733

Please sign in to comment.