diff --git a/DESCRIPTION b/DESCRIPTION index d214d8c684..ea9d965b74 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: rmarkdown Title: Dynamic Documents for R -Version: 2.25.2 +Version: 2.25.3 Authors@R: c( person("JJ", "Allaire", , "jj@posit.co", role = "aut"), person("Yihui", "Xie", , "xie@yihui.name", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-0645-5666")), diff --git a/R/html_document_base.R b/R/html_document_base.R index 8fccb41d4a..d2dff82b1c 100644 --- a/R/html_document_base.R +++ b/R/html_document_base.R @@ -251,6 +251,11 @@ html_document_base <- function(theme = NULL, } extract_preserve_chunks <- function(input_file, extract = extractPreserveChunks) { + # Don't try to modify the input file if it's not .md, otherwise the original + # input could be corrupted (#2534). In theory, preserved chunks should only + # exist in the intermediate .md file from knit(). If the .md file is not + # intermediate but original, this processing should be harmless. + if (!xfun::file_ext(input_file) %in% c('md', 'markdown')) return() input_str <- one_string(read_utf8(input_file)) preserve <- extract(input_str) if (!identical(preserve$value, input_str)) write_utf8(preserve$value, input_file)