Skip to content

Commit

Permalink
Support new pre_knit feature
Browse files Browse the repository at this point in the history
  • Loading branch information
cderv committed Dec 11, 2024
1 parent 56f0414 commit fbeeb48
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: rticles
Title: Article Formats for R Markdown
Version: 0.27.7
Version: 0.27.8
Authors@R: c(
person("JJ", "Allaire", , "[email protected]", role = "aut"),
person("Yihui", "Xie", , "[email protected]", role = "aut",
Expand Down Expand Up @@ -89,7 +89,7 @@ BugReports: https://github.com/rstudio/rticles/issues
Imports:
knitr (>= 1.30),
lifecycle,
rmarkdown (>= 2.14),
rmarkdown (>= 2.25),
tinytex (>= 0.30),
utils,
xfun,
Expand Down
18 changes: 9 additions & 9 deletions R/article.R
Original file line number Diff line number Diff line change
Expand Up @@ -507,30 +507,30 @@ springer_article <- function(..., keep_tex = TRUE, citation_package = "natbib",
)

pre_knit_fun <- format$pre_knit
format$pre_knit <- function(input, ...) {
format$pre_knit <- function(input, metadata, ...) {
if (is.function(pre_knit_fun)) pre_knit_fun(input, ...)
# for backward compatibility as we changed the template in
# https://github.com/rstudio/rticles/pull/494
options <- rmarkdown::yaml_front_matter(input)
new_template_msg <- function(ver) return (c(sprintf("If you are rendering an old Rmd, be advise that the template has changed in version '%s'\n", ver),
" and you should check new template or start from a fresh template to get latest resources and new YAML header format."))
if (is.null(options[["classoptions"]])) {
if (is.null(metadata[["classoptions"]])) {
stop("`springer_article()` now requires the 'classoptions' field in YAML front matter. ",
new_template_msg("0.25"), call. = FALSE)
} else if ("sn-mathphys" %in% options[["classoptions"]]) {
} else if ("sn-mathphys" %in% metadata[["classoptions"]]) {
stop("classoptions `sn-mathphys` detected. `springer_article()` now uses 'sn-mathphys-num' or `sn-mathphys-ay`. ",
new_template_msg("0.28"), call. = FALSE)
}
if (!is.null(options[["biblio-style"]])) {
if (!is.null(metadata[["biblio-style"]])) {
warning("`springer_article()` now ignores the 'biblio-style' field in YAML front matter. ",
"Reference style for 'natbib' is now set using the 'classoptions' field.\n",
new_template_msg("0.25"))
new_template_msg("0.25"),
immediate. = TRUE, call. = FALSE)
}
if (!is.null(options[["PACS"]])) {
if (!is.null(metadata[["PACS"]])) {
warning("`springer_article()` now ignores the 'PACS' field in YAML front matter to use `pacs.jel` and `pacs.msc`. ",
new_template_msg("0.25"))
new_template_msg("0.25"), immediate. = TRUE, call. = FALSE)
}
if (!is.null(options[["authors"]][["name"]])) {
if (!is.null(metadata[["authors"]][["name"]])) {
stop("`springer_article()` now uses different authors and affiliations fields.\n",
new_template_msg("0.25"), call. = FALSE)
}
Expand Down

0 comments on commit fbeeb48

Please sign in to comment.