ropensci / handlr

convert among citation formats
https://docs.ropensci.org/handlr
Other
38 stars 4 forks source link

Citation File Format (CFF) v1.2.0 support #25

Closed dieghernan closed 2 years ago

dieghernan commented 2 years ago

This PR adds support for the latest version of CFF (v1.2.0). It is also compatible with v1.1.0.

Description

Related Issue

Closes #24

Example

library(handlr)

# Minimal cff with v1.2.0 required keys only
file <- system.file("extdata/citation_1.2.0.cff", package = "handlr")
new <- cff_reader(file)
cat(cff_writer(new))
#> cff-version: 1.2.0
#> message: If you use this software, please cite it as below.
#> title: My Research Software
#> authors:
#> - family-names: Druskat
#>   given-names: Stephan
#>   orcid: https://orcid.org/0000-0003-4925-7248
#> doi: 10.5281/zenodo.1234
#> keywords:
#> - McAuthor's algorithm
#> - linguistics
#> - nlp
#> - parser
#> references:
#> - type: book
#>   authors:
#>   - family-names: Doe
#>     given-names: Jane
#>   - name: Foo Bar Working Group
#>     website: https://foo-bar.com
#>   title: The science of citation
#> - type: software
#>   authors:
#>   - family-names: Doe
#>     given-names: John
#>   title: Software Citation Tool
cat(bibtex_writer(new), sep = "\n")
#> @misc{10.5281/zenodo.1234,
#>   doi = {10.5281/zenodo.1234},
#>   author = {Stephan Druskat},
#>   title = {My Research Software},
#>   pages = {},
#> }
# When switched to cff_v1 it would still fail

zy <- yaml::yaml.load_file(file)
zy$`cff-version` <- "1.1.0"
tf <- tempfile(fileext = ".yml")
yaml::write_yaml(zy, tf)
cff_reader(tf)
#> Error: 'date-released' is required

Created on 2021-09-20 by the reprex package (v2.0.1)

bwiernik commented 2 years ago

Thanks!