Type: | Package |
Title: | 'Lua'-Filters for R Markdown |
Version: | 0.1.5 |
URL: | https://github.com/crsh/rmdfiltr |
BugReports: | https://github.com/crsh/rmdfiltr/issues |
Description: | A collection of 'Lua' filters that extend the functionality of R Markdown templates (e.g., count words or post-process citations). |
Imports: | assertthat (≥ 0.2.1), utils, rmarkdown (≥ 1.12) |
SystemRequirements: | pandoc (>= 2.0; https://pandoc.org) |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
Suggests: | dplyr (≥ 0.8.0.1), ggplot2 (≥ 3.0.0), knitr (≥ 1.22), spelling (≥ 2.1), testthat (≥ 2.0.0), tibble (≥ 2.1.1), stringr, bibtex (≥ 0.5.1) |
Language: | en-US |
VignetteBuilder: | knitr |
NeedsCompilation: | no |
Packaged: | 2024-10-22 15:00:16 UTC; frederikaust |
Author: | Frederik Aust |
Maintainer: | Frederik Aust <frederik.aust@uni-koeln.de> |
Repository: | CRAN |
Date/Publication: | 2024-10-22 22:00:02 UTC |
Add filter to pandoc arguments
Description
Adds a filter call to the vector of pandoc command line arguments.
Usage
add_lua_filter(args = NULL, filter_name, error = TRUE)
add_wordcount_filter(args = NULL, error = TRUE)
add_charcount_filter(args = NULL, error = TRUE)
add_replace_ampersands_filter(args = NULL, error = TRUE)
add_doi2cite_filter(args = NULL, error = TRUE)
add_citeproc_filter(args = NULL, error = TRUE)
add_custom_filter(args = NULL, filter_path, lua = FALSE, error = TRUE)
Arguments
args |
Character. (Vector of) pandoc command line arguments. |
filter_name |
Character. Name(s) of the Lua filter to add. See details. |
error |
Logical. Whether to throw an error if (required version of)
|
filter_path |
Character. Path to filter file. |
lua |
Logical. Whether the filter(s) was written in Lua (results in
|
Details
The following Lua filters are available from rmdfiltr.
Convenience functions named after the filter are available
(e.g. add_*_filter()
). For details, please also refer to the
vignettes.
replace_ampersands
Searches for citations added by
pandoc-citeproc
and replaces&
withand
in all in-text citations (e.g., as required by APA style). Iflang
is specified in the documents YAML front matter, the corresponding translation is used, if available. Be sure to setciteproc: no
in the YAML front matter of the document and callpandoc-citeproc
manually (e.g., usingadd_citeproc_filter
). For details seevignette("replace_ampersands", package = "rmdfiltr")
.wordcount
The body of the text and reference sections are counted separately. The word count for the text body does not contain, tables or images (or their captions). The filter reports the word count in the console or the R Markdown tab in 'RStudio'. For details see
vignette("wordcount", package = "rmdfiltr")
.charcount
Only the body of the text is counted. The character count for the text body does not contain, tables or images (or their captions), but includes spaces. The filter reports the character count in the console or the R Markdown tab in 'RStudio'.
doi2cite
Searches for DOI-citation tags in the text, retrieves the bibliographic information from CrossRef, stores it in a BibTeX file, and replaces the DOI-citation tags with the corresponding BibTeX keys. For details see
vignette("doi2cite", package = "rmdfiltr")
.
Examples
add_lua_filter(NULL, "wordcount", error = FALSE)
add_wordcount_filter(NULL, error = FALSE)
add_charcount_filter(NULL, error = FALSE)
add_replace_ampersands_filter(NULL, error = FALSE)
add_doi2cite_filter(NULL, error = FALSE)
add_citeproc_filter(NULL, error = FALSE)
add_custom_filter(NULL, filter_path = "foo/bar", error = FALSE)
Replace DOI citations in R Markdown document
Description
This function reads an R Markdown document and replaces all DOI citations with the corresponding entries from a BibTeX file. Requires the package 'bibtex' to be installed.
Usage
post_process_doi_citations(input_file, bib)
replace_resolved_doi_citations()
Arguments
input_file |
Character. Path to the input file provided to the post-processor. |
bib |
Character. A (vector of) path(s) to the BibTeX file(s). |
Value
Returns 'TRUE' invisibly.