read_glossary: Read and parse a glossary file

View source: R/glossary.R

read_glossaryR Documentation

Read and parse a glossary file

Description

Files may be formatted as TeX glossary file or in yaml format suitable for reading using yaml_as_df() (see details).

Usage

read_glossary(file, format = guess_glo_fmt(file))

Arguments

file

path to the tex or yaml glossary file.

format

the glossary file format; could be either "tex" or "yaml" and will be inferred by default from the extension of file.

Details

For the tex format, the glossary file is expected to contain acronym entries with the form

\newacronym{label}{abbreviation}{definition}

or

\newacronym[options]{label}{abbreviation}{definition}

For the yaml format, the glossary file is expected to be able to be read with yaml_as_df(); the outer level should be the label and columns should be provided with the names def (definition) and abb (abbreviation). See Examples.

Value

A named list of glossary definitions with class tex_glossary and glossary. The list names are acronym entry labels (i.e., what you would pass to ⁠\gls{}⁠ when writing a tex document).

See Also

as_glossary()

Examples

texfile <- system.file("glo", "glossary.tex", package = "pmtables")

x <- read_glossary(texfile)

head(x)

x$WT

x$SC

yamfile <- system.file("glo", "glossary.yaml", package = "pmtables")

y <- read_glossary(yamfile)
head(y)

# Format of the tex glossary file
head(readLines(texfile))

# Format of the yaml glossary file
head(readLines(yamfile))

yaml_as_df(yamfile)



metrumresearchgroup/pmtables documentation built on Oct. 27, 2024, 5:16 p.m.