Skip to content

Commit 21e40d6

Browse files
authored
Support new pre_knit feature (#582)
1 parent 56f0414 commit 21e40d6

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: rticles
33
Title: Article Formats for R Markdown
4-
Version: 0.27.7
4+
Version: 0.27.8
55
Authors@R: c(
66
person("JJ", "Allaire", , "[email protected]", role = "aut"),
77
person("Yihui", "Xie", , "[email protected]", role = "aut",
@@ -89,7 +89,7 @@ BugReports: https://github.com/rstudio/rticles/issues
8989
Imports:
9090
knitr (>= 1.30),
9191
lifecycle,
92-
rmarkdown (>= 2.14),
92+
rmarkdown (>= 2.25),
9393
tinytex (>= 0.30),
9494
utils,
9595
xfun,

R/article.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -507,30 +507,30 @@ springer_article <- function(..., keep_tex = TRUE, citation_package = "natbib",
507507
)
508508

509509
pre_knit_fun <- format$pre_knit
510-
format$pre_knit <- function(input, ...) {
510+
format$pre_knit <- function(input, metadata, ...) {
511511
if (is.function(pre_knit_fun)) pre_knit_fun(input, ...)
512512
# for backward compatibility as we changed the template in
513513
# https://github.com/rstudio/rticles/pull/494
514-
options <- rmarkdown::yaml_front_matter(input)
515514
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),
516515
" and you should check new template or start from a fresh template to get latest resources and new YAML header format."))
517-
if (is.null(options[["classoptions"]])) {
516+
if (is.null(metadata[["classoptions"]])) {
518517
stop("`springer_article()` now requires the 'classoptions' field in YAML front matter. ",
519518
new_template_msg("0.25"), call. = FALSE)
520-
} else if ("sn-mathphys" %in% options[["classoptions"]]) {
519+
} else if ("sn-mathphys" %in% metadata[["classoptions"]]) {
521520
stop("classoptions `sn-mathphys` detected. `springer_article()` now uses 'sn-mathphys-num' or `sn-mathphys-ay`. ",
522521
new_template_msg("0.28"), call. = FALSE)
523522
}
524-
if (!is.null(options[["biblio-style"]])) {
523+
if (!is.null(metadata[["biblio-style"]])) {
525524
warning("`springer_article()` now ignores the 'biblio-style' field in YAML front matter. ",
526525
"Reference style for 'natbib' is now set using the 'classoptions' field.\n",
527-
new_template_msg("0.25"))
526+
new_template_msg("0.25"),
527+
immediate. = TRUE, call. = FALSE)
528528
}
529-
if (!is.null(options[["PACS"]])) {
529+
if (!is.null(metadata[["PACS"]])) {
530530
warning("`springer_article()` now ignores the 'PACS' field in YAML front matter to use `pacs.jel` and `pacs.msc`. ",
531-
new_template_msg("0.25"))
531+
new_template_msg("0.25"), immediate. = TRUE, call. = FALSE)
532532
}
533-
if (!is.null(options[["authors"]][["name"]])) {
533+
if (!is.null(metadata[["authors"]][["name"]])) {
534534
stop("`springer_article()` now uses different authors and affiliations fields.\n",
535535
new_template_msg("0.25"), call. = FALSE)
536536
}

0 commit comments

Comments
 (0)