read_manuscript: Read 'Rmarkdown' Manuscript

View source: R/read_manuscript.R

read_manuscriptR Documentation

Read 'Rmarkdown' Manuscript

Description

Reads an 'Rmarkdown' manuscript and, if possible, an associated PDF.

Usage

read_manuscript(
  path,
  PDF = FALSE,
  to_envir = getOption("revise_use_envir", TRUE),
  envir = parent.frame(1)
)

Arguments

path

Character, path to the 'Rmarkdown' file.

PDF

Logical or character. Default FALSE does nothing. If set to TRUE, attempts to determine PDF file path from YAML front matter. If character, should be the path to the PDF rendered from the 'Rmarkdown' file. This PDF will be loaded for page matching.

to_envir

Logical, indicating whether or not the manuscript should be invisibly assigned to an environment variable names .revise_manuscript. Defaults to TRUE. Can be disabled by setting options(revise_use_envir = FALSE).

envir

The environment to which the manuscript should be assigned.

Details

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).

Value

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

See Also

yaml_front_matter fileutils

Examples

tempfile <- tempfile("tmp", fileext = ".txt")
writeLines("[Maecenas mollis consectetur purus.]{#test}", con = tempfile)
read_manuscript(tempfile)

revise documentation built on April 3, 2025, 11:47 p.m.