Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support new pre_knit feature #582

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading