Skip to contents

[Experimental]

Usage

parse_ref(
  input = NULL,
  path = NULL,
  output_format = c("bib", "json", "xml", "ref"),
  overwrite = FALSE
)

Arguments

input

Vector of file paths to the text documents containing bibliographic references, or a single string of reference(s). If input is not a file, it is written to a temporary file for parsing.

path

The path where the parsed file(s) will be saved. If NULL, files are saved in the current working directory. If empty, the parsed data is returned directly and not saved.

output_format

Desired output format, one of "bib", "json", "xml" or "ref". "ref" is a text file with one reference per line. Default is "json".

overwrite

Logical; if TRUE, existing files at the output location will be overwritten. Default is FALSE.

Value

If path is empty, returns a list (or a single element if only one input) containing the parsed references in the specified format. If path is specified, parsed files are saved at the location and the function returns NULL.

Details

This function utilizes the anystyle Ruby gem to parse bibliographic references. It segments references (one per line) and converts them into structured formats. The input can be

  • the paths of one or several text documents containing one full reference per line.

  • a character vector with each element of the vector containing one full reference.

Examples

if (FALSE) {
# Parse a single reference and return as JSON
parse_ref(
  input = "Doe, J. Title of the Article. Journal Name 2020, 13, 123-456.",
  output_format = "json"
)

# Parse references from a file and save as BibTeX
parse_ref(
  input = "path/to/references.txt", path = "path/to/output",
  output_format = "bib"
)
}