larsgw / citation.js

Citation.js converts formats like BibTeX, Wikidata JSON and ContentMine JSON to CSL-JSON to convert to other formats like APA, Vancouver and back to BibTeX.
https://citation.js.org/
MIT License
222 stars 30 forks source link

Can citation.js validate a bibtex file? #162

Closed RichardEb closed 3 years ago

RichardEb commented 5 years ago

Can citation.js validate a bibtex file?

E.g. check if all required fields are available?

larsgw commented 5 years ago

Not yet, but that sounds like a good idea. Would this list (source) suffice?:

article
An article from a journal or magazine. Required fields: author, title, journal, year. Optional fields: volume, number, pages, month, note.
book
A book with an explicit publisher. Required fields: author or editor, title, publisher, year. Optional fields: volume or number, series, address, edition, month, note.
booklet
A work that is printed and bound, but without a named publisher or sponsoring institution. Required field: title. Optional fields: author, howpublished, address, month, year, note.
conference
The same as INPROCEEDINGS, included for Scribe compatibility.
inbook
A part of a book, which may be a chapter (or section or whatever) and/or a range of pages. Required fields: author or editor, title, chapter and/or pages, publisher, year. Optional fields: volume or number, series, type, address, edition, month, note.
incollection
A part of a book having its own title. Required fields: author, title, booktitle, publisher, year. Optional fields: editor, volume or number, series, type, chapter, pages, address, edition, month, note.
inproceedings
An article in a conference proceedings. Required fields: author, title, booktitle, year. Optional fields: editor, volume or number, series, pages, address, month, organization, publisher, note.
manual
Technical documentation. Required field: title. Optional fields: author, organization, address, edition, month, year, note.
mastersthesis
A Master's thesis. Required fields: author, title, school, year. Optional fields: type, address, month, note.
misc
Use this type when nothing else fits. Required fields: none. Optional fields: author, title, howpublished, month, year, note.
phdthesis
A PhD thesis. Required fields: author, title, school, year. Optional fields: type, address, month, note.
proceedings
The proceedings of a conference. Required fields: title, year. Optional fields: editor, volume or number, series, address, month, organization, publisher, note.
techreport
A report published by a school or other institution, usually numbered within a series. Required fields: author, title, institution, year. Optional fields: type, number, address, month, note.
unpublished

A document having an author and title, but not formally published. Required fields: author, title, note. Optional fields: month, year.


Easiest for me would be an API like this:

Cite.plugins.config.get('@bibtex').strict = true
try {
  let data = Cite.input(bibtex)
  // valid
} catch (e) {
  // invalid
}

Do you have other ideas you'd like to share?

I'm currently a bit preoccupied with other things, so it might take a while until I have a patch, and more importantly a release. I'm probably able to work on things at the earliest in 2 weeks.

RichardEb commented 5 years ago

Everything sounds good to me. Thx

retorquere commented 4 years ago

For biblatex validation, a lot can be done from the bcf file; I have an automated checker generated from a bcf in https://gist.github.com/retorquere/c0aab4121960c8aef7df793cf28c31f9