From c26b20ad362b77a8545301651c86e9a267b285d7 Mon Sep 17 00:00:00 2001 From: crsh Date: Fri, 11 Oct 2024 12:07:47 +0200 Subject: [PATCH] Adds option to use rmdfiltr's doi2bib filter. --- .gitignore | 2 ++ R/apa6_formats.R | 8 ++++++++ .../templates/apa6/resources/apa6_header_includes.tex | 3 ++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f94320bf..2507889a 100755 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,5 @@ inst/doc .vscode .luarc.json + +/.luarc.json diff --git a/R/apa6_formats.R b/R/apa6_formats.R index 1135cfcd..69051da8 100644 --- a/R/apa6_formats.R +++ b/R/apa6_formats.R @@ -159,6 +159,10 @@ apa6_pdf <- function( on.exit(close(output_file_connection)) writeLines(output_text, output_file_connection, useBytes = TRUE) + if(isTRUE(metadata$doi_citations)) { + rmdfiltr::replace_doi_citations(input_file, metadata$bibliography) + } + # Apply bookdown postprocesser and pass format options bookdown_post_processor <- bookdown::pdf_document2()$post_processor pp_env <- environment(bookdown_post_processor) @@ -377,6 +381,10 @@ pdf_pre_processor <- function(metadata, input_file, runtime, knit_meta, files_di ) csl_specified <- is.null(args) + if(isTRUE(metadata$doi_citations)) { + args <- rmdfiltr::add_doi2cite_filter(args) + } + ## Set ampersand filter if((is.null(metadata$replace_ampersands) || metadata$replace_ampersands)) { if(csl_specified) { diff --git a/inst/rmarkdown/templates/apa6/resources/apa6_header_includes.tex b/inst/rmarkdown/templates/apa6/resources/apa6_header_includes.tex index 25d99653..2857abf8 100755 --- a/inst/rmarkdown/templates/apa6/resources/apa6_header_includes.tex +++ b/inst/rmarkdown/templates/apa6/resources/apa6_header_includes.tex @@ -58,7 +58,8 @@ \makeatletter \xapptocmd\appendix {\xapptocmd\section - {\addcontentsline{toc}{section}{\appendixname\ifoneappendix\else~\theappendix\fi\\: #1}} + {\addcontentsline{toc}{section}{\appendixname\ifoneappendix\else~\theappendix\fi: #1}} {}{\InnerPatchFailed}% } {}{\PatchFailed} +\makeatother