@citedrive/codemirror-lang-bibtex
Version:
BibTeX language support for CodeMirror
1,725 lines (1,718 loc) • 66 kB
JavaScript
'use strict';
var lr = require('@lezer/lr');
var highlight = require('@lezer/highlight');
var language = require('@codemirror/language');
var autocomplete = require('@codemirror/autocomplete');
var lint = require('@codemirror/lint');
var bibtexTidy = require('bibtex-tidy');
// This file was generated by lezer-generator. You probably shouldn't edit it.
const parser = lr.LRParser.deserialize({
version: 14,
states: "$bQYQPOOO_QPO'#C`OdQPO'#C_OOQO'#Ch'#ChQYQPOOOlQQO,58zOqQPO'#CdOvQPO'#CcO!OQPO'#CcO!WQPO,58yOOQO-E6f-E6fO!]QPO1G.fO!bQPO,59OOOQO,59T,59TO!gQPO,58}OOQO-E6g-E6gOOQO1G.e1G.eOOQO7+$Q7+$QO!oQSO'#CfOOQO1G.j1G.jP!zQPO'#CiOOQO'#Cj'#CjO#PQSO,59QOOQO,59Q,59QOOQO-E6h-E6hOOQO1G.l1G.l",
stateData: "#a~OaOSPOS~OTPO~OdTO~OXUObVP~OUZO~Oe[O~Oc]ObVX~OXUObVX~Ob`O~OcaO~OdbO~Oc]ObVa~OZeObgOdbO~Oc]O~OZeObiOdbO~OPaZa~",
goto: "![_PPP`dPPhkPqPx!O!UTROSTQOSRXQQVQR^WQc[TebfQSORYSQWQR_WQfbRhf",
nodeNames: "⚠ Comment Bib Entry EntryHeading EntryType EntryKey EntryValue Field FieldType FieldValue FieldContent",
maxTerm: 21,
skippedNodes: [0,1],
repeatNodeCount: 3,
tokenData: "*t~RuOX#fX^$Q^p#fpq$Qqu#fuv%vv|#f|}'X}!_#f!_!`'o!`!b#f!b!c(V!c!})e!}#T#f#T#o)e#o#p*j#p#q#f#q#r*o#r#y#f#y#z$Q#z$f#f$f$g$Q$g#BY#f#BY#BZ$Q#BZ$IS#f$IS$I_$Q$I_$I|#f$I|$JO$Q$JO$JT#f$JT$JU$Q$JU$KV#f$KV$KW$Q$KW&FU#f&FU&FV$Q&FV;'S#f;'S;=`#z<%lO#fS#kTZSO#o#f#p#q#f#r;'S#f;'S;=`#z<%lO#fS#}P;=`<%l#f~$Xia~ZSOX#fX^$Q^p#fpq$Qq#o#f#p#q#f#r#y#f#y#z$Q#z$f#f$f$g$Q$g#BY#f#BY#BZ$Q#BZ$IS#f$IS$I_$Q$I_$I|#f$I|$JO$Q$JO$JT#f$JT$JU$Q$JU$KV#f$KV$KW$Q$KW&FU#f&FU&FV$Q&FV;'S#f;'S;=`#z<%lO#f~%}XP~ZSOY%vYZ#fZ#o%v#o#p&j#p#q%v#q#r&j#r;'S%v;'S;=`'R<%lO%v~&oSP~OY&jZ;'S&j;'S;=`&{<%lO&j~'OP;=`<%l&j~'UP;=`<%l%vT'`TcPZSO#o#f#p#q#f#r;'S#f;'S;=`#z<%lO#fT'vTePZSO#o#f#p#q#f#r;'S#f;'S;=`#z<%lO#fT([WZSO!c#f!c!}(t!}#T#f#T#o(t#p#q#f#r;'S#f;'S;=`#z<%lO#fT({WTPZSO!c#f!c!}(t!}#T#f#T#o(t#p#q#f#r;'S#f;'S;=`#z<%lO#fV)n^UQXPZSO}#f}!O)e!O!Q#f!Q![)e![!c#f!c!})e!}#R#f#R#S)e#S#T#f#T#o)e#p#q#f#r;'S#f;'S;=`#z<%lO#f~*oOd~~*tOb~",
tokenizers: [0, 1, 2],
topRules: {"Bib":[0,2]},
tokenPrec: 104
});
/**
BibTeX autocompletion [configuration](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config).
*/
const bibtexCompletion = autocomplete.autocompletion({
activateOnTyping: true,
activateOnTypingDelay: 100,
tooltipClass: () => "editor-tooltip",
optionClass: () => "editor-option",
});
/**
BibTeX [syntax linter](https://codemirror.net/6/docs/ref/#lint.Diagnostic).
*/
const bibtexLinter = lint.linter((view) => {
let diagnostics = [];
let currentDocText = view.state.doc.toString();
try {
let tidyOutput = bibtexTidy.tidy(currentDocText, { modify: false });
}
catch (err) {
view.domAtPos(err.pos);
diagnostics.push({
from: err.pos,
to: view.state.toText(currentDocText).lineAt(err.pos).to,
severity: "error",
message: "Invalid BibTeX Syntax",
});
}
return diagnostics;
});
// struct with ranked section objects
const sections = {
Entry: { name: "Entry", rank: 0 },
Field: { name: "Field", rank: 0 },
Keyword: { name: "Keyword", rank: 0 },
Recommended: { name: "Recommended", rank: 1 },
Optional: { name: "Optional", rank: 2 },
Alias: { name: "Alias", rank: 3 },
Special: { name: "Special", rank: 4 },
};
// funcs for dynamic snippet creation
const createEntry = (label, section, detail, fields, snipRecs) => {
let applySnip = snipRecs
? autocomplete.snippet(`@${label}{#{<citationkey>},\n\t% Recommended Fields:${fields.recommended.map((f) => `\n\t${f} = {#{<${f}>}}`)},\n\n\t% Optional Fields:${fields.optional.map((f) => `\n\t${f} = {#{<${f}>}}`)}\n}`)
: autocomplete.snippet(`@${label}{#{<citationkey>},${fields.required.map((f) => `\n\t${f} = {#{<${f}>}}`)}\n}`);
return {
// matching options
label: `@${label}`,
detail: detail,
//expansion
apply: applySnip,
// render options
section: section,
type: "class",
};
};
const createField = (label, section, detail) => {
return {
// matching options
label: label,
detail: detail,
// expansion
apply: autocomplete.snippet(`${label} = {#{<${label}>}}#{,}\n#{}`),
// render options
section: section,
type: "property",
};
};
const createKeyword = (label) => {
return {
// matching options
label: label,
detail: "Custom Keyword",
// expansion
apply: autocomplete.snippet(`${label}`),
// render options
section: sections.Keyword,
type: "property",
};
};
// ENTRIES
const bibtexEntries = [
{
name: "article",
type: sections.Entry,
description: "An article from a journal or magazine.",
fields: {
recommended: [
"author",
"title",
"year",
"month",
"journal",
"publisher",
"doi",
"url",
],
optional: ["volume", "number", "pages", "issn"],
required: ["author", "title", "journal", "year"],
},
},
{
name: "book",
type: sections.Entry,
description: "A book with a publisher.",
fields: {
recommended: [
"author",
"title",
"year",
"month",
"publisher",
"address",
"isbn",
],
optional: ["volume", "number", "pages", "series", "edition"],
required: ["author", "editor", "title", "publisher", "year"],
},
},
{
name: "booklet",
type: sections.Entry,
description: "A work that is printed and bound, but without a named publisher or sponsoring institution.",
fields: {
recommended: ["author", "title", "year", "month", "isbn"],
optional: ["volume", "number", "pages", "series", "edition"],
required: ["title"],
},
},
{
name: "conference",
type: sections.Entry,
description: "An article in a conference proceedings.",
fields: {
recommended: [
"author",
"title",
"year",
"month",
"organization",
"address",
"doi",
],
optional: ["volume", "number", "pages", "issn"],
required: ["author", "title", "booktitle", "year"],
},
},
{
name: "inbook",
type: sections.Entry,
description: "A part of a book, which may be a chapter (or type: section or whatever) and/or a range of pages.",
fields: {
recommended: [
"author",
"title",
"year",
"month",
"publisher",
"address",
"isbn",
],
optional: ["volume", "number", "pages", "series", "edition"],
required: [
"author/editor",
"title",
"chapter/pages",
"publisher",
"year",
],
},
},
{
name: "incollection",
type: sections.Entry,
description: "A part of a book having its own title.",
fields: {
recommended: [
"author",
"title",
"booktitle",
"year",
"month",
"publisher",
"address",
"isbn",
],
optional: ["volume", "number", "pages", "series", "edition"],
required: ["author", "title", "booktitle", "publisher", "year"],
},
},
{
name: "inproceedings",
type: sections.Entry,
description: "An article in a conference proceedings.",
fields: {
recommended: [
"author",
"title",
"year",
"month",
"organization",
"address",
"doi",
],
optional: ["volume", "number", "pages", "issn"],
required: ["author", "title", "booktitle", "year"],
},
},
{
name: "manual",
type: sections.Entry,
description: "Technical documentation.",
fields: {
recommended: ["title", "year", "month", "institution", "doi"],
optional: ["edition", "pages", "issn"],
required: ["title"],
},
},
{
name: "mastersthesis",
type: sections.Entry,
description: "A Master’s thesis.",
fields: {
recommended: ["title", "year", "month", "institution", "doi"],
optional: ["pages", "issn"],
required: ["author", "title", "school", "year"],
},
},
{
name: "misc",
type: sections.Entry,
description: "Use this type when nothing else fits.",
fields: {
recommended: ["title", "year", "month"],
optional: ["url"],
required: [],
},
},
{
name: "phdthesis",
type: sections.Entry,
description: "A PhD thesis.",
fields: {
recommended: ["title", "year", "month", "institution", "doi"],
optional: ["pages", "issn"],
required: ["author", "title", "school", "year"],
},
},
{
name: "proceedings",
type: sections.Entry,
description: "The proceedings of a conference.",
fields: {
recommended: ["year", "month", "organization", "address", "doi"],
optional: ["volume", "number", "issn"],
required: ["title", "year"],
},
},
{
name: "techreport",
type: sections.Entry,
description: "A report published by a school or other institution.",
fields: {
recommended: ["title", "year", "month", "institution", "doi"],
optional: ["pages", "issn"],
required: ["author", "title", "institution", "year"],
},
},
{
name: "unpublished",
type: sections.Entry,
description: "A document having an author and title, but not formally published.",
fields: {
recommended: ["author", "title", "year", "month"],
optional: ["note"],
required: ["author", "title", "note"],
},
},
];
// FIELDS
const bibtexFields = [
{
name: "address",
type: sections.Field,
description: "The address of the publisher or other type of institution.",
},
{ name: "annote", type: sections.Field, description: "An annotation." },
{
name: "author",
type: sections.Field,
description: "The name(s) of the author(s).",
},
{
name: "booktitle",
type: sections.Field,
description: "The title of the book.",
},
{
name: "chapter",
type: sections.Field,
description: "The chapter (or section or whatever) number.",
},
{
name: "crossref",
type: sections.Field,
description: "The database key of the entry being cross referenced.",
},
{
name: "doi",
type: sections.Field,
description: "The Digital Object Identifier of the work.",
},
{
name: "edition",
type: sections.Field,
description: "The edition of a book, as an ordinal.",
},
{
name: "editor",
type: sections.Field,
description: "The name(s) of the editor(s).",
},
{
name: "email",
type: sections.Field,
description: "The email address(es) of the author(s).",
},
{
name: "howpublished",
type: sections.Field,
description: "How something strange has been published.",
},
{
name: "institution",
type: sections.Field,
description: "The sponsoring institution of a technical report.",
},
{
name: "isbn",
type: sections.Field,
description: "The International Standard Book Number of the work.",
},
{
name: "issn",
type: sections.Field,
description: "The International Standard Serial Number of a periodical.",
},
{ name: "journal", type: sections.Field, description: "The journal name." },
{
name: "key",
type: sections.Field,
description: "The citation key (for use in a `\\cite{}` command).",
},
{
name: "keywords",
type: sections.Field,
description: "Keywords that describe the work being cited.",
},
{
name: "month",
type: sections.Field,
description: "The month in which the work was published or written.",
},
{
name: "note",
type: sections.Field,
description: "Any additional information that can help the reader.",
},
{
name: "number",
type: sections.Field,
description: "The number of a journal, magazine, technical report, or of a work in a series.",
},
{
name: "organization",
type: sections.Field,
description: "The organization that sponsors a conference or that publishes a manual.",
},
{
name: "pages",
type: sections.Field,
description: "One or more page numbers or range of numbers.",
},
{
name: "publisher",
type: sections.Field,
description: "The publisher’s name.",
},
{
name: "school",
type: sections.Field,
description: "The name of the school where a thesis was written.",
},
{
name: "series",
type: sections.Field,
description: "The name of a series or set of books.",
},
{ name: "title", type: sections.Field, description: "The work’s title." },
{
name: "type",
type: sections.Field,
description: "The type of a technical report.",
},
{
name: "url",
type: sections.Field,
description: "The url of an online publication.",
},
{
name: "volume",
type: sections.Field,
description: "The volume of a journal or multivolume book.",
},
{
name: "year",
type: sections.Field,
description: "The year of publication or written.",
},
];
// ENTRIES
const biblatexEntries = [
// Recommended Entries
{
name: "article",
type: sections.Recommended,
description: "An article in a periodical.",
fields: {
recommended: ["author", "title", "journaltitle", "date"],
optional: [
"subtitle",
"volume",
"number",
"pages",
"eid",
"note",
"issn",
"doi",
"url",
"eprint",
],
required: ["author", "title", "journaltitle", "date"],
},
},
{
name: "book",
type: sections.Recommended,
description: "A single-volume book.",
fields: {
recommended: [
"author",
"editor",
"title",
"publisher",
"location",
"date",
],
optional: [
"subtitle",
"edition",
"series",
"volume",
"number",
"isbn",
"note",
"doi",
"url",
],
required: ["author", "title", "date"],
},
},
{
name: "booklet",
type: sections.Recommended,
description: "A book-like work without a formal publisher.",
fields: {
recommended: ["author", "title", "howpublished", "date"],
optional: ["subtitle", "address", "edition", "note", "url", "doi"],
required: ["author", "title", "date"],
},
},
{
name: "collection",
type: sections.Recommended,
description: "A single-volume collection.",
fields: {
recommended: ["editor", "title", "publisher", "location", "date"],
optional: [
"subtitle",
"edition",
"series",
"volume",
"number",
"note",
"doi",
"url",
],
required: ["editor", "title", "date"],
},
},
{
name: "dataset",
type: sections.Recommended,
description: "A data set or similar collection of raw data.",
fields: {
recommended: ["editor", "title", "date"],
optional: [
"subtitle",
"version",
"doi",
"url",
"note",
"archive",
"location",
],
required: ["editor", "title", "date"],
},
},
{
name: "manual",
type: sections.Recommended,
description: "Technical or other documentation.",
fields: {
recommended: ["author", "title", "date"],
optional: [
"subtitle",
"edition",
"organization",
"address",
"note",
"doi",
"url",
],
required: ["author", "title", "date"],
},
},
{
name: "online",
type: sections.Recommended,
description: "An online resource.",
fields: {
recommended: ["author", "title", "date", "url"],
optional: [
"subtitle",
"organization",
"urldate",
"note",
"doi",
"language",
],
required: ["author", "title", "date", "url"],
},
},
{
name: "patent",
type: sections.Recommended,
description: "A patent or patent request.",
fields: {
recommended: ["author", "title", "number", "date"],
optional: [
"subtitle",
"holder",
"location",
"day",
"note",
"doi",
"url",
],
required: ["author", "title", "number", "date"],
},
},
{
name: "periodical",
type: sections.Recommended,
description: "A complete issue of a periodical.",
fields: {
recommended: ["editor", "title", "publisher", "location", "date"],
optional: [
"subtitle",
"volume",
"number",
"series",
"note",
"issn",
"doi",
"url",
],
required: ["editor", "title", "date"],
},
},
{
name: "proceedings",
type: sections.Recommended,
description: "A single-volume conference proceedings.",
fields: {
recommended: ["title", "publisher", "location", "date"],
optional: [
"subtitle",
"editor",
"organization",
"series",
"volume",
"number",
"edition",
"note",
"doi",
"url",
],
required: ["title", "date"],
},
},
{
name: "reference",
type: sections.Recommended,
description: "A single-volume work of reference.",
fields: {
recommended: ["editor", "title", "publisher", "location", "date"],
optional: [
"subtitle",
"edition",
"series",
"volume",
"number",
"note",
"doi",
"url",
],
required: ["editor", "title", "date"],
},
},
{
name: "report",
type: sections.Recommended,
description: "A report of some kind published by an institution.",
fields: {
recommended: [
"author",
"title",
"type",
"institution",
"location",
"date",
],
optional: ["subtitle", "series", "number", "note", "doi", "url"],
required: ["author", "title", "type", "institution", "date"],
},
},
{
name: "software",
type: sections.Recommended,
description: "A piece of computer software.",
fields: {
recommended: ["author", "title", "version", "date"],
optional: [
"subtitle",
"publisher",
"location",
"doi",
"url",
"note",
],
required: ["author", "title", "date"],
},
},
{
name: "thesis",
type: sections.Recommended,
description: "A thesis written for an educational institution.",
fields: {
recommended: [
"author",
"title",
"type",
"institution",
"location",
"date",
],
optional: ["subtitle", "series", "address", "note", "doi", "url"],
required: ["author", "title", "type", "institution", "date"],
},
},
// Optional Entries
{
name: "artwork",
type: sections.Optional,
description: "A work of the visual arts.",
fields: {
recommended: ["author", "title", "date"],
optional: [
"subtitle",
"institution",
"location",
"url",
"note",
"doi",
],
required: ["author", "title", "date"],
},
},
{
name: "audio",
type: sections.Optional,
description: "An audio recording.",
fields: {
recommended: ["author", "title", "date"],
optional: [
"subtitle",
"medium",
"publisher",
"location",
"doi",
"url",
"note",
],
required: ["author", "title", "date"],
},
},
{
name: "bookinbook",
type: sections.Optional,
description: "An <@inbook> that was originally published as its own work.",
fields: {
recommended: [
"author",
"title",
"booktitle",
"publisher",
"location",
"date",
],
optional: [
"subtitle",
"series",
"volume",
"number",
"edition",
"note",
"url",
"doi",
],
required: ["author", "title", "booktitle", "date"],
},
},
{
name: "commentary",
type: sections.Optional,
description: "A legal or other commentary.",
fields: {
recommended: ["author", "title", "date"],
optional: [
"subtitle",
"journaltitle",
"volume",
"number",
"pages",
"note",
"doi",
"url",
],
required: ["author", "title", "date"],
},
},
{
name: "image",
type: sections.Optional,
description: "An image or similar media.",
fields: {
recommended: ["author", "title", "date"],
optional: ["subtitle", "medium", "location", "url", "doi", "note"],
required: ["author", "title", "date"],
},
},
{
name: "inbook",
type: sections.Optional,
description: "A part of a book which is its own titled work.",
fields: {
recommended: [
"author",
"title",
"booktitle",
"publisher",
"location",
"date",
],
optional: [
"subtitle",
"volume",
"part",
"pages",
"edition",
"series",
"doi",
"url",
"note",
],
required: ["author", "title", "booktitle", "date"],
},
},
{
name: "incollection",
type: sections.Optional,
description: "A contribution to a collection which is its own titled work.",
fields: {
recommended: [
"author",
"title",
"editor",
"booktitle",
"publisher",
"location",
"date",
],
optional: [
"subtitle",
"series",
"volume",
"number",
"edition",
"pages",
"note",
"doi",
"url",
],
required: ["author", "title", "editor", "booktitle", "date"],
},
},
{
name: "inproceedings",
type: sections.Optional,
description: "An article in a conference proceedings.",
fields: {
recommended: [
"author",
"title",
"booktitle",
"publisher",
"location",
"date",
],
optional: [
"subtitle",
"editor",
"pages",
"organization",
"series",
"volume",
"number",
"note",
"doi",
"url",
],
required: ["author", "title", "booktitle", "date"],
},
},
{
name: "inreference",
type: sections.Optional,
description: "An article in a work of reference.",
fields: {
recommended: [
"editor",
"title",
"booktitle",
"publisher",
"location",
"date",
],
optional: [
"subtitle",
"series",
"volume",
"number",
"edition",
"pages",
"note",
"doi",
"url",
],
required: ["editor", "title", "date"],
},
},
{
name: "jurisdiction",
type: sections.Optional,
description: "A court decision, recording, or similar.",
fields: {
recommended: ["author", "title", "date", "court"],
optional: ["volume", "reporter", "pages", "url", "note"],
required: ["author", "title", "date"],
},
},
{
name: "legal",
type: sections.Optional,
description: "A legal document such as a treaty.",
fields: {
recommended: ["organization", "title", "date"],
optional: [
"subtitle",
"type",
"location",
"number",
"url",
"doi",
"note",
],
required: ["organization", "title", "date"],
},
},
{
name: "legislation",
type: sections.Optional,
description: "A law, bill, proposal, or similar.",
fields: {
recommended: ["organization", "title", "date"],
optional: ["subtitle", "type", "number", "location", "url", "note"],
required: ["organization", "title", "date"],
},
},
{
name: "letter",
type: sections.Optional,
description: "Personal correspondence.",
fields: {
recommended: ["author", "title", "date"],
optional: ["recipient", "location", "venue", "url", "doi", "note"],
required: ["author", "title", "date"],
},
},
{
name: "misc",
type: sections.Special,
description: "A fallback for entries which do not fit in other categories.",
fields: {
recommended: ["author", "title", "date"],
optional: ["howpublished", "note", "url", "doi"],
required: ["author", "title", "date"],
},
},
{
name: "movie",
type: sections.Optional,
description: "A motion picture.",
fields: {
recommended: ["publisher", "title", "date"],
optional: [
"director",
"producer",
"location",
"medium",
"note",
"url",
"doi",
],
required: ["publisher", "title", "date"],
},
},
{
name: "music",
type: sections.Optional,
description: "A musical recording.",
fields: {
recommended: ["publisher", "title", "date"],
optional: [
"composer",
"performer",
"location",
"medium",
"note",
"url",
"doi",
],
required: ["publisher", "title", "date"],
},
},
{
name: "mvbook",
type: sections.Optional,
description: "A multi-volume book.",
fields: {
recommended: ["author", "title", "series", "volume", "date"],
optional: [
"publisher",
"location",
"edition",
"note",
"doi",
"url",
],
required: ["author", "title", "date"],
},
},
{
name: "mvcollection",
type: sections.Optional,
description: "A multi-volume collection.",
fields: {
recommended: ["editor", "title", "series", "volume", "date"],
optional: [
"publisher",
"location",
"edition",
"note",
"doi",
"url",
],
required: ["editor", "title", "date"],
},
},
{
name: "mvproceedings",
type: sections.Optional,
description: "A multi-volume conference proceedings.",
fields: {
recommended: ["title", "series", "volume", "date"],
optional: [
"editor",
"publisher",
"location",
"edition",
"organization",
"note",
"doi",
"url",
],
required: ["title", "date"],
},
},
{
name: "mvreference",
type: sections.Optional,
description: "A multi-volume work of reference.",
fields: {
recommended: ["editor", "title", "series", "volume", "date"],
optional: [
"publisher",
"location",
"edition",
"note",
"doi",
"url",
],
required: ["editor", "title", "date"],
},
},
{
name: "performance",
type: sections.Optional,
description: "A work of the performing arts.",
fields: {
recommended: ["organization", "title", "date"],
optional: [
"location",
"venue",
"duration",
"medium",
"note",
"url",
],
required: ["organization", "title", "date"],
},
},
{
name: "review",
type: sections.Optional,
description: "A review of some other work.",
fields: {
recommended: ["author", "title", "journaltitle", "date"],
optional: [
"subtitle",
"journal",
"volume",
"number",
"pages",
"doi",
"url",
"note",
],
required: ["author", "title", "journaltitle", "date"],
},
},
{
name: "standard",
type: sections.Optional,
description: "A National or Institutional standard issued by a standards body.",
fields: {
recommended: ["organization", "title", "date", "number"],
optional: ["series", "edition", "url", "doi", "note"],
required: ["organization", "title", "date"],
},
},
{
name: "suppbook",
type: sections.Optional,
description: "Supplemental material in a book.",
fields: {
recommended: [
"author",
"title",
"booktitle",
"publisher",
"location",
"date",
],
optional: [
"subtitle",
"series",
"volume",
"number",
"edition",
"note",
"doi",
"url",
],
required: ["author", "title", "booktitle", "date"],
},
},
{
name: "suppcollection",
type: sections.Optional,
description: "Supplemental material in a collection.",
fields: {
recommended: ["editor", "title", "publisher", "location", "date"],
optional: [
"subtitle",
"series",
"volume",
"number",
"edition",
"note",
"doi",
"url",
],
required: ["editor", "title", "date"],
},
},
{
name: "suppperiodical",
type: sections.Optional,
description: "Supplemental material in a periodical.",
fields: {
recommended: [
"editor",
"title",
"journaltitle",
"volume",
"number",
"date",
],
optional: ["subtitle", "series", "note", "doi", "url"],
required: ["editor", "title", "date"],
},
},
{
name: "unpublished",
type: sections.Optional,
description: "A work which has not been formally published.",
fields: {
recommended: ["author", "title", "date", "note"],
optional: ["subtitle", "location", "url", "doi"],
required: ["author", "title", "date"],
},
},
{
name: "video",
type: sections.Optional,
description: "An audiovisual recording.",
fields: {
recommended: ["author", "title", "date"],
optional: [
"director",
"producer",
"location",
"medium",
"duration",
"note",
"url",
"doi",
],
required: ["author", "title", "date"],
},
},
// Special Entries
{
name: "bibnote",
type: sections.Special,
description: "Used by the `notes2bib` package (and others) to place notes within the bibliography.",
fields: {
recommended: ["note"],
optional: [],
required: ["note"],
},
},
{
name: "custom",
type: sections.Special,
description: "Custom types for special bibliography styles.",
fields: {
recommended: [],
optional: [],
required: [],
},
},
{
name: "set",
type: sections.Special,
description: "An entry set.",
fields: {
recommended: ["entryset"],
optional: [],
required: ["entryset"],
},
},
{
name: "xdata",
type: sections.Special,
description: "Holds data which may be inherited by other entries using the <xdata> field.",
fields: {
recommended: [],
optional: [],
required: [],
},
},
// Entry Aliases (mostly for backwards compatibility with BibTeX)
{
name: "conference",
type: sections.Alias,
description: "An alias for <@inproceedings>.",
fields: {
recommended: [
"author",
"title",
"booktitle",
"publisher",
"location",
"date",
],
optional: [
"subtitle",
"editor",
"series",
"volume",
"number",
"edition",
"pages",
"month",
"note",
"doi",
"url",
],
required: ["author", "title", "booktitle", "date"],
},
},
{
name: "electronic",
type: sections.Alias,
description: "An alias for <@online>.",
fields: {
recommended: ["author", "title", "date", "url"],
optional: [
"subtitle",
"organization",
"urldate",
"note",
"doi",
"language",
],
required: ["author", "title", "date", "url"],
},
},
{
name: "mastersthesis",
type: sections.Alias,
description: "An alias for <@thesis>.",
fields: {
recommended: [
"author",
"title",
"type",
"institution",
"location",
"date",
],
optional: [
"subtitle",
"series",
"address",
"month",
"note",
"doi",
"url",
],
required: ["author", "title", "institution", "date"],
},
},
{
name: "phdthesis",
type: sections.Alias,
description: "An alias for <@thesis>.",
fields: {
recommended: [
"author",
"title",
"type",
"institution",
"location",
"date",
],
optional: [
"subtitle",
"series",
"address",
"month",
"note",
"doi",
"url",
],
required: ["author", "title", "institution", "date"],
},
},
{
name: "techreport",
type: sections.Alias,
description: "An alias for <@report>.",
fields: {
recommended: [
"author",
"title",
"type",
"institution",
"location",
"date",
],
optional: [
"subtitle",
"series",
"number",
"month",
"note",
"doi",
"url",
],
required: ["author", "title", "institution", "date"],
},
},
{
name: "www",
type: sections.Alias,
description: "An alias for <@online>.",
fields: {
recommended: ["author", "title", "date", "url"],
optional: [
"subtitle",
"organization",
"urldate",
"note",
"doi",
"language",
],
required: ["author", "title", "date", "url"],
},
},
];
// FIELDS
const biblatexFields = [
// Recommended Fields
{
name: "author",
type: sections.Recommended,
description: "The author(s) of <title>.",
},
{
name: "title",
type: sections.Recommended,
description: "The title of the work.",
},
{
name: "publisher",
type: sections.Recommended,
description: "The name(s) of the publisher(s).",
},
{
name: "date",
type: sections.Recommended,
description: "The publication date.",
},
{
name: "doi",
type: sections.Recommended,
description: "The Digital Object Identifier of the work.",
},
{
name: "url",
type: sections.Recommended,
description: "The url of an online publication.",
},
{
name: "urldate",
type: sections.Recommended,
description: "The access date of the <url>.",
},
// Optional Fields
{
name: "abstract",
type: sections.Optional,
description: "The abstract of the work being cited.",
},
{
name: "addendum",
type: sections.Optional,
description: "Miscellaneous bibliographic data.",
},
{
name: "afterword",
type: sections.Optional,
description: "The author(s) of an afterword to the work.",
},
{
name: "annotation",
type: sections.Optional,
description: "An annotation for use in annotated bibliographies.",
},
{
name: "annotator",
type: sections.Optional,
description: "The author(s) of annotations within the work.",
},
{
name: "authortype",
type: sections.Optional,
description: "The type of <author>.",
},
{
name: "bookauthor",
type: sections.Optional,
description: "The author(s) of <booktitle>",
},
{
name: "bookpagination",
type: sections.Optional,
description: "The pagination scheme of the enclosing work.",
},
{
name: "booksubtitle",
type: sections.Optional,
description: "The subtitle related to the <booktitle>.",
},
{
name: "booktitle",
type: sections.Optional,
description: "The title of a work which is part of a larger publication.",
},
{
name: "booktitleaddon",
type: sections.Optional,
description: "An annex to the <booktitle>.",
},
{
name: "chapter",
type: sections.Optional,
description: "A chapter or section or any other unit of a work.",
},
{
name: "commentator",
type: sections.Optional,
description: "The author(s) of a commentary to the work.",
},
{
name: "edition",
type: sections.Optional,
description: "The edition of a printed publication, as an integer.",
},
{
name: "editor",
type: sections.Optional,
description: "The editor(s) of the work.",
},
{
name: "editora",
type: sections.Optional,
description: "The secondary editor(s), performing a different editorial role.",
},
{
name: "editorb",
type: sections.Optional,
description: "More secondary editor(s), performing a different role.",
},
{
name: "editorc",
type: sections.Optional,
description: "More secondary editor(s), performing a different role.",
},
{
name: "editortype",
type: sections.Optional,
description: "The type of editorial role performed by <editor>.",
},
{
name: "editoratype",
type: sections.Optional,
description: "The type of editorial role performed by <editora>.",
},
{
name: "editorbtype",
type: sections.Optional,
description: "The type of editorial role performed by <editorb>.",
},
{
name: "editorctype",
type: sections.Optional,
description: "The type of editorial role performed by <editorc>.",
},
{
name: "eid",
type: sections.Optional,
description: "The Electronic Identifier of a section of a larger work.",
},
{
name: "entrysubtype",
type: sections.Optional,
description: "The subtype of an entry type.",
},
{
name: "eprint",
type: sections.Optional,
description: "The Electronic Identifier of an online publication.",
},
{
name: "eprintclass",
type: sections.Optional,
description: "Additional information related to the <eprinttype>.",
},
{
name: "eprinttype",
type: sections.Optional,
description: "The type of <eprint> identifier.",
},
{
name: "eventdate",
type: sections.Optional,
description: "The date of an event in a <@proceedings> entry.",
},
{
name: "eventtitle",
type: sections.Optional,
description: "The title of an event in a <@proceedings> entry.",
},
{
name: "eventtitleaddon",
type: sections.Optional,
description: "An annex to the <eventtitle>.",
},
{
name: "file",
type: sections.Optional,
description: "A local link to a file containing the work.",
},
{
name: "foreword",
type: sections.Optional,
description: "The author(s) of a foreword to the work.",
},
{
name: "holder",
type: sections.Optional,
description: "The holder(s) of a <@patent>.",
},
{
name: "howpublished",
type: sections.Optional,
description: "A publication notice for unusual publications.",
},
{
name: "indextitle",
type: sections.Optional,
description: "A title to use for indexing instead of the regular <title>.",
},
{
name: "institution",
type: sections.Optional,
description: "The name of a university or some other institution.",
},
{
name: "introduction",
type: sections.Optional,
description: "The author(s) of an introduction to the work.",
},
{
name: "isan",
type: sections.Optional,
description: "The International Standard Audiovisual Number of an audiovisual work.",
},
{
name: "isbn",
type: sections.Optional,
description: "The International Standard Book Number of a book.",
},
{
name: "ismn",
type: sections.Optional,
description: "The International Standard Music Number of a piece of printed music.",
},
{
name: "isrn",
type: sections.Optional,
description: "The International Standard Technical Report Number of a technical report.",
},
{
name: "issn",
type: sections.Optional,
description: "The International Standard Serial Number of a periodical.",
},
{
name: "issue",
type: sections.Optional,
description: "The issue of a journal or other periodical.",
},
{
name: "issuesubtitle",
type: sections.Optional,
description: "The subtitle of a specific issue of a periodical.",
},
{
name: "issuetitle",
type: sections.Optional,
description: "The title of a specific issue of a periodical.",
},
{
name: "issuetitleaddon",
type: sections.Optional,
description: "An annex to the <issuetitle>.",
},
{
name: "iswc",
type: sections.Optional,
description: "The International Standard Work Code of a musical work.",
},
{
name: "journalsubtitle",
type: sections.Optional,
description: "The subtitle of a periodical.",
},
{
name: "journaltitle",
type: sections.Optional,
description: "The title of a periodical.",
},
{
name: "journaltitleaddon",
type: sections.Optional,
description: "An annex to the <journaltitle>.",
},
{
name: "label",
type: sections.Optional,
description: "A fallback for the auto-generated label.",
},
{
name: "language",
type: sections.Optional,
description: "The language(s) of the work.",
},
{
name: "library",
type: sections.Optional,
description: "The library name and/or call number.",
},
{
name: "location",
type: sections.Optional,
description: "The place(s) of publication.",
},
{
name: "mainsubtitle",
type: sections.Optional,
description: "The subtitle related to the <maintitle>.",
},
{
name: "maintitle",
type: sections.Optional,
description: "The main title of a multi-volume publication.",
},
{
name: "maintitleaddon",
type: sections.Optional,
description: "An annex to the <maintitle>.",
},
{
name: "nameaddon",
type: sections.Optional,
description: "An addon to be printed after the author name.",
},
{
name: "note",
type: sections.Optional,
description: "Miscellae