| Title: | Dynamic Revision Letters for 'Rmarkdown' Manuscripts |
|---|---|
| Description: | Extracts tagged text from markdown manuscripts for inclusion in dynamically generated revision letters. Provides an R markdown template based on papaja::revision_letter_pdf() with comment cross-referencing, a system for managing multiple sections of extracted text, and a way to automatically determine the page number of quoted sections from PDF manuscripts. |
| Authors: | James Conigrave [aut, cre] (ORCID: <https://orcid.org/0000-0002-8816-6229>), Philip Parker [aut] (ORCID: <https://orcid.org/0000-0002-4604-8566>), Taren Sanders [aut] (ORCID: <https://orcid.org/0000-0002-4504-6008>), Michael Noetel [aut] (ORCID: <https://orcid.org/0000-0002-6563-8203>), Caspar J. Van Lissa [aut] (ORCID: <https://orcid.org/0000-0002-0808-5024>) |
| Maintainer: | James Conigrave <[email protected]> |
| License: | MIT + file LICENCE |
| Version: | 0.1.0 |
| Built: | 2026-05-22 07:20:45 UTC |
| Source: | https://github.com/conig/revise |
A comment to style chunks for reviewer comments
anchor_tag()anchor_tag()
Extract comments from a google docs document
drive_comments(url, email = NULL, cache_credentials = NULL)drive_comments(url, email = NULL, cache_credentials = NULL)
url |
URL to drive document |
email |
drive email account. Can be set with options(gargle_oath_email) |
cache_credentials |
bool. Should cached credentials be used? Can be set with options(gargle_oauth_cache) |
A list with a length equal to the number of comments. Each element corresponds to one comment: the element's name is the comment text, and its value is the text that was bounded by the comment.
Extract table and figure references
extract_refs(path)extract_refs(path)
path |
to markdown manuscript |
Extract sections from text string
extract_sections(string, is_span = FALSE)extract_sections(string, is_span = FALSE)
string |
string to extract md sections from |
is_span |
logical, whether to extract sections in square brackets (default) or spans |
Retrieves and formats a specified section from a revise_manuscript object based on its ID.
get_revision( id, manuscript = NULL, quote = TRUE, evaluate = TRUE, split_string = FALSE, search_length = 300, include_pgnum = TRUE, revise_errors = getOption("revise_errors"), envir = parent.frame(1L) )get_revision( id, manuscript = NULL, quote = TRUE, evaluate = TRUE, split_string = FALSE, search_length = 300, include_pgnum = TRUE, revise_errors = getOption("revise_errors"), envir = parent.frame(1L) )
id |
the id as a character string from a html or markdown tag |
manuscript |
Optional; a revise_manuscript object in which to search
for |
quote |
should the output string be quoted by inserting '>' before the string? |
evaluate |
logical. Should inline rchunks be executed? |
split_string |
should only the start and end of the string be searched for? |
search_length |
numeric. Searches for the first n and n characters in a string. Shorten if difficult to find passages split by floats. |
include_pgnum |
logical. include PDF page number? Requires a PDF to be provided to the manuscript object. |
revise_errors |
logical. If FALSE, failure to match manuscript sections will result in warnings rather than errors. |
envir |
The environment in which to find the manuscript. |
A character vector of length 1 containing the text extracted from the manuscript that was tagged with id, including any modifications as specified by the arguments.
Returns a character vector with the names of manuscripts loaded in a given environment.
list_manuscripts(envir = parent.frame(1))list_manuscripts(envir = parent.frame(1))
envir |
The environment in which to check for manuscripts. |
A character vector, or NULL if no manuscripts
exist in the environment.
temp_file <- tempfile(fileext = ".Rmd") write("`r 1 + 1", file = temp_file) read_manuscript(temp_file) list_manuscripts()temp_file <- tempfile(fileext = ".Rmd") write("`r 1 + 1", file = temp_file) read_manuscript(temp_file) list_manuscripts()
The YAML front matter tag mask determines whether
the text is displayed or replaced by mask_message.
The YAML tag can take the values yes or no.
mask( x, mask_message = "masked for blind review", hide = rmarkdown::metadata$mask )mask( x, mask_message = "masked for blind review", hide = rmarkdown::metadata$mask )
x |
Atomic character vector to be masked. |
mask_message |
Atomic character vector to mask |
hide |
Logical, Default: rmarkdown::metadata$mask |
Character vector.
mask("this is masked", hide = TRUE)mask("this is masked", hide = TRUE)
Read a docx file and extract comments
read_docx(path)read_docx(path)
path |
path to docx |
Reads an 'Rmarkdown' manuscript and, if possible, an associated PDF.
read_manuscript( path, PDF = FALSE, to_envir = getOption("revise_use_envir", TRUE), envir = parent.frame(1) )read_manuscript( path, PDF = FALSE, to_envir = getOption("revise_use_envir", TRUE), envir = parent.frame(1) )
path |
Character, path to the 'Rmarkdown' file. |
PDF |
Logical or character. Default |
to_envir |
Logical, indicating whether or not the manuscript should
be invisibly assigned to an environment variable names |
envir |
The environment to which the manuscript should be assigned. |
If to_envir is TRUE, the manuscript is invisibly assigned to the specified environment for later use by other revise functions. For example, this allows get_revision to work without specifying a manuscript. This behaviour can be disabled by setting options(revise_use_envir = FALSE).
Invisibly returns a list of class manuscript, containing
the following elements:
$sections: Extracted revisions
$PDF: Optionally, the PDF document
$refs: References to figures and tables
$rmd: The raw rmarkdown
$mtime: When the rmarkdown file was last modified
$checksum: A checksum of the rmarkdown file
$filename: The filename of the rmarkdown file
tempfile <- tempfile("tmp", fileext = ".txt") writeLines("[Maecenas mollis consectetur purus.]{#test}", con = tempfile) read_manuscript(tempfile)tempfile <- tempfile("tmp", fileext = ".txt") writeLines("[Maecenas mollis consectetur purus.]{#test}", con = tempfile) read_manuscript(tempfile)
Read in a markdown document for further analysis
read_md(path)read_md(path)
path |
to markdown manuscript |
Removes a revise_manuscript from a given environment by name.
remove_manuscript(manuscript = NULL, envir = parent.frame(1))remove_manuscript(manuscript = NULL, envir = parent.frame(1))
manuscript |
A character vector of revise_manuscript names
that exist in |
envir |
The environment from which to remove the manuscript. |
Invisibly returns TRUE if successful, and FALSE
otherwise.
temp_file <- tempfile(fileext = ".Rmd") write("`r 1 + 1", file = temp_file) read_manuscript(temp_file) result <- remove_manuscript(list_manuscripts()[1]) # See that remove_manuscript() silently returns TRUE print(result) # See that there are no more manuscripts in envir list_manuscripts()temp_file <- tempfile(fileext = ".Rmd") write("`r 1 + 1", file = temp_file) read_manuscript(temp_file) result <- remove_manuscript(list_manuscripts()[1]) # See that remove_manuscript() silently returns TRUE print(result) # See that there are no more manuscripts in envir list_manuscripts()
A comment to style chunks for reviewer comments
reviewer_comment()reviewer_comment()
Template for creating journal revision letters with dynamic excerpts from a manuscript.
revise_letter_docx(...)revise_letter_docx(...)
... |
Arguments passed on to |
This function wraps bookdown::word_document2().
An R Markdown output format object to be passed to
rmarkdown::render().
Template for creating journal revision letters with dynamic excerpts from a manuscript.
revise_letter_pdf(...)revise_letter_pdf(...)
... |
Arguments passed on to |
This function wraps papaja::revision_letter_pdf().
R Markdown output format to pass to rmarkdown::render().
papaja::revision_letter_pdf(), bookdown::pdf_document2(), rmarkdown::pdf_document()
Template for creating journal revision letters with dynamic excerpts from a manuscript.
revise_letter_txt(...)revise_letter_txt(...)
... |
Arguments passed on to |
This function wraps rmarkdown::output_format().
An R Markdown output format definition that can be passed to
render.