cffjs
v0.1.0
Published
Types and utilities for working with CITATION.cff files in Typescript
Downloads
2,293
Readme
cffjs
Types and utilities for working with CITATION.cff files in TypeScript.
The Citation File Format provides citation metadata for software and datasets in YAML.
Install
npm install cffjsUsage
import { readCFF, writeCFF, validateCFF } from 'cffjs';
const cff = readCFF('./CITATION.cff');
validateCFF(cff);
writeCFF(cff, './output');API
Reading & Writing
readCFF(file)- Read CFF data from aCITATION.cfffile (or directory containing one). Returns the parsed object without validation.writeCFF(cff, directory)- Write CFF data asCITATION.cffinto the given directory, creating it if needed.
Validating
validateCFF(input)- Validate an in-memory CFF object against the CFF 1.2.0 JSON schema. Throws on failure.validateCFFFile(file)- Read a CFF file and validate it. Throws on failure.
MyST Conversion
Convert MyST frontmatter into CFF data:
mystFrontmatterToCFF(frontmatter, abstract?)- Convert MySTPageFrontmatterinto a complete CFF document.mystFrontmatterToCFFReference(frontmatter, abstract?)- Convert MySTPageFrontmatterinto a CFFReferenceentry.
Types
The package exports TypeScript types for CFF, ReferenceCFF, PersonCFF, EntityCFF, and IdentifierCFF, along with the ReferenceType and ReferenceStatus enums.
Scope
- Reading, writing, and validating
CITATION.cfffiles - Conversion from MyST frontmatter to CFF
- CFF version 1.2.0 only
Potential goals
- Conversion to MyST frontmatter
- Support for other CFF versions
- Conversion to/from other formats (e.g. BibTeX)
- CLI
