Skip to contents

Usage

write_bib(x, file = tempfile(), append = FALSE, verbose = TRUE, ascii = FALSE)

write_citation(
  x,
  file = "./inst/CITATION",
  append = FALSE,
  verbose = TRUE,
  ...
)

Arguments

x

A bibentry or a cff object.

file

Name of the file to be created. If NULL, the lines are displayed instead.

append

Logical. Whether to append entries to an existing file.

verbose

Logical. Display informative messages.

ascii

Logical. Whether to write entries using ASCII characters only.

Value

Writes a file.

See also

Deprecated functions: cff_extract_to_bibtex(), cff_from_bibtex(), cff_parse_citation(), cff_parse_person()

Examples

bib <- bibentry("Misc",
  title = "My title",
  author = "Fran Pérez"
)

my_temp_bib <- tempfile(fileext = ".bib")

cff_write_bib(bib, file = my_temp_bib)
#>  Writing 4 entries.
#>  Results written to /tmp/Rtmp7uejjj/file6069e58f1.bib.

cat(readLines(my_temp_bib), sep = "\n")
#> @Misc{,
#>   title = {My title},
#>   author = {Fran Pérez},
#> }

cff_write_bib(bib, file = my_temp_bib, ascii = TRUE, append = TRUE)
#>  Creating a backup of /tmp/Rtmp7uejjj/file6069e58f1.bib in /tmp/Rtmp7uejjj/file6069e58f1.bib.bk1.
#>  Writing 4 entries.
#>  Results written to /tmp/Rtmp7uejjj/file6069e58f1.bib.

cat(readLines(my_temp_bib), sep = "\n")
#> @Misc{,
#>   title = {My title},
#>   author = {Fran Pérez},
#> }
#> @Misc{,
#>   title = {My title},
#>   author = {Fran P{\'e}rez},
#> }