@retorquere/bibtex-parser 12.1.9 → 12.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../index.ts"],
4
- "sourcesContent": ["/* eslint-disable no-underscore-dangle */\nimport type { Argument, Environment, Group, Macro, Node, Root, String as StringNode } from '@unified-latex/unified-latex-types'\nimport { LatexPegParser } from '@unified-latex/unified-latex-util-pegjs'\nimport { printRaw } from '@unified-latex/unified-latex-util-print-raw'\nimport { replaceNode } from '@unified-latex/unified-latex-util-replace'\nimport { visit } from '@unified-latex/unified-latex-util-visit'\nimport { combining, latex2unicode as latex2unicodemap } from 'unicode2latex'\nimport * as JabRef from './jabref.js'\nimport * as bibtex from './verbatim.js'\nexport type { Group as JabRefGroup, JabRefMetadata } from './jabref.js'\nexport type { ParseError } from './verbatim.js'\n/** Parses BibTeX without interpreting field contents as LaTeX. */\nexport { Library as VerbatimLibrary, parse as parseVerbatim } from './verbatim.js'\nexport type { Entry as VerbatimEntry, ParserOptions as VerbatimParserOptions } from './verbatim.js'\nimport { toSentenceCase } from './sentence-case.js'\n/** Converts a title to sentence case using heuristic token classification. */\nexport { toSentenceCase } from './sentence-case.js'\nexport type { Options as SentenceCaseOptions } from './sentence-case.js'\nimport { tokenize } from './tokenizer.js'\nimport type { Token } from './tokenizer.js'\n/** Splits text into classified tokens with source offsets. */\nexport { tokenize } from './tokenizer.js'\nexport type { Token } from './tokenizer.js'\n\nimport { playnice } from './yield.js'\n\nimport { crossref as CrossRef } from './crossref.js'\nimport { allowed as Allowed, noCrossRef as NoCrossRef } from './fields.js'\n\nimport { merge } from './merge.js'\n\nfunction latexMode(node: Node | Argument): 'math' | 'text' {\n return node._renderInfo!.mode as 'math' | 'text'\n}\n\nconst macroAliases: Record<string, string> = {\n sb: 'textsubscript',\n sp: 'textsuperscript',\n}\n\nfunction latex2unicode(tex: string, node: Node): string {\n if (node.type === 'macro' && macroAliases[node.content]) {\n tex = `\\\\${macroAliases[node.content]}${tex.slice(node.content.length + 1)}`\n }\n const text: string | Record<string, string> = latex2unicodemap[tex]\n if (typeof text === 'string') return text\n return text && text[latexMode(node)]\n}\n\nconst open: Record<string, string> = {}\nconst close: Record<string, string> = {}\nfor (const tag of ['i', 'b', 'sc', 'nc', 'ncx', 'br', 'p', 'li', 'code']) {\n open[tag] = `\\x0E${tag}\\x0F`\n close[tag] = `\\x0E/${tag}\\x0F`\n}\nconst collapsable = /\\x0E\\/([a-z]+)\\x0F(\\s*)\\x0E\\1\\x0F/ig\n\nexport type CreatorFields = {\n author?: Creator[]\n bookauthor?: Creator[]\n collaborator?: Creator[]\n commentator?: Creator[]\n director?: Creator[]\n editor?: Creator[]\n editora?: Creator[]\n editorb?: Creator[]\n editors?: Creator[]\n holder?: Creator[]\n scriptwriter?: Creator[]\n translator?: Creator[]\n}\nexport type ArrayFields = {\n keywords?: string[]\n institution?: string[]\n publisher?: string[]\n origpublisher?: string[]\n organization?: string[]\n location?: string[]\n origlocation?: string[]\n}\nexport type TypedFields = CreatorFields & ArrayFields\nexport type Fields = TypedFields & Omit<Record<string, string>, keyof TypedFields>\n\n/** A normalized BibTeX entry returned by {@link parse}. */\nexport type Entry = {\n type: string\n key: string\n fields: Fields\n mode: Record<string, ParseMode>\n crossref?: Record<string, { parent: string; field: string }>\n input: string\n}\n\nconst Month = {\n jan: '1',\n january: '1',\n feb: '2',\n february: '2',\n mar: '3',\n march: '3',\n apr: '4',\n april: '4',\n may: '5',\n jun: '6',\n june: '6',\n jul: '7',\n july: '7',\n aug: '8',\n august: '8',\n sep: '9',\n september: '9',\n oct: '10',\n october: '10',\n nov: '11',\n november: '11',\n dec: '12',\n december: '12',\n}\n\n/** The parsed contents of a BibTeX library. */\nexport interface Library {\n /**\n * errors found while parsing\n */\n errors: bibtex.ParseError[]\n\n /**\n * entries in the order in which they are found, omitting those which could not be parsed.\n */\n entries: Entry[]\n\n /**\n * `@comment`s found in the bibtex file.\n */\n comments: string[]\n\n /**\n * `@string`s found in the bibtex file.\n */\n strings: Record<string, string>\n\n /**\n * `@preamble` declarations found in the bibtex file\n */\n preambles: string[]\n\n /**\n * jabref metadata (such as groups information) found in the bibtex file\n */\n jabref: JabRef.JabRefMetadata\n}\n\nexport interface Options {\n /**\n * Bib(La)TeX handles entries that are in English differently from emtries in other languages. For English-like entries,\n * it expects titles in title-case. Words within braces are recognized as \"case-protected\" and their original casing is preserved during\n * rendering. For non-English entries, the casing as entered in the entries is rendered as entered. Other reference managers, such as\n * Zotero, expect all titles to be in sentence-case. In this parser you can specify which `langid` values mark an entry to be English so\n * that it can convert those titles to sentence-case, and to carry over case-protection. If no `langid` is present an entry is\n * assumed to be English by bib(la)tex, and the parser follows that convention. Note that sentence-casing uses heuristics and\n * does not employ any kind of natural language processing, so you should always inspect the results. If you offer your own list\n * of english-langids here, do not forget to include the empty string, stands for \"`langid` absent\". Default languages to sentenceCase\n * are the empty string, plus:\n *\n * - american\n * - british\n * - canadian\n * - english\n * - australian\n * - newzealand\n * - usenglish\n * - ukenglish\n * - en\n * - eng\n * - en-au\n * - en-bz\n * - en-ca\n * - en-cb\n * - en-gb\n * - en-ie\n * - en-jm\n * - en-nz\n * - en-ph\n * - en-tt\n * - en-us\n * - en-za\n * - en-zw\n *\n * If you pass an empty array, or `false`, no sentence casing will be applied (even when there's no language field).\n */\n english?: string[] | boolean\n\n /**\n * By default, `langid` and `hyphenation` are used to determine whether an entry is English, but some sources (ab)use the `language` field\n * for this. If you turn on this option, this field will also be taken into account as a source for `langid`.\n */\n languageAsLangid?: boolean\n\n sentenceCase?: false | {\n /**\n * Some bibtex files will have English titles in sentence case, or all-uppercase. If this is on, and there is a field that would\n * normally have sentence-casing applied in which there are all-lowercase words that are not prepositions (where `X` is either\n * lower or upper) than mixed-case, it is assumed that you want them this way, and no sentence-casing will be applied to that field\n */\n guess?: boolean\n\n /**\n * Retain Capitalised words in sub-sentences after colons. Given the input title \"Structured Interviewing For OCB: Construct Validity,\n * Faking, And The Effects Of Question Type\":\n * - when `true`, sentence-cases to \"Structured interviewing for OCB: Construct validity, faking, and the effects of question type\"\n * - when `false`, sentence-cases to \"Structured interviewing for OCB: construct validity, faking, and the effects of question type\"\n */\n subSentence?: boolean\n\n /**\n * If you have sentence-casing on, you can independently choose whether quoted titles within a title are preserved as-is (true)\n * or also sentence-cased (false).\n */\n preserveQuoted?: boolean\n }\n\n /**\n * translate braced parts of English-entry titles into a case-protected counterpart; Default == true == as-needed.\n * In as-needed mode the parser will assume that words that have capitals in them imply \"nocase\" behavior in the consuming application. If you don't want this, turn this option on, and you'll get\n * case protection exactly as the input has it\n */\n caseProtection?: 'as-needed' | 'strict' | boolean\n\n /**\n * How to handle unknown TeX commands and environments: `tex` wraps the command in a script\n * element, `text` returns the command without its backslash, `ignore` omits it, and `throw`\n * throws an error identifying the unsupported TeX. When omitted, literal TeX is preserved for\n * backwards compatibility.\n */\n unsupported?: 'tex' | 'text' | 'ignore' | 'throw'\n\n /**\n * Some fields such as `url` are parsed in what is called \"verbatim mode\" where pretty much everything except braces is treated as regular text, not TeX commands. You can change the default list here if you want,\n * for example to help parse Mendeley `file` fields, which against spec are not in verbatim mode.\n */\n verbatimFields?: (string | RegExp)[]\n\n /**\n * In the past many bibtex entries would just always wrap a field in double braces, likely because whomever was writing them couldn't figure out the case meddling rules (and who could\n * blame them). Fields listed here will either have one outer layer of braces treated as case-preserve, or have the outer braced be ignored completely, if this is detected.\n */\n removeOuterBraces?: string[]\n\n /**\n * Specify parsing mode for specific fields\n */\n fieldMode?: Record<string, ParseMode>\n\n /**\n * If this flag is set entries will be returned without conversion of LaTeX to unicode equivalents.\n */\n raw?: boolean\n\n /**\n * You can pass in an existing `@string` dictionary\n */\n strings?: Record<string, string> | string\n\n /**\n * Apply crossref inheritance\n */\n applyCrossRef?: boolean\n}\n\n/** A parsed personal or organizational name. */\nexport interface Creator {\n name?: string\n lastName?: string\n firstName?: string\n prefix?: string\n suffix?: string\n initial?: string\n useprefix?: boolean\n juniorcomma?: boolean\n}\n\nexport const FieldMode = {\n creatorlist: [\n 'author',\n 'bookauthor',\n 'collaborator',\n 'commentator',\n 'director',\n 'editor',\n 'editora',\n 'editorb',\n 'editors',\n 'holder',\n 'scriptwriter',\n 'translator',\n ],\n title: [\n 'title',\n 'subtitle',\n 'series',\n 'shorttitle',\n 'booktitle',\n // 'type',\n 'origtitle',\n 'maintitle',\n 'eventtitle',\n ],\n verbatim: [\n 'doi',\n 'eprint',\n 'file',\n 'files',\n 'pdf',\n 'groups', // jabref unilaterally decided to make this non-standard field verbatim\n 'ids',\n 'url',\n 'verba',\n 'verbb',\n 'verbc',\n /^keywords([+]duplicate-\\d+)?$/,\n /^citeulike-linkout-[0-9]+$/,\n /^bdsk-url-[0-9]+$/,\n ],\n richtext: [\n 'annotation',\n 'comment',\n 'annote',\n 'review',\n 'notes',\n 'note',\n ],\n literallist: [\n 'institution',\n 'publisher',\n 'origpublisher',\n 'organization',\n 'location',\n 'origlocation',\n ],\n}\n\n/** Controls how a field's TeX content is interpreted. */\nexport type ParseMode = keyof typeof FieldMode | 'literal' | 'verbatimlist'\n\nexport const English = [\n '',\n 'american',\n 'british',\n 'canadian',\n 'english',\n 'australian',\n 'newzealand',\n 'usenglish',\n 'ukenglish',\n 'en',\n 'eng',\n 'en-au',\n 'en-bz',\n 'en-ca',\n 'en-cb',\n 'en-gb',\n 'en-ie',\n 'en-jm',\n 'en-nz',\n 'en-ph',\n 'en-tt',\n 'en-us',\n 'en-za',\n 'en-zw',\n 'anglais', // don't do this people\n]\n\nconst FieldAction = {\n removeOuterBraces: [\n 'doi',\n // 'publisher',\n // 'location',\n ],\n parseInt: [\n 'year',\n 'month',\n ],\n}\n\nconst narguments = {\n advance: 1,\n allcaps: 1,\n ElsevierGlyph: 1,\n bar: 1,\n bibcyr: 1,\n bibstring: 1,\n chsf: 1,\n cite: 1,\n citeauthor: 1,\n cyrchar: 1,\n discretionary: 3,\n ding: 1,\n emph: 1,\n enquote: 1,\n frac: 2,\n hbox: 1,\n href: 2,\n hskip: 1,\n hspace: 1,\n ht: 1,\n mathrm: 1,\n mbox: 1,\n mkbibbold: 1,\n mkbibemph: 1,\n mkbibitalic: 1,\n mkbibquote: 1,\n newcommand: 2,\n noopsort: 1,\n ocirc: 1,\n overline: 1,\n ProvideTextCommandDefault: 2,\n rlap: 1,\n sb: 1,\n section: 1,\n symbol: 1,\n sp: 1,\n subsection: 1,\n subsubsection: 1,\n subsubsubsection: 1,\n t: 1,\n textbf: 1,\n textcite: 1,\n textit: 1,\n textrm: 1,\n textsc: 1,\n textsl: 1,\n textsubscript: 1,\n textsuperscript: 1,\n texttt: 1,\n textup: 1,\n url: 1,\n vphantom: 1,\n vspace: 1,\n wd: 1,\n\n // math\n 'math\\t_': 1,\n 'math\\t^': 1,\n}\nfor (const m in combining.tounicode) { // eslint-disable-line guard-for-in\n narguments[m] = 1\n}\n\nclass UnsupportedError extends Error {}\n\ntype Context = {\n mode: ParseMode\n caseProtected?: boolean\n}\n\n/*\nasync function* asyncGenerator<T>(array: T[]): AsyncGenerator<T, void, unknown> {\n for (const item of array) {\n yield await Promise.resolve(item)\n }\n}\n*/\n\nclass BibTeXParser {\n private current!: Entry\n private english!: boolean\n private options!: Options\n private fieldMode!: typeof FieldMode\n private newcommands: Record<string, Argument> = {}\n private bib!: Library\n private unhandled: Set<string> = new Set()\n\n private split(ast: Group | Root, sep: RegExp, split: RegExp): Root[] {\n const roots: Root[] = []\n\n const nodes = [...ast.content]\n const types = nodes.map(node => {\n if (node.type === 'whitespace') return ' '\n if (node.type === 'string' && node.content.match(sep)) return '&'\n return '.'\n }).join('')\n\n types.split(split).forEach((match, i) => {\n const content = match.length ? nodes.splice(0, match.length) : []\n if ((i % 2) === 0) roots.push({ type: 'root', content })\n })\n\n return roots\n }\n\n private trimCreator(cr: Creator): Creator {\n // trims strings but coincidentally removes undefined fields\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return JSON.parse(JSON.stringify(cr, (k, v) => typeof v === 'string' ? (v.trim() || undefined) : v)) as Creator\n }\n\n private parseCreator(ast: Root): Creator {\n if (ast.content.length === 1 && ast.content[0].type === 'group') return this.trimCreator({ name: this.stringify(ast, { mode: 'creatorlist' }) })\n\n const { parts, extended } = this.commaSeparatedCreator(ast)\n if (extended) {\n const name: Creator = {}\n for (const [attr, value] of Object.entries(extended)) {\n const rendered = this.stringify(value, { mode: 'creatorlist' }).trim()\n\n switch (attr) {\n case '':\n break\n\n case 'given':\n name.firstName = rendered\n break\n\n case 'family':\n name.lastName = rendered\n break\n\n case 'given-i':\n name.initial = rendered\n break\n\n case 'useprefix':\n case 'juniorcomma':\n name[attr] = rendered.toLowerCase() === 'true'\n break\n\n default:\n name[attr] = rendered\n break\n }\n }\n return this.trimCreator(name)\n }\n else if (parts.length) {\n const nameparts: string[] = parts.map((part: Node) => this.stringify(part, { mode: 'creatorlist' }).trim())\n\n if (nameparts.length === 3 && nameparts[2] === '') nameparts.pop()\n\n if (nameparts.length > 3) {\n const key = this.current.key ? `@${this.current.key}: ` : ''\n this.bib.errors.push({\n error: `${key}unexpected ${nameparts.length}-part name \"${nameparts.join(', ')}\", dropping \"${nameparts.slice(3).join(', ')}\"`,\n input: nameparts.join(', '),\n })\n }\n\n let [lastName, suffix, firstName] = (nameparts.length === 2)\n ? [nameparts[0], undefined, nameparts[1]]\n // > 3 parts are invalid and are dropped\n : nameparts.slice(0, 3)\n let prefix\n const m = lastName.match(/^([a-z'. ]+) (.+)/)\n if (m) {\n prefix = m[1]\n lastName = m[2]\n }\n return this.trimCreator({\n lastName,\n firstName,\n prefix,\n suffix,\n })\n }\n else { // first-last mode\n const nameparts = this.split(ast, /^$/, /( )/).map(part => this.stringify(part, { mode: 'creatorlist' })).filter(n => n)\n\n if (nameparts.length === 1) return this.trimCreator({ lastName: nameparts[0] })\n\n const prefix = nameparts.findIndex(n => n.match(/^[a-z]/))\n const postfix = prefix <= 0 ? -1 : nameparts.findIndex((n, i) => i > prefix && !n.match(/^[a-z]/))\n if (postfix === -1) {\n const lastName = nameparts.pop()\n return this.trimCreator({ lastName, firstName: nameparts.join(' ') })\n }\n\n return this.trimCreator({\n firstName: nameparts.slice(0, prefix).join(' '),\n prefix: nameparts.slice(prefix, postfix).join(' '),\n lastName: nameparts.slice(postfix).join(' '),\n })\n }\n }\n\n private ligature(nodes: Node[]): StringNode | null {\n if (latexMode(nodes[0]) !== 'text') return null\n\n const max = 3\n const slice = nodes.slice(0, max)\n const type = slice.map(n => n.type === 'string' ? 's' : ' ').join('')\n if (type[0] !== 's') return null\n\n const content = slice.map(n => n.type === 'string' ? n.content : '')\n let latex: string\n\n while (content.length) {\n if (type.startsWith('s'.repeat(content.length)) && (latex = latex2unicode(content.join(''), slice[0]))) {\n try {\n return { type: 'string', content: latex, _renderInfo: {} }\n }\n finally {\n nodes.splice(0, content.length)\n }\n }\n content.pop()\n }\n\n return null\n }\n\n private wraparg(node: Node, macro: Macro): Argument {\n if (macro.content.match(/^(itshape|textsl|textit|emph|mkbibemph)$/)) node._renderInfo!.emph = true\n if (macro.content.match(/^(textbf|mkbibbold|bfseries)$/)) node._renderInfo!.bold = true\n if (macro.content.match(/^(textsc)$/)) node._renderInfo!.smallCaps = true\n if (macro.content.match(/^(texttt)$/)) node._renderInfo!.code = true\n return { type: 'argument', content: [node], openMark: '', closeMark: '', _renderInfo: { mode: node._renderInfo!.mode } }\n }\n\n private argtogroup(node: Argument): Group {\n if (node.content.length === 1 && node.content[0].type === 'group') return node.content[0]\n return { type: 'group', content: node.content }\n }\n\n private argument(nodes: Node[], macro: Macro): Argument | null {\n if (!nodes.length) return null\n if (nodes[0].type === 'whitespace') nodes.shift()\n if (!nodes.length) return null\n if (nodes[0].type === 'string') {\n const char = nodes[0].content[0]\n nodes[0].content = nodes[0].content.substr(1)\n const arg = { ...nodes[0], content: char }\n if (!nodes[0].content) nodes.shift()\n return this.wraparg(arg, macro)\n }\n return this.wraparg(nodes.shift()!, macro)\n }\n\n private unsupported(node: Node): string {\n const tex = printRaw(node)\n if (this.options.unsupported === 'throw') throw new UnsupportedError(`unhandled ${node.type} ${tex}`)\n\n let id: string\n switch (node.type) {\n case 'macro':\n id = `${node.type}.${node.content}`\n if (!this.unhandled.has(id)) {\n this.unhandled.add(id)\n this.bib.errors.push({ error: `unhandled ${node.type} ${printRaw(node)}`, input: printRaw(node) })\n }\n break\n case 'environment':\n id = `${node.type}.${node.env}`\n if (!this.unhandled.has(id)) {\n this.unhandled.add(id)\n this.bib.errors.push({ error: `unhandled ${node.type} ${node.env} (${printRaw(node)})`, input: printRaw(node) })\n }\n break\n default:\n this.bib.errors.push({ error: `unhandled ${node.type} (${printRaw(node)})`, input: printRaw(node) })\n break\n }\n\n const command = node.type === 'macro' ? `\\\\${node.content}` : tex\n switch (this.options.unsupported) {\n case 'ignore':\n return ''\n case 'text':\n return command.replace(/^\\\\/, '')\n case 'tex':\n return `<script>${command}</script>`\n default:\n return tex\n }\n }\n\n private wrap(text: string, tag, wrap = true): string {\n if (!text || !wrap) return text || ''\n return `\\x0E${tag}\\x0F${text}\\x0E/${tag}\\x0F`\n }\n\n private registercommand(node: Macro): string {\n const types = (nodes: Node[]) => nodes.map(n => n.type).join('.')\n\n const group = (arg: Argument, kind: string): Node[] => {\n if (!arg) throw new Error(`missing ${kind} for ${printRaw(node)} @ ${JSON.stringify(node.position)}`)\n if (types(arg.content) !== 'group') throw new Error(`Malformed ${kind} for ${printRaw(node)} @ ${JSON.stringify(node.position)}`)\n return (<Group> arg.content[0]).content\n }\n\n if (!node.args) throw new Error(`No arguments for ${printRaw(node)} @ ${JSON.stringify(node.position)}`)\n\n const namearg = group(node.args[0], 'name')\n if (types(namearg) !== 'macro') throw new Error(`Unexpected name for ${printRaw(node)} @ ${JSON.stringify(node.position)}`)\n\n this.newcommands[(<Macro> namearg[0]).content] = node.args[1]\n return ''\n }\n\n private subp(text: string, mode: 'sub' | 'sup') {\n const macro = { sub: '_', sup: '^' }[mode]\n let subp = ''\n for (let char of text) {\n const mapped = latex2unicodemap[`${macro}{${char}}`]\n switch (typeof mapped) {\n case 'string':\n subp += mapped\n break\n\n case 'undefined':\n return `\\x0E${mode}\\x0F${text}\\x0E/${mode}\\x0F`\n\n default:\n subp += mapped.math\n }\n }\n return subp\n }\n\n private macro(node: Macro, context: Context): string {\n const name = macroAliases[node.content] ?? node.content\n if (name === 'discretionary') {\n return node.args?.[2] ? this.stringify(node.args[2], context) : ''\n }\n if (name === 'symbol') {\n const argument = node.args?.[0]?.content ?? []\n const content = argument.length === 1 && argument[0].type === 'group' ? argument[0].content : argument\n const code = content.map(n => this.stringify(n, context)).join('').trim()\n const value = /^\\d+$/.test(code) ? Number(code) : NaN\n if (Number.isSafeInteger(value) && value <= 0x10ffff && !(value >= 0xd800 && value <= 0xdfff)) {\n return String.fromCodePoint(value)\n }\n return this.unsupported(node)\n }\n\n const text = latex2unicode(printRaw(node), node)\n if (text) return text\n\n let url: Argument\n let label: Argument\n let arg: string[]\n switch (name) {\n case 'newcommand':\n case 'ProvideTextCommandDefault':\n return this.registercommand(node)\n\n // too complex to deal with these\n case 'raise':\n case 'accent':\n case 'def':\n case 'hss':\n case 'ifmmode':\n case 'makeatletter':\n case 'makeatother':\n case 'scriptscriptstyle':\n case 'setbox':\n case 'dimen':\n case 'advance':\n return ''\n\n case 'vphantom':\n case 'noopsort':\n case 'left':\n case 'right':\n case 'ensuremath':\n case 'wd':\n case 'ht':\n return ''\n\n case 'path':\n return '' // until https://github.com/siefkenj/unified-latex/issues/94 is fixed\n\n case 'hspace':\n case 'hskip':\n if (node.args && node.args.length) {\n if (printRaw(node.args).match(/^[{]?0[a-z]*$/)) return ''\n return ' '\n }\n return ''\n\n case 'overline':\n case 'bar':\n return node.args!.map(a => this.stringify(a, context)).join('').replace(/[a-z0-9]/ig, m => `${m}\\u0305`)\n\n // accents dealt with by preprocessor\n case 'textup':\n case 'textsc':\n case 'textrm':\n case 'texttt':\n case 'mathrm':\n case 'mbox':\n case 'hbox':\n case 'rlap':\n return node.args!.map(n => this.stringify(n, context)).join('')\n\n case 'href':\n case 'url':\n if (node.args) {\n url = node.args[0]\n label = node.args[node.content === 'url' ? 0 : 1]\n }\n return `<a href=\"${this.stringify(url!, context)}\">${this.stringify(label!, context)}</a>`\n\n case 'relax':\n case 'aftergroup':\n case 'ignorespaces':\n case 'undefined':\n case 'em':\n case 'it':\n case 'tt':\n case 'sl':\n case 'if':\n case 'ifx':\n case 'else':\n return ''\n\n case 'rm':\n case 'sc':\n return ''\n\n // bold/emph/smallcaps is handled in the wrapper\n case 'textbf':\n case 'mkbibbold':\n case 'textit':\n case 'emph':\n case 'mkbibemph':\n return this.stringify(node.args![0], context)\n\n case 'textsuperscript':\n return this.subp(this.stringify(node.args![0], context), 'sup')\n\n case 'textsubscript':\n return this.subp(this.stringify(node.args![0], context), 'sub')\n\n case 'allcaps':\n return this.wrap(this.stringify(node.args![0], { ...context, caseProtected: true }), 'nc', this.english && context.mode === 'title')\n\n case '_':\n case '^':\n switch (latexMode(node)) {\n case 'math':\n return this.subp(this.stringify(node.args![0], context), node.content === '^' ? 'sup' : 'sub')\n default:\n return node.content\n }\n\n case 'LaTeX':\n return this.wrap(`L${this.subp('A', 'sup')}T${this.subp('E', 'sub')}X`, 'ncx')\n\n case 'enquote':\n case 'mkbibquote':\n return this.wrap(this.stringify(node.args![0], context), 'enquote')\n\n case '\\\\':\n return context.mode === 'richtext' ? open.br : ' '\n\n case ' ':\n return ' '\n\n case 'par':\n return context.mode === 'richtext' ? open.p : ' '\n\n case 'item':\n return context.mode === 'richtext' ? open.li : ' '\n\n case 'section':\n case 'subsection':\n case 'subsubsection':\n case 'subsubsubsection':\n return this.wrap(this.stringify(node.args![0], context), `h${node.content.split('sub').length}`)\n\n case 'frac':\n arg = node.args!.map(a => this.stringify(a, context))\n if (arg.length === 2) {\n const resolved = latex2unicodemap[`\\\\frac${arg.map(a => `{${a}}`).join('')}`]\n if (resolved) return typeof resolved === 'string' ? resolved : (resolved.math || resolved.text)\n }\n return arg.map((part, i) => this.subp(part, i ? 'sub' : 'sup')).join('\\u2044')\n\n case 'chsf':\n case 'bibstring':\n case 'cite':\n case 'textcite':\n case 'citeauthor':\n // ncx protects but will be stripped later\n return this.wrap(this.stringify(node.args![0], context), 'ncx', context.mode === 'title')\n\n default:\n if (this.newcommands[node.content]) return this.stringify(this.newcommands[node.content], context)\n return this.unsupported(node)\n }\n }\n\n private what(node: Node) {\n if (!node) return ''\n\n switch (node.type) {\n case 'macro':\n return `macro:${<string> node._renderInfo!.mode ?? 'text'}:${node.content}`\n case 'environment':\n return `env:${node.env}`\n default:\n return node.type\n }\n }\n private environment(node: Environment, context: Context) {\n while (node.content.length && this.what(node.content[0]).match(/^parbreak|whitespace|macro:text:par$/)) node.content.shift()\n while (node.content.length && this.what(node.content[node.content.length - 1]).match(/^parbreak|whitespace|macro:text:par$/)) node.content.pop()\n\n switch (node.env) {\n case 'quotation':\n return this.wrap(node.content.map(n => this.stringify(n, context)).join(''), 'blockquote', context.mode === 'richtext')\n\n case 'itemize':\n return this.wrap(node.content.map(n => this.stringify(n, context)).join(''), 'ul', context.mode === 'richtext')\n\n case 'em':\n return this.wrap(node.content.map(n => this.stringify(n, context)).join(''), 'i', context.mode === 'richtext')\n\n default:\n return this.unsupported(node)\n }\n }\n\n private stringify(node: Node | Argument, context: Context): string {\n let content = this.stringifyContent(node, context)\n if (content && node._renderInfo) {\n if (node._renderInfo!.emph) content = `${open.i}${content}${close.i}`\n if (node._renderInfo!.bold) content = `${open.b}${content}${close.b}`\n if (node._renderInfo!.smallCaps) content = `${open.sc}${content}${close.sc}`\n if (node._renderInfo!.code) content = `${open.code}${content}${close.code}`\n if (this.english && node._renderInfo!.protectCase && !context.caseProtected) content = `${open.nc}${content}${close.nc}`\n }\n return content\n }\n\n private stringifyContent(node: Node | Argument, context: Context): string {\n if (!node) return ''\n\n switch (node.type) {\n case 'root':\n case 'argument':\n case 'group':\n case 'inlinemath':\n return node.content.map(n => this.stringify(n, context)).join('')\n\n case 'string':\n case 'verbatim':\n return node.content\n\n case 'macro':\n return this.macro(node, context)\n\n case 'parbreak':\n return context.mode === 'richtext' ? open.p : ' '\n\n case 'whitespace':\n return node._renderInfo!.mode === 'math' ? '' : ' '\n\n case 'comment':\n return ''\n\n case 'environment':\n return this.environment(node, context)\n\n case 'verb':\n return node.content\n\n default:\n return this.unsupported(node)\n }\n }\n\n private protect(node) {\n if (node.type === 'inlinemath') return true\n if (node.type !== 'group') return false\n if (!node.content.length) return false\n return (node.content[0].type !== 'macro')\n }\n\n private mode(field: string): ParseMode {\n if (this.options.verbatimFields && this.options.verbatimFields.find(name => typeof name === 'string' ? (name === field) : field.match(name))) return 'verbatim'\n\n let mode: ParseMode = 'literal'\n for (const [selected, fields] of Object.entries(this.fieldMode)) {\n if (fields.find(match => typeof match === 'string' ? field === match : field.match(match))) mode = <ParseMode> selected\n }\n return mode\n }\n\n private restoreMarkup(s: string): string {\n if (!s.includes('\\x0E')) return s\n\n const restored: string[] = [s.replace(/\\x0E\\/?ncx\\x0F/ig, '')]\n while (restored[0] !== restored[1]) {\n restored.unshift(restored[0].replace(collapsable, '$2'))\n }\n\n return restored[0]\n .replace(/(\\x0Ep\\x0F\\s*){2,}/ig, '\\x0Ep\\x0F')\n .replace(/\\s*(\\x0E\\/p\\x0F){2,}/ig, '\\x0E/p\\x0F')\n .replace(/\\x0Eenquote\\x0F/ig, '\\u201C').replace(/\\x0E\\/enquote\\x0F/ig, '\\u201D')\n .replace(/\\x0Esc\\x0F/ig, '<span style=\"font-variant:small-caps;\">').replace(/\\x0E\\/sc\\x0F/ig, '</span>')\n .replace(/\\x0Enc\\x0F/ig, '<span class=\"nocase\">').replace(/\\x0E\\/nc\\x0F/ig, '</span>')\n .replace(/\\x0E/ig, '<').replace(/\\x0F/ig, '>')\n }\n\n private stringField(field: string, value: string, mode: string, guessSC: boolean): string {\n if (field === 'crossref') return value\n\n if (FieldAction.parseInt.includes(field) && value.trim().match(/^-?\\d+$/)) return `${parseInt(value)}`\n\n if (this.english && mode === 'title') {\n value = toSentenceCase(value, {\n preserveQuoted: this.options.sentenceCase && this.options.sentenceCase.preserveQuoted,\n subSentenceCapitalization: this.options.sentenceCase && this.options.sentenceCase.subSentence,\n markup: /\\x0E\\/?([a-z]+)\\x0F/ig,\n nocase: /\\x0E(ncx?)\\x0F.*?\\x0E\\/\\1\\x0F/ig,\n guess: guessSC,\n })\n\n let cancel = (_match: string, stripped: string) => stripped\n switch (this.options.caseProtection) {\n case 'strict':\n cancel = (match: string, _stripped: string) => match\n break\n case 'as-needed':\n cancel = (match: string, stripped: string) => {\n const words: Token[] = tokenize(stripped, /\\x0E\\/?([a-z]+)\\x0F/ig)\n return words.find(w => w.shape.match(/^(?!.*X).*x.*$/)) ? match : this.wrap(stripped, 'ncx')\n }\n break\n }\n\n return value.replace(/\\x0Enc\\x0F(.*?)\\x0E\\/nc\\x0F/ig, cancel)\n }\n\n return value\n }\n\n private commaSeparatedCreator(ast: Root): { parts: Root[]; extended?: Record<string, Root> } {\n const result: { parts: Root[]; extended?: Record<string, Root> } = {\n parts: [],\n }\n\n if (!ast.content.find(node => node.type === 'string' && node.content === ',')) return result\n\n result.parts = this.split(ast, /^,$/, /(&)/)\n result.extended = {}\n for (const part of result.parts) {\n const start = part.content[0]?.type === 'whitespace' ? 1 : 0\n let signature = part.content\n .slice(start, start + 4)\n .map((node, i) => node._renderInfo!.mode === 'text' && node.type === 'string' ? node.content.replace(i % 2 ? /[^=-]/g : /[^a-z]/gi, '.') : '.')\n .join('')\n if (signature.match(/^[a-z]+(-[a-z]+)?=/i)) {\n signature = signature.replace(/=.*/, '').toLowerCase()\n result.extended[signature] = { type: 'root', content: part.content.slice(signature.includes('-') ? start + 4 : start + 2) }\n }\n else {\n delete result.extended\n break\n }\n }\n return result\n }\n\n private field(entry: Entry, field: string, value: string) {\n const mode: ParseMode = entry.mode[field] = this.mode(field)\n const caseProtection = {\n present: false,\n intuitive: 0, // a lot of people don't realise `some text \\textit{in italics}` will protect 'in italics'\n }\n\n const ast: Root = LatexPegParser.parse(value)\n\n if (this.options.removeOuterBraces!.includes(field) && ast.content.length === 1 && ast.content[0].type === 'group') {\n ast.content = ast.content[0].content\n }\n\n if (mode === 'verbatim') { // &^%@#&^%@# idiots wrapping verbatim fields\n entry.fields[field] = printRaw(ast)\n return\n }\n\n if (this.english && mode === 'title') {\n let root = [...ast.content]\n while (root.length) {\n const node = root.shift()!\n\n // only root groups offer case protecten -- but it may be as an macro arg, so mark here before gobbling\n if (this.protect(node)) node._renderInfo = { root: true }\n\n // environments are considered root when at root\n if (node.type === 'environment') root = [...root, ...node.content]\n }\n }\n\n // pass 0 -- register parse mode\n visit(ast, (node, info) => {\n if (!node._renderInfo) node._renderInfo = {}\n\n node._renderInfo!.mode = info.context.inMathMode ? 'math' : 'text'\n\n // if (info.context.inMathMode || info.context.hasMathModeAncestor) return\n\n if (mode === 'title' && node.type === 'inlinemath' && !info.parents.find(p => p._renderInfo!.protectCase)) node._renderInfo!.protectCase = true\n\n if (!info.context.inMathMode) {\n if (mode === 'title' && node._renderInfo!.root && (node.type !== 'group' || node.content[0].type !== 'macro')) {\n node._renderInfo!.protectCase = true\n if (node.type === 'group') {\n caseProtection.present = true\n caseProtection.intuitive += 1\n }\n }\n\n if (node.type === 'macro' && typeof node.escapeToken !== 'string') node.escapeToken = '\\\\'\n\n if (node.type === 'environment' && node.env === 'em') node._renderInfo!.emph = true\n }\n })\n\n if (this.options.raw) {\n switch (mode) {\n case 'creatorlist':\n entry.fields[field] = this.split(ast, /^and$/i, /(^& | & | &$)/)\n .map(cr => {\n const { parts, extended } = this.commaSeparatedCreator(cr)\n if (parts.length === 2 && !extended) {\n return this.trimCreator({ lastName: printRaw(parts[0]), firstName: printRaw(parts[1]) })\n }\n\n if (!parts.length) {\n const nameparts = this.split(ast, /^$/, /( )/)\n if (nameparts.length === 2) {\n return this.trimCreator({\n lastName: printRaw(nameparts[1]),\n firstName: printRaw(nameparts[0]),\n })\n }\n }\n\n return { name: printRaw(cr) }\n }) as unknown as string\n return\n case 'literallist':\n entry.fields[field] = this.split(ast, /^and$/i, /(^& | & | &$)/)\n .map(elt => printRaw(elt)) as unknown as string // pacify typescript\n return\n default:\n entry.fields[field] = printRaw(ast)\n return\n }\n }\n\n // pass 1 -- mark & normalize\n visit(ast, (nodes, info) => {\n const compacted: Node[] = []\n let inif = 0\n while (nodes.length) {\n const ligatureResult = this.ligature(nodes)\n if (ligatureResult) {\n compacted.push(ligatureResult)\n continue\n }\n\n const node = nodes.shift()!\n\n if (node.type === 'macro' && node.content === 'ifdefined') {\n inif += 1\n continue\n }\n else if (node.type === 'macro' && node.content === 'else') {\n continue\n }\n else if (node.type === 'macro' && node.content === 'fi') {\n inif = Math.max(inif - 1, 0)\n continue\n }\n else if (inif) {\n continue\n }\n\n const nargs = node.type === 'macro'\n ? narguments[node.content] || narguments[`${info.context.inMathMode ? 'math' : 'text'}\\t${node.content}`]\n : 0\n if (node.type === 'macro' && nargs) {\n const args = Array(nargs).fill(undefined).map(_i => this.argument(nodes, <Macro> node)).filter((arg): arg is Argument => arg !== null)\n node.args = args\n if (node.content.match(/^(url|href)$/) && args.length) {\n let url: Node[] = args[0].content\n if (url.length === 1 && url[0].type === 'group') url = url[0].content\n args[0] = this.wraparg({ type: 'string', content: printRaw(url), _renderInfo: { mode: url[0]._renderInfo!.mode } }, node)\n }\n caseProtection.intuitive -= args.filter(arg => arg.content[0].type === 'group' && arg.content[0]._renderInfo!.protectCase).length\n }\n else if (node.type === 'macro' && node.content.match(/^[a-z]+$/i) && nodes[0]?.type === 'whitespace') {\n nodes.shift()\n }\n\n compacted.push(node)\n }\n\n if (!info.context.inMathMode) {\n // feed-forward inline macros\n for (const [macro, markup] of Object.entries({ em: 'emph', it: 'emph', sl: 'emph', bf: 'bold', sc: 'smallCaps', tt: 'code' })) {\n if (info.parents.find(p => p._renderInfo?.[markup])) continue\n\n compacted.forEach((markup_node, i) => {\n if (markup_node.type === 'macro' && markup_node.content === macro) {\n compacted.slice(i + 1).forEach(n => n._renderInfo![markup] = true)\n }\n })\n }\n }\n\n nodes.push(...compacted)\n }, { test: Array.isArray, includeArrays: true })\n\n replaceNode(ast, (node, _info) => {\n if (node.type !== 'macro') return\n\n if (node.escapeToken && combining.tounicode[node.content]) {\n let arg: Node\n // no args, args of zero length, or first arg has no content\n if (!node.args || node.args.length === 0 || node.args[0].content.length === 0) {\n arg = { type: 'string', content: ' ', _renderInfo: {} }\n }\n else if (node.args.length !== 1 || node.args[0].content.length !== 1) {\n return\n }\n else {\n arg = node.args[0].content[0]\n }\n\n if (arg.type === 'group') {\n switch (arg.content.length) {\n case 0:\n arg = { type: 'string', content: ' ', _renderInfo: {} }\n break\n case 1:\n arg = arg.content[0]\n break\n default:\n return\n }\n }\n\n switch (arg.type) {\n case 'verbatim':\n case 'string':\n return { type: 'string', content: `${arg.content}${combining.tounicode[node.content]}`, _renderInfo: {} }\n case 'macro':\n // Legacy input can encode an accented base as an unknown control word, for example\n // `\\'{\\a}`. The outer accent is recognized, but `\\a` has no Unicode mapping. Treat\n // only that argument-free, single-letter payload as text here; ordinary unknown\n // macros must still go through the unsupported-command handler unchanged.\n if (arg.escapeToken && /^[A-Za-z]$/.test(arg.content) && !arg.args?.length) {\n const command = `${arg.escapeToken}${arg.content}`\n if (!(command in latex2unicodemap)) {\n return { type: 'string', content: `${arg.content}${combining.tounicode[node.content]}`, _renderInfo: {} }\n }\n }\n return\n default:\n return\n }\n }\n\n let latex = `${node.escapeToken}${node.content}`\n latex += (node.args || []).map(arg => printRaw(this.argtogroup(arg))).join('')\n if (latex in latex2unicodemap) return { type: 'string', content: latex2unicode(latex, node), _renderInfo: {} }\n // return null to delete\n })\n\n switch (mode) {\n case 'creatorlist':\n entry.fields[field] = this.split(ast, /^and$/i, /(^& | & | &$)/)\n .map(cr => this.parseCreator(cr))\n .filter(cr => Object.keys(cr).length) as unknown as string // pacify typescript\n break\n case 'literallist':\n entry.fields[field] = this.split(ast, /^and$/i, /(^& | & | &$)/)\n .map(elt => this.stringify(elt, { mode: 'literal' }).trim()) as unknown as string // pacify typescript\n break\n default:\n entry.fields[field] = this.stringField(\n field,\n this.stringify(ast, { mode }),\n mode,\n !!(this.options.sentenceCase && this.options.sentenceCase.guess), // && (!caseProtection.present || caseProtection.intuitive > 0)\n ) as unknown as string\n break\n }\n\n // recursively restores markup in string content. 'as string' is just here to pacify typescript\n entry.fields[field] = JSON.parse(JSON.stringify(entry.fields[field], (k, v) => (typeof v === 'string' ? this.restoreMarkup(v) : v) as string))\n }\n\n private reset(options: Options = {}) {\n if (options.sentenceCase === false) {\n options = {\n ...options,\n english: false,\n sentenceCase: {\n guess: false,\n subSentence: false,\n preserveQuoted: false,\n },\n }\n }\n\n this.options = merge(options, {\n caseProtection: 'as-needed',\n applyCrossRef: options.applyCrossRef ?? true,\n fieldMode: {},\n english: English,\n sentenceCase: {\n guess: true,\n preserveQuoted: true,\n },\n })\n\n if (this.options.caseProtection === true) this.options.caseProtection = 'as-needed'\n\n if (this.options.verbatimFields) this.options.verbatimFields = this.options.verbatimFields.map(f => typeof f === 'string' ? f.toLowerCase() : new RegExp(f.source, f.flags + (f.flags.includes('i') ? '' : 'i')))\n\n if (typeof this.options.english === 'boolean') this.options.english = this.options.english ? English : []\n this.options.english = (this.options.english as string[]).map(langid => langid.toLowerCase())\n\n this.fieldMode = Object.entries(FieldMode).reduce((acc: typeof FieldMode, [mode, test]: [string, (RegExp | string)[]]) => {\n const strings = test.filter(fieldname_or_regex => typeof fieldname_or_regex === 'string' && !this.options.fieldMode![fieldname_or_regex])\n const regexes = test.filter(fieldname_or_regex => typeof fieldname_or_regex !== 'string')\n acc[mode] = [...strings, ...regexes]\n return acc\n }, <typeof FieldMode> {})\n for (const [field, mode] of Object.entries(this.options.fieldMode!)) {\n this.fieldMode[mode].unshift(field)\n }\n\n if (!this.options.removeOuterBraces) {\n this.options.removeOuterBraces = [\n ...FieldAction.removeOuterBraces,\n ...this.fieldMode.title,\n ...this.fieldMode.verbatim,\n ].filter(field => typeof field === 'string')\n }\n\n if (options.unsupported !== undefined && !['tex', 'text', 'ignore', 'throw'].includes(options.unsupported)) {\n throw new TypeError('unsupported must be tex, text, ignore, or throw')\n }\n\n this.bib = {\n errors: [],\n entries: [],\n comments: [],\n strings: {},\n preambles: [],\n jabref: { root: [], groups: {} },\n }\n }\n\n private reparse(verbatim: bibtex.Entry) {\n let langid: string = (verbatim.fields.langid || verbatim.fields.hyphenation || '').toLowerCase()\n if (!langid && this.options.languageAsLangid && verbatim.fields.language) langid = verbatim.fields.language.toLowerCase()\n this.english = (<string[]> this.options.english).includes(langid)\n\n const entry: Entry = this.current = {\n type: verbatim.type,\n key: verbatim.key,\n fields: {},\n mode: {},\n input: verbatim.input,\n }\n let keywords: string[] = [] // OMG #783\n try {\n for (let [field, value] of Object.entries(verbatim.fields)) {\n if (!value.trim()) continue\n\n /*\n if (this.options.raw && !this.options.removeOuterBraces.includes(field)) {\n entry.fields[field] = value.trim()\n entry.mode[field] = 'verbatim'\n continue\n }\n */\n\n if (field.match(/^keywords([+]duplicate-\\d+)?$/)) field = 'keywords' // #873\n\n this.field(entry, field, value)\n\n if (field === 'keywords') { // #873\n keywords = [...keywords, ...(entry.fields.keywords as unknown as string).split(/\\s*[,;]\\s*/)].map((k: string) => k.trim()).filter(k => k)\n delete entry.fields.keywords\n }\n\n if (!this.options.raw && typeof entry.fields[field] === 'string') {\n entry.fields[field] = entry.fields[field].trim()\n if (field === 'month') entry.fields[field] = Month[entry.fields[field].toLowerCase()] || entry.fields[field]\n }\n }\n\n if (keywords.length) {\n entry.fields.keywords = keywords\n entry.mode.keywords = 'verbatimlist'\n }\n\n this.bib.entries.push(entry)\n }\n catch (err) {\n if (err instanceof UnsupportedError) throw err\n this.bib.errors.push({ error: `${err.message}\\n${entry.input}`, input: entry.input })\n }\n }\n\n private content(tex: string) {\n const entry: Entry = { key: '', type: '', fields: {}, mode: {}, input: tex }\n const english = this.english\n this.english = false\n this.field(entry, 'tex', tex)\n this.english = english\n return entry.fields.tex\n }\n\n private prep(base: bibtex.Library) {\n for (const preamble of base.preambles) {\n try {\n this.content(preamble)\n }\n catch (err) {\n if (err instanceof UnsupportedError) throw err\n }\n }\n for (const [k, v] of Object.entries(base.strings)) {\n this.bib.strings[k] = this.content(v)\n }\n }\n\n private finalize(base: bibtex.Library) {\n if (this.options.applyCrossRef) {\n const entries: Partial<Record<string, Entry>> = {}\n for (const entry of this.bib.entries) {\n if (entry.key) entries[entry.key.toUpperCase()] = entry\n }\n\n const order: string[] = []\n for (const entry of this.bib.entries) {\n if (!entry.key || typeof entry.fields.crossref !== 'string') continue\n\n const crossref = entry.fields.crossref.toUpperCase()\n if (!entries[crossref]) continue\n\n const key = entry.key.toUpperCase()\n // Topological sort: parents are unshifted to the front, children pushed\n // to the back. Because a parent may itself be a child of another entry,\n // unshift guarantees every ancestor appears before all of its descendants\n // regardless of the order entries appear in the .bib file. Duplicate\n // entries are skipped so a shared parent is only processed once.\n if (!order.includes(crossref)) order.unshift(crossref)\n if (!order.includes(key)) order.push(key)\n }\n\n for (const key of order) {\n const child = entries[key.toUpperCase()]!\n const parent = entries[child.fields.crossref?.toUpperCase()]\n if (!parent) continue\n\n for (const mappings of [CrossRef[child.type], CrossRef['*']].filter(m => m)) {\n for (const mapping of [mappings[parent.type], mappings['*']].filter(m => m)) {\n for (const [childfield, parentfield] of Object.entries(mapping)) {\n if (!child.fields[childfield] && parent.fields[parentfield]) {\n child.fields[childfield] = parent.fields[parentfield]\n\n child.crossref ??= {}\n child.crossref[childfield] = { parent: parent.key, field: parentfield }\n }\n }\n\n for (const field of (Allowed[child.type] || [])) {\n if (NoCrossRef.includes(field)) continue\n\n if (!child.fields[field] && parent.fields[field]) {\n child.fields[field] = parent.fields[field]\n\n child.crossref ??= {}\n child.crossref[field] = { parent: parent.key, field }\n }\n }\n }\n }\n }\n }\n\n const { comments, jabref } = JabRef.parse(base.comments)\n this.bib.comments = comments\n this.bib.jabref = jabref\n\n this.bib.preambles = base.preambles\n this.bib.errors = [...base.errors, ...this.bib.errors]\n }\n\n public parse(input: string, options: Options = {}): Library {\n this.reset(options)\n\n const base = bibtex.parse(input, { strings: options.strings })\n\n this.prep(base)\n\n for (const entry of base.entries) {\n this.reparse(entry)\n }\n\n this.finalize(base)\n return this.bib\n }\n\n public async parseAsync(input: string, options: Options = {}): Promise<Library> {\n this.reset(options)\n\n const base = await bibtex.promises.parse(input, { strings: options.strings })\n\n this.prep(base)\n\n let n = 1\n for (const entry of base.entries) {\n this.reparse(entry)\n if ((n++ % 1000) === 0) await playnice()\n }\n\n this.finalize(base)\n return this.bib\n }\n}\n\n/** Parses BibTeX or BibLaTeX source into a normalized library. */\nexport function parse(input: string, options: Options = {}): Library {\n const parser = new BibTeXParser()\n return parser.parse(input, options)\n}\n\n/** Asynchronous variant of {@link parse}, yielding periodically for large libraries. */\nexport async function parseAsync(input: string, options: Options = {}): Promise<Library> {\n const parser = new BibTeXParser()\n return await parser.parseAsync(input, options)\n}\n"],
5
- "mappings": ";;;AAEA,SAAS,sBAAsB;AAC/B,SAAS,gBAAgB;AACzB,SAAS,mBAAmB;AAC5B,SAAS,aAAa;AACtB,SAAS,WAAW,iBAAiB,wBAAwB;AAC7D,YAAY,YAAY;AACxB,YAAY,YAAY;AAIxB,SAAoB,SAA0B,aAAqB;AAEnE,SAAS,sBAAsB;AAE/B,SAAS,kBAAAA,uBAAsB;AAE/B,SAAS,gBAAgB;AAGzB,SAAS,YAAAC,iBAAgB;AAGzB,SAAS,gBAAgB;AAEzB,SAAS,YAAY,gBAAgB;AACrC,SAAS,WAAW,SAAS,cAAc,kBAAkB;AAE7D,SAAS,aAAa;AAEtB,SAAS,UAAU,MAAwC;AACzD,SAAO,KAAK,YAAa;AAC3B;AAEA,MAAM,eAAuC;AAAA,EAC3C,IAAI;AAAA,EACJ,IAAI;AACN;AAEA,SAAS,cAAc,KAAa,MAAoB;AACtD,MAAI,KAAK,SAAS,WAAW,a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UAAM,OAAO,MAAM,OAAO,SAAS,MAAM,OAAO,EAAE,SAAS,QAAQ,QAAQ,CAAC;AAE5E,SAAK,KAAK,IAAI;AAEd,QAAI,IAAI;AACR,eAAW,SAAS,KAAK,SAAS;AAChC,WAAK,QAAQ,KAAK;AAClB,UAAK,MAAM,QAAU,EAAG,OAAM,SAAS;AAAA,IACzC;AAEA,SAAK,SAAS,IAAI;AAClB,WAAO,KAAK;AAAA,EACd;AACF;AAGO,SAASC,OAAM,OAAe,UAAmB,CAAC,GAAY;AACnE,QAAM,SAAS,IAAI,aAAa;AAChC,SAAO,OAAO,MAAM,OAAO,OAAO;AACpC;AAGA,eAAsB,WAAW,OAAe,UAAmB,CAAC,GAAqB;AACvF,QAAM,SAAS,IAAI,aAAa;AAChC,SAAO,MAAM,OAAO,WAAW,OAAO,OAAO;AAC/C;",
4
+ "sourcesContent": ["/* eslint-disable no-underscore-dangle */\nimport type { Argument, Environment, Group, Macro, Node, Root, String as StringNode } from '@unified-latex/unified-latex-types'\nimport { LatexPegParser } from '@unified-latex/unified-latex-util-pegjs'\nimport { printRaw } from '@unified-latex/unified-latex-util-print-raw'\nimport { replaceNode } from '@unified-latex/unified-latex-util-replace'\nimport { visit } from '@unified-latex/unified-latex-util-visit'\nimport { combining, latex2unicode as latex2unicodemap } from 'unicode2latex'\nimport * as JabRef from './jabref.js'\nimport * as bibtex from './verbatim.js'\nexport type { Group as JabRefGroup } from './jabref.js'\nexport { JabRefMetadata } from './jabref.js'\nexport type { ParseError } from './verbatim.js'\n/** Parses BibTeX without interpreting field contents as LaTeX. */\nexport { Library as VerbatimLibrary, parse as parseVerbatim } from './verbatim.js'\nexport type { Entry as VerbatimEntry, ParserOptions as VerbatimParserOptions } from './verbatim.js'\nimport { toSentenceCase } from './sentence-case.js'\n/** Converts a title to sentence case using heuristic token classification. */\nexport { toSentenceCase } from './sentence-case.js'\nexport type { Options as SentenceCaseOptions } from './sentence-case.js'\nimport { tokenize } from './tokenizer.js'\nimport type { Token } from './tokenizer.js'\n/** Splits text into classified tokens with source offsets. */\nexport { tokenize } from './tokenizer.js'\nexport type { Token } from './tokenizer.js'\n\nimport { playnice } from './yield.js'\n\nimport { crossref as CrossRef } from './crossref.js'\nimport { allowed as Allowed, noCrossRef as NoCrossRef } from './fields.js'\n\nimport { merge } from './merge.js'\n\nfunction latexMode(node: Node | Argument): 'math' | 'text' {\n return node._renderInfo!.mode as 'math' | 'text'\n}\n\nconst macroAliases: Record<string, string> = {\n sb: 'textsubscript',\n sp: 'textsuperscript',\n}\n\nfunction latex2unicode(tex: string, node: Node): string {\n if (node.type === 'macro' && macroAliases[node.content]) {\n tex = `\\\\${macroAliases[node.content]}${tex.slice(node.content.length + 1)}`\n }\n const text: string | Record<string, string> = latex2unicodemap[tex]\n if (typeof text === 'string') return text\n return text && text[latexMode(node)]\n}\n\nconst open: Record<string, string> = {}\nconst close: Record<string, string> = {}\nfor (const tag of ['i', 'b', 'sc', 'nc', 'ncx', 'br', 'p', 'li', 'code']) {\n open[tag] = `\\x0E${tag}\\x0F`\n close[tag] = `\\x0E/${tag}\\x0F`\n}\nconst collapsable = /\\x0E\\/([a-z]+)\\x0F(\\s*)\\x0E\\1\\x0F/ig\n\nexport type CreatorFields = {\n author?: Creator[]\n bookauthor?: Creator[]\n collaborator?: Creator[]\n commentator?: Creator[]\n director?: Creator[]\n editor?: Creator[]\n editora?: Creator[]\n editorb?: Creator[]\n editors?: Creator[]\n holder?: Creator[]\n scriptwriter?: Creator[]\n translator?: Creator[]\n}\nexport type ArrayFields = {\n keywords?: string[]\n institution?: string[]\n publisher?: string[]\n origpublisher?: string[]\n organization?: string[]\n location?: string[]\n origlocation?: string[]\n}\nexport type TypedFields = CreatorFields & ArrayFields\nexport type Fields = TypedFields & Omit<Record<string, string>, keyof TypedFields>\n\n/** A normalized BibTeX entry returned by {@link parse}. */\nexport type Entry = {\n type: string\n key: string\n fields: Fields\n mode: Record<string, ParseMode>\n crossref?: Record<string, { parent: string; field: string }>\n input: string\n}\n\nconst Month = {\n jan: '1',\n january: '1',\n feb: '2',\n february: '2',\n mar: '3',\n march: '3',\n apr: '4',\n april: '4',\n may: '5',\n jun: '6',\n june: '6',\n jul: '7',\n july: '7',\n aug: '8',\n august: '8',\n sep: '9',\n september: '9',\n oct: '10',\n october: '10',\n nov: '11',\n november: '11',\n dec: '12',\n december: '12',\n}\n\n/** The parsed contents of a BibTeX library. */\nexport interface Library {\n /**\n * errors found while parsing\n */\n errors: bibtex.ParseError[]\n\n /**\n * entries in the order in which they are found, omitting those which could not be parsed.\n */\n entries: Entry[]\n\n /**\n * `@comment`s found in the bibtex file.\n */\n comments: string[]\n\n /**\n * `@string`s found in the bibtex file.\n */\n strings: Record<string, string>\n\n /**\n * `@preamble` declarations found in the bibtex file\n */\n preambles: string[]\n\n /**\n * jabref metadata (such as groups information) found in the bibtex file\n */\n jabref: JabRef.JabRefMetadata\n}\n\nexport interface Options {\n /**\n * Bib(La)TeX handles entries that are in English differently from emtries in other languages. For English-like entries,\n * it expects titles in title-case. Words within braces are recognized as \"case-protected\" and their original casing is preserved during\n * rendering. For non-English entries, the casing as entered in the entries is rendered as entered. Other reference managers, such as\n * Zotero, expect all titles to be in sentence-case. In this parser you can specify which `langid` values mark an entry to be English so\n * that it can convert those titles to sentence-case, and to carry over case-protection. If no `langid` is present an entry is\n * assumed to be English by bib(la)tex, and the parser follows that convention. Note that sentence-casing uses heuristics and\n * does not employ any kind of natural language processing, so you should always inspect the results. If you offer your own list\n * of english-langids here, do not forget to include the empty string, stands for \"`langid` absent\". Default languages to sentenceCase\n * are the empty string, plus:\n *\n * - american\n * - british\n * - canadian\n * - english\n * - australian\n * - newzealand\n * - usenglish\n * - ukenglish\n * - en\n * - eng\n * - en-au\n * - en-bz\n * - en-ca\n * - en-cb\n * - en-gb\n * - en-ie\n * - en-jm\n * - en-nz\n * - en-ph\n * - en-tt\n * - en-us\n * - en-za\n * - en-zw\n *\n * If you pass an empty array, or `false`, no sentence casing will be applied (even when there's no language field).\n */\n english?: string[] | boolean\n\n /**\n * By default, `langid` and `hyphenation` are used to determine whether an entry is English, but some sources (ab)use the `language` field\n * for this. If you turn on this option, this field will also be taken into account as a source for `langid`.\n */\n languageAsLangid?: boolean\n\n sentenceCase?: false | {\n /**\n * Some bibtex files will have English titles in sentence case, or all-uppercase. If this is on, and there is a field that would\n * normally have sentence-casing applied in which there are all-lowercase words that are not prepositions (where `X` is either\n * lower or upper) than mixed-case, it is assumed that you want them this way, and no sentence-casing will be applied to that field\n */\n guess?: boolean\n\n /**\n * Retain Capitalised words in sub-sentences after colons. Given the input title \"Structured Interviewing For OCB: Construct Validity,\n * Faking, And The Effects Of Question Type\":\n * - when `true`, sentence-cases to \"Structured interviewing for OCB: Construct validity, faking, and the effects of question type\"\n * - when `false`, sentence-cases to \"Structured interviewing for OCB: construct validity, faking, and the effects of question type\"\n */\n subSentence?: boolean\n\n /**\n * If you have sentence-casing on, you can independently choose whether quoted titles within a title are preserved as-is (true)\n * or also sentence-cased (false).\n */\n preserveQuoted?: boolean\n }\n\n /**\n * translate braced parts of English-entry titles into a case-protected counterpart; Default == true == as-needed.\n * In as-needed mode the parser will assume that words that have capitals in them imply \"nocase\" behavior in the consuming application. If you don't want this, turn this option on, and you'll get\n * case protection exactly as the input has it\n */\n caseProtection?: 'as-needed' | 'strict' | boolean\n\n /**\n * How to handle unknown TeX commands and environments: `tex` wraps the command in a script\n * element, `text` returns the command without its backslash, `ignore` omits it, and `throw`\n * throws an error identifying the unsupported TeX. When omitted, literal TeX is preserved for\n * backwards compatibility.\n */\n unsupported?: 'tex' | 'text' | 'ignore' | 'throw'\n\n /**\n * Some fields such as `url` are parsed in what is called \"verbatim mode\" where pretty much everything except braces is treated as regular text, not TeX commands. You can change the default list here if you want,\n * for example to help parse Mendeley `file` fields, which against spec are not in verbatim mode.\n */\n verbatimFields?: (string | RegExp)[]\n\n /**\n * In the past many bibtex entries would just always wrap a field in double braces, likely because whomever was writing them couldn't figure out the case meddling rules (and who could\n * blame them). Fields listed here will either have one outer layer of braces treated as case-preserve, or have the outer braced be ignored completely, if this is detected.\n */\n removeOuterBraces?: string[]\n\n /**\n * Specify parsing mode for specific fields\n */\n fieldMode?: Record<string, ParseMode>\n\n /**\n * If this flag is set entries will be returned without conversion of LaTeX to unicode equivalents.\n */\n raw?: boolean\n\n /**\n * You can pass in an existing `@string` dictionary\n */\n strings?: Record<string, string> | string\n\n /**\n * Apply crossref inheritance\n */\n applyCrossRef?: boolean\n}\n\n/** A parsed personal or organizational name. */\nexport interface Creator {\n name?: string\n lastName?: string\n firstName?: string\n prefix?: string\n suffix?: string\n initial?: string\n useprefix?: boolean\n juniorcomma?: boolean\n}\n\nexport const FieldMode = {\n creatorlist: [\n 'author',\n 'bookauthor',\n 'collaborator',\n 'commentator',\n 'director',\n 'editor',\n 'editora',\n 'editorb',\n 'editors',\n 'holder',\n 'scriptwriter',\n 'translator',\n ],\n title: [\n 'title',\n 'subtitle',\n 'series',\n 'shorttitle',\n 'booktitle',\n // 'type',\n 'origtitle',\n 'maintitle',\n 'eventtitle',\n ],\n verbatim: [\n 'doi',\n 'eprint',\n 'file',\n 'files',\n 'pdf',\n 'groups', // jabref unilaterally decided to make this non-standard field verbatim\n 'ids',\n 'url',\n 'verba',\n 'verbb',\n 'verbc',\n /^keywords([+]duplicate-\\d+)?$/,\n /^citeulike-linkout-[0-9]+$/,\n /^bdsk-url-[0-9]+$/,\n ],\n richtext: [\n 'annotation',\n 'comment',\n 'annote',\n 'review',\n 'notes',\n 'note',\n ],\n literallist: [\n 'institution',\n 'publisher',\n 'origpublisher',\n 'organization',\n 'location',\n 'origlocation',\n ],\n}\n\n/** Controls how a field's TeX content is interpreted. */\nexport type ParseMode = keyof typeof FieldMode | 'literal' | 'verbatimlist'\n\nexport const English = [\n '',\n 'american',\n 'british',\n 'canadian',\n 'english',\n 'australian',\n 'newzealand',\n 'usenglish',\n 'ukenglish',\n 'en',\n 'eng',\n 'en-au',\n 'en-bz',\n 'en-ca',\n 'en-cb',\n 'en-gb',\n 'en-ie',\n 'en-jm',\n 'en-nz',\n 'en-ph',\n 'en-tt',\n 'en-us',\n 'en-za',\n 'en-zw',\n 'anglais', // don't do this people\n]\n\nconst FieldAction = {\n removeOuterBraces: [\n 'doi',\n // 'publisher',\n // 'location',\n ],\n parseInt: [\n 'year',\n 'month',\n ],\n}\n\nconst narguments = {\n advance: 1,\n allcaps: 1,\n ElsevierGlyph: 1,\n bar: 1,\n bibcyr: 1,\n bibstring: 1,\n chsf: 1,\n cite: 1,\n citeauthor: 1,\n cyrchar: 1,\n discretionary: 3,\n ding: 1,\n emph: 1,\n enquote: 1,\n frac: 2,\n hbox: 1,\n href: 2,\n hskip: 1,\n hspace: 1,\n ht: 1,\n mathrm: 1,\n mbox: 1,\n mkbibbold: 1,\n mkbibemph: 1,\n mkbibitalic: 1,\n mkbibquote: 1,\n newcommand: 2,\n noopsort: 1,\n ocirc: 1,\n overline: 1,\n ProvideTextCommandDefault: 2,\n rlap: 1,\n sb: 1,\n section: 1,\n symbol: 1,\n sp: 1,\n subsection: 1,\n subsubsection: 1,\n subsubsubsection: 1,\n t: 1,\n textbf: 1,\n textcite: 1,\n textit: 1,\n textrm: 1,\n textsc: 1,\n textsl: 1,\n textsubscript: 1,\n textsuperscript: 1,\n texttt: 1,\n textup: 1,\n url: 1,\n vphantom: 1,\n vspace: 1,\n wd: 1,\n\n // math\n 'math\\t_': 1,\n 'math\\t^': 1,\n}\nfor (const m in combining.tounicode) { // eslint-disable-line guard-for-in\n narguments[m] = 1\n}\n\nclass UnsupportedError extends Error {}\n\ntype Context = {\n mode: ParseMode\n caseProtected?: boolean\n}\n\n/*\nasync function* asyncGenerator<T>(array: T[]): AsyncGenerator<T, void, unknown> {\n for (const item of array) {\n yield await Promise.resolve(item)\n }\n}\n*/\n\nclass BibTeXParser {\n private current!: Entry\n private english!: boolean\n private options!: Options\n private fieldMode!: typeof FieldMode\n private newcommands: Record<string, Argument> = {}\n private bib!: Library\n private unhandled: Set<string> = new Set()\n\n private split(ast: Group | Root, sep: RegExp, split: RegExp): Root[] {\n const roots: Root[] = []\n\n const nodes = [...ast.content]\n const types = nodes.map(node => {\n if (node.type === 'whitespace') return ' '\n if (node.type === 'string' && node.content.match(sep)) return '&'\n return '.'\n }).join('')\n\n types.split(split).forEach((match, i) => {\n const content = match.length ? nodes.splice(0, match.length) : []\n if ((i % 2) === 0) roots.push({ type: 'root', content })\n })\n\n return roots\n }\n\n private trimCreator(cr: Creator): Creator {\n // trims strings but coincidentally removes undefined fields\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return JSON.parse(JSON.stringify(cr, (k, v) => typeof v === 'string' ? (v.trim() || undefined) : v)) as Creator\n }\n\n private parseCreator(ast: Root): Creator {\n if (ast.content.length === 1 && ast.content[0].type === 'group') return this.trimCreator({ name: this.stringify(ast, { mode: 'creatorlist' }) })\n\n const { parts, extended } = this.commaSeparatedCreator(ast)\n if (extended) {\n const name: Creator = {}\n for (const [attr, value] of Object.entries(extended)) {\n const rendered = this.stringify(value, { mode: 'creatorlist' }).trim()\n\n switch (attr) {\n case '':\n break\n\n case 'given':\n name.firstName = rendered\n break\n\n case 'family':\n name.lastName = rendered\n break\n\n case 'given-i':\n name.initial = rendered\n break\n\n case 'useprefix':\n case 'juniorcomma':\n name[attr] = rendered.toLowerCase() === 'true'\n break\n\n default:\n name[attr] = rendered\n break\n }\n }\n return this.trimCreator(name)\n }\n else if (parts.length) {\n const nameparts: string[] = parts.map((part: Node) => this.stringify(part, { mode: 'creatorlist' }).trim())\n\n if (nameparts.length === 3 && nameparts[2] === '') nameparts.pop()\n\n if (nameparts.length > 3) {\n const key = this.current.key ? `@${this.current.key}: ` : ''\n this.bib.errors.push({\n error: `${key}unexpected ${nameparts.length}-part name \"${nameparts.join(', ')}\", dropping \"${nameparts.slice(3).join(', ')}\"`,\n input: nameparts.join(', '),\n })\n }\n\n let [lastName, suffix, firstName] = (nameparts.length === 2)\n ? [nameparts[0], undefined, nameparts[1]]\n // > 3 parts are invalid and are dropped\n : nameparts.slice(0, 3)\n let prefix\n const m = lastName.match(/^([a-z'. ]+) (.+)/)\n if (m) {\n prefix = m[1]\n lastName = m[2]\n }\n return this.trimCreator({\n lastName,\n firstName,\n prefix,\n suffix,\n })\n }\n else { // first-last mode\n const nameparts = this.split(ast, /^$/, /( )/).map(part => this.stringify(part, { mode: 'creatorlist' })).filter(n => n)\n\n if (nameparts.length === 1) return this.trimCreator({ lastName: nameparts[0] })\n\n const prefix = nameparts.findIndex(n => n.match(/^[a-z]/))\n const postfix = prefix <= 0 ? -1 : nameparts.findIndex((n, i) => i > prefix && !n.match(/^[a-z]/))\n if (postfix === -1) {\n const lastName = nameparts.pop()\n return this.trimCreator({ lastName, firstName: nameparts.join(' ') })\n }\n\n return this.trimCreator({\n firstName: nameparts.slice(0, prefix).join(' '),\n prefix: nameparts.slice(prefix, postfix).join(' '),\n lastName: nameparts.slice(postfix).join(' '),\n })\n }\n }\n\n private ligature(nodes: Node[]): StringNode | null {\n if (latexMode(nodes[0]) !== 'text') return null\n\n const max = 3\n const slice = nodes.slice(0, max)\n const type = slice.map(n => n.type === 'string' ? 's' : ' ').join('')\n if (type[0] !== 's') return null\n\n const content = slice.map(n => n.type === 'string' ? n.content : '')\n let latex: string\n\n while (content.length) {\n if (type.startsWith('s'.repeat(content.length)) && (latex = latex2unicode(content.join(''), slice[0]))) {\n try {\n return { type: 'string', content: latex, _renderInfo: {} }\n }\n finally {\n nodes.splice(0, content.length)\n }\n }\n content.pop()\n }\n\n return null\n }\n\n private wraparg(node: Node, macro: Macro): Argument {\n if (macro.content.match(/^(itshape|textsl|textit|emph|mkbibemph)$/)) node._renderInfo!.emph = true\n if (macro.content.match(/^(textbf|mkbibbold|bfseries)$/)) node._renderInfo!.bold = true\n if (macro.content.match(/^(textsc)$/)) node._renderInfo!.smallCaps = true\n if (macro.content.match(/^(texttt)$/)) node._renderInfo!.code = true\n return { type: 'argument', content: [node], openMark: '', closeMark: '', _renderInfo: { mode: node._renderInfo!.mode } }\n }\n\n private argtogroup(node: Argument): Group {\n if (node.content.length === 1 && node.content[0].type === 'group') return node.content[0]\n return { type: 'group', content: node.content }\n }\n\n private argument(nodes: Node[], macro: Macro): Argument | null {\n if (!nodes.length) return null\n if (nodes[0].type === 'whitespace') nodes.shift()\n if (!nodes.length) return null\n if (nodes[0].type === 'string') {\n const char = nodes[0].content[0]\n nodes[0].content = nodes[0].content.substr(1)\n const arg = { ...nodes[0], content: char }\n if (!nodes[0].content) nodes.shift()\n return this.wraparg(arg, macro)\n }\n return this.wraparg(nodes.shift()!, macro)\n }\n\n private unsupported(node: Node): string {\n const tex = printRaw(node)\n if (this.options.unsupported === 'throw') throw new UnsupportedError(`unhandled ${node.type} ${tex}`)\n\n let id: string\n switch (node.type) {\n case 'macro':\n id = `${node.type}.${node.content}`\n if (!this.unhandled.has(id)) {\n this.unhandled.add(id)\n this.bib.errors.push({ error: `unhandled ${node.type} ${printRaw(node)}`, input: printRaw(node) })\n }\n break\n case 'environment':\n id = `${node.type}.${node.env}`\n if (!this.unhandled.has(id)) {\n this.unhandled.add(id)\n this.bib.errors.push({ error: `unhandled ${node.type} ${node.env} (${printRaw(node)})`, input: printRaw(node) })\n }\n break\n default:\n this.bib.errors.push({ error: `unhandled ${node.type} (${printRaw(node)})`, input: printRaw(node) })\n break\n }\n\n const command = node.type === 'macro' ? `\\\\${node.content}` : tex\n switch (this.options.unsupported) {\n case 'ignore':\n return ''\n case 'text':\n return command.replace(/^\\\\/, '')\n case 'tex':\n return `<script>${command}</script>`\n default:\n return tex\n }\n }\n\n private wrap(text: string, tag, wrap = true): string {\n if (!text || !wrap) return text || ''\n return `\\x0E${tag}\\x0F${text}\\x0E/${tag}\\x0F`\n }\n\n private registercommand(node: Macro): string {\n const types = (nodes: Node[]) => nodes.map(n => n.type).join('.')\n\n const group = (arg: Argument, kind: string): Node[] => {\n if (!arg) throw new Error(`missing ${kind} for ${printRaw(node)} @ ${JSON.stringify(node.position)}`)\n if (types(arg.content) !== 'group') throw new Error(`Malformed ${kind} for ${printRaw(node)} @ ${JSON.stringify(node.position)}`)\n return (<Group> arg.content[0]).content\n }\n\n if (!node.args) throw new Error(`No arguments for ${printRaw(node)} @ ${JSON.stringify(node.position)}`)\n\n const namearg = group(node.args[0], 'name')\n if (types(namearg) !== 'macro') throw new Error(`Unexpected name for ${printRaw(node)} @ ${JSON.stringify(node.position)}`)\n\n this.newcommands[(<Macro> namearg[0]).content] = node.args[1]\n return ''\n }\n\n private subp(text: string, mode: 'sub' | 'sup') {\n const macro = { sub: '_', sup: '^' }[mode]\n let subp = ''\n for (let char of text) {\n const mapped = latex2unicodemap[`${macro}{${char}}`]\n switch (typeof mapped) {\n case 'string':\n subp += mapped\n break\n\n case 'undefined':\n return `\\x0E${mode}\\x0F${text}\\x0E/${mode}\\x0F`\n\n default:\n subp += mapped.math\n }\n }\n return subp\n }\n\n private macro(node: Macro, context: Context): string {\n const name = macroAliases[node.content] ?? node.content\n if (name === 'discretionary') {\n return node.args?.[2] ? this.stringify(node.args[2], context) : ''\n }\n if (name === 'symbol') {\n const argument = node.args?.[0]?.content ?? []\n const content = argument.length === 1 && argument[0].type === 'group' ? argument[0].content : argument\n const code = content.map(n => this.stringify(n, context)).join('').trim()\n const value = /^\\d+$/.test(code) ? Number(code) : NaN\n if (Number.isSafeInteger(value) && value <= 0x10ffff && !(value >= 0xd800 && value <= 0xdfff)) {\n return String.fromCodePoint(value)\n }\n return this.unsupported(node)\n }\n\n const text = latex2unicode(printRaw(node), node)\n if (text) return text\n\n let url: Argument\n let label: Argument\n let arg: string[]\n switch (name) {\n case 'newcommand':\n case 'ProvideTextCommandDefault':\n return this.registercommand(node)\n\n // too complex to deal with these\n case 'raise':\n case 'accent':\n case 'def':\n case 'hss':\n case 'ifmmode':\n case 'makeatletter':\n case 'makeatother':\n case 'scriptscriptstyle':\n case 'setbox':\n case 'dimen':\n case 'advance':\n return ''\n\n case 'vphantom':\n case 'noopsort':\n case 'left':\n case 'right':\n case 'ensuremath':\n case 'wd':\n case 'ht':\n return ''\n\n case 'path':\n return '' // until https://github.com/siefkenj/unified-latex/issues/94 is fixed\n\n case 'hspace':\n case 'hskip':\n if (node.args && node.args.length) {\n if (printRaw(node.args).match(/^[{]?0[a-z]*$/)) return ''\n return ' '\n }\n return ''\n\n case 'overline':\n case 'bar':\n return node.args!.map(a => this.stringify(a, context)).join('').replace(/[a-z0-9]/ig, m => `${m}\\u0305`)\n\n // accents dealt with by preprocessor\n case 'textup':\n case 'textsc':\n case 'textrm':\n case 'texttt':\n case 'mathrm':\n case 'mbox':\n case 'hbox':\n case 'rlap':\n return node.args!.map(n => this.stringify(n, context)).join('')\n\n case 'href':\n case 'url':\n if (node.args) {\n url = node.args[0]\n label = node.args[node.content === 'url' ? 0 : 1]\n }\n return `<a href=\"${this.stringify(url!, context)}\">${this.stringify(label!, context)}</a>`\n\n case 'relax':\n case 'aftergroup':\n case 'ignorespaces':\n case 'undefined':\n case 'em':\n case 'it':\n case 'tt':\n case 'sl':\n case 'if':\n case 'ifx':\n case 'else':\n return ''\n\n case 'rm':\n case 'sc':\n return ''\n\n // bold/emph/smallcaps is handled in the wrapper\n case 'textbf':\n case 'mkbibbold':\n case 'textit':\n case 'emph':\n case 'mkbibemph':\n return this.stringify(node.args![0], context)\n\n case 'textsuperscript':\n return this.subp(this.stringify(node.args![0], context), 'sup')\n\n case 'textsubscript':\n return this.subp(this.stringify(node.args![0], context), 'sub')\n\n case 'allcaps':\n return this.wrap(this.stringify(node.args![0], { ...context, caseProtected: true }), 'nc', this.english && context.mode === 'title')\n\n case '_':\n case '^':\n switch (latexMode(node)) {\n case 'math':\n return this.subp(this.stringify(node.args![0], context), node.content === '^' ? 'sup' : 'sub')\n default:\n return node.content\n }\n\n case 'LaTeX':\n return this.wrap(`L${this.subp('A', 'sup')}T${this.subp('E', 'sub')}X`, 'ncx')\n\n case 'enquote':\n case 'mkbibquote':\n return this.wrap(this.stringify(node.args![0], context), 'enquote')\n\n case '\\\\':\n return context.mode === 'richtext' ? open.br : ' '\n\n case ' ':\n return ' '\n\n case 'par':\n return context.mode === 'richtext' ? open.p : ' '\n\n case 'item':\n return context.mode === 'richtext' ? open.li : ' '\n\n case 'section':\n case 'subsection':\n case 'subsubsection':\n case 'subsubsubsection':\n return this.wrap(this.stringify(node.args![0], context), `h${node.content.split('sub').length}`)\n\n case 'frac':\n arg = node.args!.map(a => this.stringify(a, context))\n if (arg.length === 2) {\n const resolved = latex2unicodemap[`\\\\frac${arg.map(a => `{${a}}`).join('')}`]\n if (resolved) return typeof resolved === 'string' ? resolved : (resolved.math || resolved.text)\n }\n return arg.map((part, i) => this.subp(part, i ? 'sub' : 'sup')).join('\\u2044')\n\n case 'chsf':\n case 'bibstring':\n case 'cite':\n case 'textcite':\n case 'citeauthor':\n // ncx protects but will be stripped later\n return this.wrap(this.stringify(node.args![0], context), 'ncx', context.mode === 'title')\n\n default:\n if (this.newcommands[node.content]) return this.stringify(this.newcommands[node.content], context)\n return this.unsupported(node)\n }\n }\n\n private what(node: Node) {\n if (!node) return ''\n\n switch (node.type) {\n case 'macro':\n return `macro:${<string> node._renderInfo!.mode ?? 'text'}:${node.content}`\n case 'environment':\n return `env:${node.env}`\n default:\n return node.type\n }\n }\n private environment(node: Environment, context: Context) {\n while (node.content.length && this.what(node.content[0]).match(/^parbreak|whitespace|macro:text:par$/)) node.content.shift()\n while (node.content.length && this.what(node.content[node.content.length - 1]).match(/^parbreak|whitespace|macro:text:par$/)) node.content.pop()\n\n switch (node.env) {\n case 'quotation':\n return this.wrap(node.content.map(n => this.stringify(n, context)).join(''), 'blockquote', context.mode === 'richtext')\n\n case 'itemize':\n return this.wrap(node.content.map(n => this.stringify(n, context)).join(''), 'ul', context.mode === 'richtext')\n\n case 'em':\n return this.wrap(node.content.map(n => this.stringify(n, context)).join(''), 'i', context.mode === 'richtext')\n\n default:\n return this.unsupported(node)\n }\n }\n\n private stringify(node: Node | Argument, context: Context): string {\n let content = this.stringifyContent(node, context)\n if (content && node._renderInfo) {\n if (node._renderInfo!.emph) content = `${open.i}${content}${close.i}`\n if (node._renderInfo!.bold) content = `${open.b}${content}${close.b}`\n if (node._renderInfo!.smallCaps) content = `${open.sc}${content}${close.sc}`\n if (node._renderInfo!.code) content = `${open.code}${content}${close.code}`\n if (this.english && node._renderInfo!.protectCase && !context.caseProtected) content = `${open.nc}${content}${close.nc}`\n }\n return content\n }\n\n private stringifyContent(node: Node | Argument, context: Context): string {\n if (!node) return ''\n\n switch (node.type) {\n case 'root':\n case 'argument':\n case 'group':\n case 'inlinemath':\n return node.content.map(n => this.stringify(n, context)).join('')\n\n case 'string':\n case 'verbatim':\n return node.content\n\n case 'macro':\n return this.macro(node, context)\n\n case 'parbreak':\n return context.mode === 'richtext' ? open.p : ' '\n\n case 'whitespace':\n return node._renderInfo!.mode === 'math' ? '' : ' '\n\n case 'comment':\n return ''\n\n case 'environment':\n return this.environment(node, context)\n\n case 'verb':\n return node.content\n\n default:\n return this.unsupported(node)\n }\n }\n\n private protect(node) {\n if (node.type === 'inlinemath') return true\n if (node.type !== 'group') return false\n if (!node.content.length) return false\n return (node.content[0].type !== 'macro')\n }\n\n private mode(field: string): ParseMode {\n if (this.options.verbatimFields && this.options.verbatimFields.find(name => typeof name === 'string' ? (name === field) : field.match(name))) return 'verbatim'\n\n let mode: ParseMode = 'literal'\n for (const [selected, fields] of Object.entries(this.fieldMode)) {\n if (fields.find(match => typeof match === 'string' ? field === match : field.match(match))) mode = <ParseMode> selected\n }\n return mode\n }\n\n private restoreMarkup(s: string): string {\n if (!s.includes('\\x0E')) return s\n\n const restored: string[] = [s.replace(/\\x0E\\/?ncx\\x0F/ig, '')]\n while (restored[0] !== restored[1]) {\n restored.unshift(restored[0].replace(collapsable, '$2'))\n }\n\n return restored[0]\n .replace(/(\\x0Ep\\x0F\\s*){2,}/ig, '\\x0Ep\\x0F')\n .replace(/\\s*(\\x0E\\/p\\x0F){2,}/ig, '\\x0E/p\\x0F')\n .replace(/\\x0Eenquote\\x0F/ig, '\\u201C').replace(/\\x0E\\/enquote\\x0F/ig, '\\u201D')\n .replace(/\\x0Esc\\x0F/ig, '<span style=\"font-variant:small-caps;\">').replace(/\\x0E\\/sc\\x0F/ig, '</span>')\n .replace(/\\x0Enc\\x0F/ig, '<span class=\"nocase\">').replace(/\\x0E\\/nc\\x0F/ig, '</span>')\n .replace(/\\x0E/ig, '<').replace(/\\x0F/ig, '>')\n }\n\n private stringField(field: string, value: string, mode: string, guessSC: boolean): string {\n if (field === 'crossref') return value\n\n if (FieldAction.parseInt.includes(field) && value.trim().match(/^-?\\d+$/)) return `${parseInt(value)}`\n\n if (this.english && mode === 'title') {\n value = toSentenceCase(value, {\n preserveQuoted: this.options.sentenceCase && this.options.sentenceCase.preserveQuoted,\n subSentenceCapitalization: this.options.sentenceCase && this.options.sentenceCase.subSentence,\n markup: /\\x0E\\/?([a-z]+)\\x0F/ig,\n nocase: /\\x0E(ncx?)\\x0F.*?\\x0E\\/\\1\\x0F/ig,\n guess: guessSC,\n })\n\n let cancel = (_match: string, stripped: string) => stripped\n switch (this.options.caseProtection) {\n case 'strict':\n cancel = (match: string, _stripped: string) => match\n break\n case 'as-needed':\n cancel = (match: string, stripped: string) => {\n const words: Token[] = tokenize(stripped, /\\x0E\\/?([a-z]+)\\x0F/ig)\n return words.find(w => w.shape.match(/^(?!.*X).*x.*$/)) ? match : this.wrap(stripped, 'ncx')\n }\n break\n }\n\n return value.replace(/\\x0Enc\\x0F(.*?)\\x0E\\/nc\\x0F/ig, cancel)\n }\n\n return value\n }\n\n private commaSeparatedCreator(ast: Root): { parts: Root[]; extended?: Record<string, Root> } {\n const result: { parts: Root[]; extended?: Record<string, Root> } = {\n parts: [],\n }\n\n if (!ast.content.find(node => node.type === 'string' && node.content === ',')) return result\n\n result.parts = this.split(ast, /^,$/, /(&)/)\n result.extended = {}\n for (const part of result.parts) {\n const start = part.content[0]?.type === 'whitespace' ? 1 : 0\n let signature = part.content\n .slice(start, start + 4)\n .map((node, i) => node._renderInfo!.mode === 'text' && node.type === 'string' ? node.content.replace(i % 2 ? /[^=-]/g : /[^a-z]/gi, '.') : '.')\n .join('')\n if (signature.match(/^[a-z]+(-[a-z]+)?=/i)) {\n signature = signature.replace(/=.*/, '').toLowerCase()\n result.extended[signature] = { type: 'root', content: part.content.slice(signature.includes('-') ? start + 4 : start + 2) }\n }\n else {\n delete result.extended\n break\n }\n }\n return result\n }\n\n private field(entry: Entry, field: string, value: string) {\n const mode: ParseMode = entry.mode[field] = this.mode(field)\n const caseProtection = {\n present: false,\n intuitive: 0, // a lot of people don't realise `some text \\textit{in italics}` will protect 'in italics'\n }\n\n const ast: Root = LatexPegParser.parse(value)\n\n if (this.options.removeOuterBraces!.includes(field) && ast.content.length === 1 && ast.content[0].type === 'group') {\n ast.content = ast.content[0].content\n }\n\n if (mode === 'verbatim') { // &^%@#&^%@# idiots wrapping verbatim fields\n entry.fields[field] = printRaw(ast)\n return\n }\n\n if (this.english && mode === 'title') {\n let root = [...ast.content]\n while (root.length) {\n const node = root.shift()!\n\n // only root groups offer case protecten -- but it may be as an macro arg, so mark here before gobbling\n if (this.protect(node)) node._renderInfo = { root: true }\n\n // environments are considered root when at root\n if (node.type === 'environment') root = [...root, ...node.content]\n }\n }\n\n // pass 0 -- register parse mode\n visit(ast, (node, info) => {\n if (!node._renderInfo) node._renderInfo = {}\n\n node._renderInfo!.mode = info.context.inMathMode ? 'math' : 'text'\n\n // if (info.context.inMathMode || info.context.hasMathModeAncestor) return\n\n if (mode === 'title' && node.type === 'inlinemath' && !info.parents.find(p => p._renderInfo!.protectCase)) node._renderInfo!.protectCase = true\n\n if (!info.context.inMathMode) {\n if (mode === 'title' && node._renderInfo!.root && (node.type !== 'group' || node.content[0].type !== 'macro')) {\n node._renderInfo!.protectCase = true\n if (node.type === 'group') {\n caseProtection.present = true\n caseProtection.intuitive += 1\n }\n }\n\n if (node.type === 'macro' && typeof node.escapeToken !== 'string') node.escapeToken = '\\\\'\n\n if (node.type === 'environment' && node.env === 'em') node._renderInfo!.emph = true\n }\n })\n\n if (this.options.raw) {\n switch (mode) {\n case 'creatorlist':\n entry.fields[field] = this.split(ast, /^and$/i, /(^& | & | &$)/)\n .map(cr => {\n const { parts, extended } = this.commaSeparatedCreator(cr)\n if (parts.length === 2 && !extended) {\n return this.trimCreator({ lastName: printRaw(parts[0]), firstName: printRaw(parts[1]) })\n }\n\n if (!parts.length) {\n const nameparts = this.split(ast, /^$/, /( )/)\n if (nameparts.length === 2) {\n return this.trimCreator({\n lastName: printRaw(nameparts[1]),\n firstName: printRaw(nameparts[0]),\n })\n }\n }\n\n return { name: printRaw(cr) }\n }) as unknown as string\n return\n case 'literallist':\n entry.fields[field] = this.split(ast, /^and$/i, /(^& | & | &$)/)\n .map(elt => printRaw(elt)) as unknown as string // pacify typescript\n return\n default:\n entry.fields[field] = printRaw(ast)\n return\n }\n }\n\n // pass 1 -- mark & normalize\n visit(ast, (nodes, info) => {\n const compacted: Node[] = []\n let inif = 0\n while (nodes.length) {\n const ligatureResult = this.ligature(nodes)\n if (ligatureResult) {\n compacted.push(ligatureResult)\n continue\n }\n\n const node = nodes.shift()!\n\n if (node.type === 'macro' && node.content === 'ifdefined') {\n inif += 1\n continue\n }\n else if (node.type === 'macro' && node.content === 'else') {\n continue\n }\n else if (node.type === 'macro' && node.content === 'fi') {\n inif = Math.max(inif - 1, 0)\n continue\n }\n else if (inif) {\n continue\n }\n\n const nargs = node.type === 'macro'\n ? narguments[node.content] || narguments[`${info.context.inMathMode ? 'math' : 'text'}\\t${node.content}`]\n : 0\n if (node.type === 'macro' && nargs) {\n const args = Array(nargs).fill(undefined).map(_i => this.argument(nodes, <Macro> node)).filter((arg): arg is Argument => arg !== null)\n node.args = args\n if (node.content.match(/^(url|href)$/) && args.length) {\n let url: Node[] = args[0].content\n if (url.length === 1 && url[0].type === 'group') url = url[0].content\n args[0] = this.wraparg({ type: 'string', content: printRaw(url), _renderInfo: { mode: url[0]._renderInfo!.mode } }, node)\n }\n caseProtection.intuitive -= args.filter(arg => arg.content[0].type === 'group' && arg.content[0]._renderInfo!.protectCase).length\n }\n else if (node.type === 'macro' && node.content.match(/^[a-z]+$/i) && nodes[0]?.type === 'whitespace') {\n nodes.shift()\n }\n\n compacted.push(node)\n }\n\n if (!info.context.inMathMode) {\n // feed-forward inline macros\n for (const [macro, markup] of Object.entries({ em: 'emph', it: 'emph', sl: 'emph', bf: 'bold', sc: 'smallCaps', tt: 'code' })) {\n if (info.parents.find(p => p._renderInfo?.[markup])) continue\n\n compacted.forEach((markup_node, i) => {\n if (markup_node.type === 'macro' && markup_node.content === macro) {\n compacted.slice(i + 1).forEach(n => n._renderInfo![markup] = true)\n }\n })\n }\n }\n\n nodes.push(...compacted)\n }, { test: Array.isArray, includeArrays: true })\n\n replaceNode(ast, (node, _info) => {\n if (node.type !== 'macro') return\n\n if (node.escapeToken && combining.tounicode[node.content]) {\n let arg: Node\n // no args, args of zero length, or first arg has no content\n if (!node.args || node.args.length === 0 || node.args[0].content.length === 0) {\n arg = { type: 'string', content: ' ', _renderInfo: {} }\n }\n else if (node.args.length !== 1 || node.args[0].content.length !== 1) {\n return\n }\n else {\n arg = node.args[0].content[0]\n }\n\n if (arg.type === 'group') {\n switch (arg.content.length) {\n case 0:\n arg = { type: 'string', content: ' ', _renderInfo: {} }\n break\n case 1:\n arg = arg.content[0]\n break\n default:\n return\n }\n }\n\n switch (arg.type) {\n case 'verbatim':\n case 'string':\n return { type: 'string', content: `${arg.content}${combining.tounicode[node.content]}`, _renderInfo: {} }\n case 'macro':\n // Legacy input can encode an accented base as an unknown control word, for example\n // `\\'{\\a}`. The outer accent is recognized, but `\\a` has no Unicode mapping. Treat\n // only that argument-free, single-letter payload as text here; ordinary unknown\n // macros must still go through the unsupported-command handler unchanged.\n if (arg.escapeToken && /^[A-Za-z]$/.test(arg.content) && !arg.args?.length) {\n const command = `${arg.escapeToken}${arg.content}`\n if (!(command in latex2unicodemap)) {\n return { type: 'string', content: `${arg.content}${combining.tounicode[node.content]}`, _renderInfo: {} }\n }\n }\n return\n default:\n return\n }\n }\n\n let latex = `${node.escapeToken}${node.content}`\n latex += (node.args || []).map(arg => printRaw(this.argtogroup(arg))).join('')\n if (latex in latex2unicodemap) return { type: 'string', content: latex2unicode(latex, node), _renderInfo: {} }\n // return null to delete\n })\n\n switch (mode) {\n case 'creatorlist':\n entry.fields[field] = this.split(ast, /^and$/i, /(^& | & | &$)/)\n .map(cr => this.parseCreator(cr))\n .filter(cr => Object.keys(cr).length) as unknown as string // pacify typescript\n break\n case 'literallist':\n entry.fields[field] = this.split(ast, /^and$/i, /(^& | & | &$)/)\n .map(elt => this.stringify(elt, { mode: 'literal' }).trim()) as unknown as string // pacify typescript\n break\n default:\n entry.fields[field] = this.stringField(\n field,\n this.stringify(ast, { mode }),\n mode,\n !!(this.options.sentenceCase && this.options.sentenceCase.guess), // && (!caseProtection.present || caseProtection.intuitive > 0)\n ) as unknown as string\n break\n }\n\n // recursively restores markup in string content. 'as string' is just here to pacify typescript\n entry.fields[field] = JSON.parse(JSON.stringify(entry.fields[field], (k, v) => (typeof v === 'string' ? this.restoreMarkup(v) : v) as string))\n }\n\n private reset(options: Options = {}) {\n if (options.sentenceCase === false) {\n options = {\n ...options,\n english: false,\n sentenceCase: {\n guess: false,\n subSentence: false,\n preserveQuoted: false,\n },\n }\n }\n\n this.options = merge(options, {\n caseProtection: 'as-needed',\n applyCrossRef: options.applyCrossRef ?? true,\n fieldMode: {},\n english: English,\n sentenceCase: {\n guess: true,\n preserveQuoted: true,\n },\n })\n\n if (this.options.caseProtection === true) this.options.caseProtection = 'as-needed'\n\n if (this.options.verbatimFields) this.options.verbatimFields = this.options.verbatimFields.map(f => typeof f === 'string' ? f.toLowerCase() : new RegExp(f.source, f.flags + (f.flags.includes('i') ? '' : 'i')))\n\n if (typeof this.options.english === 'boolean') this.options.english = this.options.english ? English : []\n this.options.english = (this.options.english as string[]).map(langid => langid.toLowerCase())\n\n this.fieldMode = Object.entries(FieldMode).reduce((acc: typeof FieldMode, [mode, test]: [string, (RegExp | string)[]]) => {\n const strings = test.filter(fieldname_or_regex => typeof fieldname_or_regex === 'string' && !this.options.fieldMode![fieldname_or_regex])\n const regexes = test.filter(fieldname_or_regex => typeof fieldname_or_regex !== 'string')\n acc[mode] = [...strings, ...regexes]\n return acc\n }, <typeof FieldMode> {})\n for (const [field, mode] of Object.entries(this.options.fieldMode!)) {\n this.fieldMode[mode].unshift(field)\n }\n\n if (!this.options.removeOuterBraces) {\n this.options.removeOuterBraces = [\n ...FieldAction.removeOuterBraces,\n ...this.fieldMode.title,\n ...this.fieldMode.verbatim,\n ].filter(field => typeof field === 'string')\n }\n\n if (options.unsupported !== undefined && !['tex', 'text', 'ignore', 'throw'].includes(options.unsupported)) {\n throw new TypeError('unsupported must be tex, text, ignore, or throw')\n }\n\n this.bib = {\n errors: [],\n entries: [],\n comments: [],\n strings: {},\n preambles: [],\n jabref: new JabRef.JabRefMetadata(),\n }\n }\n\n private reparse(verbatim: bibtex.Entry) {\n let langid: string = (verbatim.fields.langid || verbatim.fields.hyphenation || '').toLowerCase()\n if (!langid && this.options.languageAsLangid && verbatim.fields.language) langid = verbatim.fields.language.toLowerCase()\n this.english = (<string[]> this.options.english).includes(langid)\n\n const entry: Entry = this.current = {\n type: verbatim.type,\n key: verbatim.key,\n fields: {},\n mode: {},\n input: verbatim.input,\n }\n let keywords: string[] = [] // OMG #783\n try {\n for (let [field, value] of Object.entries(verbatim.fields)) {\n if (!value.trim()) continue\n\n /*\n if (this.options.raw && !this.options.removeOuterBraces.includes(field)) {\n entry.fields[field] = value.trim()\n entry.mode[field] = 'verbatim'\n continue\n }\n */\n\n if (field.match(/^keywords([+]duplicate-\\d+)?$/)) field = 'keywords' // #873\n\n this.field(entry, field, value)\n\n if (field === 'keywords') { // #873\n keywords = [...keywords, ...(entry.fields.keywords as unknown as string).split(/\\s*[,;]\\s*/)].map((k: string) => k.trim()).filter(k => k)\n delete entry.fields.keywords\n }\n\n if (!this.options.raw && typeof entry.fields[field] === 'string') {\n entry.fields[field] = entry.fields[field].trim()\n if (field === 'month') entry.fields[field] = Month[entry.fields[field].toLowerCase()] || entry.fields[field]\n }\n }\n\n if (keywords.length) {\n entry.fields.keywords = keywords\n entry.mode.keywords = 'verbatimlist'\n }\n\n this.bib.entries.push(entry)\n }\n catch (err) {\n if (err instanceof UnsupportedError) throw err\n this.bib.errors.push({ error: `${err.message}\\n${entry.input}`, input: entry.input })\n }\n }\n\n private content(tex: string) {\n const entry: Entry = { key: '', type: '', fields: {}, mode: {}, input: tex }\n const english = this.english\n this.english = false\n this.field(entry, 'tex', tex)\n this.english = english\n return entry.fields.tex\n }\n\n private prep(base: bibtex.Library) {\n for (const preamble of base.preambles) {\n try {\n this.content(preamble)\n }\n catch (err) {\n if (err instanceof UnsupportedError) throw err\n }\n }\n for (const [k, v] of Object.entries(base.strings)) {\n this.bib.strings[k] = this.content(v)\n }\n }\n\n private finalize(base: bibtex.Library) {\n if (this.options.applyCrossRef) {\n const entries: Partial<Record<string, Entry>> = {}\n for (const entry of this.bib.entries) {\n if (entry.key) entries[entry.key.toUpperCase()] = entry\n }\n\n const order: string[] = []\n for (const entry of this.bib.entries) {\n if (!entry.key || typeof entry.fields.crossref !== 'string') continue\n\n const crossref = entry.fields.crossref.toUpperCase()\n if (!entries[crossref]) continue\n\n const key = entry.key.toUpperCase()\n // Topological sort: parents are unshifted to the front, children pushed\n // to the back. Because a parent may itself be a child of another entry,\n // unshift guarantees every ancestor appears before all of its descendants\n // regardless of the order entries appear in the .bib file. Duplicate\n // entries are skipped so a shared parent is only processed once.\n if (!order.includes(crossref)) order.unshift(crossref)\n if (!order.includes(key)) order.push(key)\n }\n\n for (const key of order) {\n const child = entries[key.toUpperCase()]!\n const parent = entries[child.fields.crossref?.toUpperCase()]\n if (!parent) continue\n\n for (const mappings of [CrossRef[child.type], CrossRef['*']].filter(m => m)) {\n for (const mapping of [mappings[parent.type], mappings['*']].filter(m => m)) {\n for (const [childfield, parentfield] of Object.entries(mapping)) {\n if (!child.fields[childfield] && parent.fields[parentfield]) {\n child.fields[childfield] = parent.fields[parentfield]\n\n child.crossref ??= {}\n child.crossref[childfield] = { parent: parent.key, field: parentfield }\n }\n }\n\n for (const field of (Allowed[child.type] || [])) {\n if (NoCrossRef.includes(field)) continue\n\n if (!child.fields[field] && parent.fields[field]) {\n child.fields[field] = parent.fields[field]\n\n child.crossref ??= {}\n child.crossref[field] = { parent: parent.key, field }\n }\n }\n }\n }\n }\n }\n\n const { comments, jabref } = JabRef.parse(base.comments)\n this.bib.comments = comments\n this.bib.jabref = jabref\n\n this.bib.preambles = base.preambles\n this.bib.errors = [...base.errors, ...this.bib.errors]\n }\n\n public parse(input: string, options: Options = {}): Library {\n this.reset(options)\n\n const base = bibtex.parse(input, { strings: options.strings })\n\n this.prep(base)\n\n for (const entry of base.entries) {\n this.reparse(entry)\n }\n\n this.finalize(base)\n return this.bib\n }\n\n public async parseAsync(input: string, options: Options = {}): Promise<Library> {\n this.reset(options)\n\n const base = await bibtex.promises.parse(input, { strings: options.strings })\n\n this.prep(base)\n\n let n = 1\n for (const entry of base.entries) {\n this.reparse(entry)\n if ((n++ % 1000) === 0) await playnice()\n }\n\n this.finalize(base)\n return this.bib\n }\n}\n\n/** Parses BibTeX or BibLaTeX source into a normalized library. */\nexport function parse(input: string, options: Options = {}): Library {\n const parser = new BibTeXParser()\n return parser.parse(input, options)\n}\n\n/** Asynchronous variant of {@link parse}, yielding periodically for large libraries. */\nexport async function parseAsync(input: string, options: Options = {}): Promise<Library> {\n const parser = new BibTeXParser()\n return await parser.parseAsync(input, options)\n}\n"],
5
+ "mappings": ";;;AAEA,SAAS,sBAAsB;AAC/B,SAAS,gBAAgB;AACzB,SAAS,mBAAmB;AAC5B,SAAS,aAAa;AACtB,SAAS,WAAW,iBAAiB,wBAAwB;AAC7D,YAAY,YAAY;AACxB,YAAY,YAAY;AAExB,SAAS,sBAAsB;AAG/B,SAAoB,SAA0B,aAAqB;AA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AAA,EAEO,MAAM,OAAe,UAAmB,CAAC,GAAY;AAC1D,SAAK,MAAM,OAAO;AAElB,UAAM,OAAO,OAAO,MAAM,OAAO,EAAE,SAAS,QAAQ,QAAQ,CAAC;AAE7D,SAAK,KAAK,IAAI;AAEd,eAAW,SAAS,KAAK,SAAS;AAChC,WAAK,QAAQ,KAAK;AAAA,IACpB;AAEA,SAAK,SAAS,IAAI;AAClB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAa,WAAW,OAAe,UAAmB,CAAC,GAAqB;AAC9E,SAAK,MAAM,OAAO;AAElB,UAAM,OAAO,MAAM,OAAO,SAAS,MAAM,OAAO,EAAE,SAAS,QAAQ,QAAQ,CAAC;AAE5E,SAAK,KAAK,IAAI;AAEd,QAAI,IAAI;AACR,eAAW,SAAS,KAAK,SAAS;AAChC,WAAK,QAAQ,KAAK;AAClB,UAAK,MAAM,QAAU,EAAG,OAAM,SAAS;AAAA,IACzC;AAEA,SAAK,SAAS,IAAI;AAClB,WAAO,KAAK;AAAA,EACd;AACF;AAGO,SAASC,OAAM,OAAe,UAAmB,CAAC,GAAY;AACnE,QAAM,SAAS,IAAI,aAAa;AAChC,SAAO,OAAO,MAAM,OAAO,OAAO;AACpC;AAGA,eAAsB,WAAW,OAAe,UAAmB,CAAC,GAAqB;AACvF,QAAM,SAAS,IAAI,aAAa;AAChC,SAAO,MAAM,OAAO,WAAW,OAAO,OAAO;AAC/C;",
6
6
  "names": ["toSentenceCase", "tokenize", "parse"]
7
7
  }
@@ -1,4 +1,14 @@
1
- function decode(s, sep = ";") {
1
+ var __defProp = Object.defineProperty;
2
+ var __typeError = (msg) => {
3
+ throw TypeError(msg);
4
+ };
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
8
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
9
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
+ var _groups;
11
+ function decode(s = "", sep = ";") {
2
12
  s = s.replace(/\r?\n/g, "");
3
13
  let pos = 0;
4
14
  const records = [""];
@@ -18,11 +28,36 @@ function decode(s, sep = ";") {
18
28
  }
19
29
  return records.reverse().filter((record) => record);
20
30
  }
31
+ class JabRefMetadata {
32
+ constructor(data = {}) {
33
+ __privateAdd(this, _groups, /* @__PURE__ */ new Map());
34
+ /**
35
+ * The root groups. You can find the nested groups in their `groups` property
36
+ */
37
+ __publicField(this, "root", []);
38
+ this.root = data.root ?? [];
39
+ for (const field of ["fileDirectory", "groupsversion", "databaseType"]) {
40
+ if (data[field] !== void 0) Object.assign(this, { [field]: data[field] });
41
+ }
42
+ const index = (groups) => {
43
+ for (const group of groups) {
44
+ if (!__privateGet(this, _groups).has(group.name)) __privateGet(this, _groups).set(group.name, group);
45
+ index(group.groups);
46
+ }
47
+ };
48
+ index(this.root);
49
+ }
50
+ /** Populates JabRef 3.8+ memberships in `root` by group name; duplicate names select the first node. */
51
+ addEntry(name, key) {
52
+ const group = __privateGet(this, _groups).get(name);
53
+ if (!group) return false;
54
+ if (!group.entries.includes(key)) group.entries.push(key);
55
+ return true;
56
+ }
57
+ }
58
+ _groups = new WeakMap();
21
59
  function parse(comments) {
22
- const result = {
23
- root: [],
24
- groups: {}
25
- };
60
+ const result = new JabRefMetadata();
26
61
  const levels = [];
27
62
  const decoded = {
28
63
  fileDirectory: null,
@@ -60,7 +95,6 @@ function parse(comments) {
60
95
  entries: keys,
61
96
  groups: []
62
97
  };
63
- result.groups[name] = result.groups[name] || group;
64
98
  if (levels.length < level) {
65
99
  levels.push(group);
66
100
  } else {
@@ -84,9 +118,10 @@ function parse(comments) {
84
118
  }
85
119
  }
86
120
  }
87
- return { comments, jabref: result };
121
+ return { comments, jabref: new JabRefMetadata(result) };
88
122
  }
89
123
  export {
124
+ JabRefMetadata,
90
125
  parse
91
126
  };
92
127
  //# sourceMappingURL=jabref.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../jabref.ts"],
4
- "sourcesContent": ["function decode(s, sep = ';') {\n s = s.replace(/\\r?\\n/g, '')\n let pos = 0\n const records = ['']\n while (pos < s.length) {\n switch (s[pos]) {\n case '\\\\':\n pos++\n records[0] += s[pos]\n break\n\n case sep:\n records.unshift('')\n break\n\n default:\n records[0] += s[pos]\n }\n pos++\n }\n return records.reverse().filter(record => record)\n}\n\n/**\n * A JabRef group.\n */\nexport interface Group {\n /**\n * the group name\n */\n name: string\n\n /**\n * The citation keys which are specified to belong to this group, after intersection calculation has been applied\n */\n entries: string[]\n\n /**\n * Sub-groups under this group\n */\n groups: Group[]\n}\n\nexport interface JabRefMetadata {\n /**\n * The root groups. You can find the nested groups in their `groups` property\n */\n root: Group[]\n\n /**\n * JabRef since 3.8 has changed their groups format. Entries have a `groups` field which has the names of the groups they belong to -- this name does not have to be unique in the groups hierarchy so if you\n * have multiple groups with the same name, it's not well-defined where the entries should end up. This property gives you the for each group name the first time the group showed up in the hierarchy. Note that\n * keys from the entries themselves have *not* yet been added to the [[Group]]s. You need to combine this yourself as you're parsing the entries.\n */\n groups: { [key: string]: Group }\n\n /**\n * The base path for file paths\n */\n fileDirectory?: string\n\n /**\n * The JabRef metadata format version\n */\n groupsversion?: number\n\n /**\n * The JabRef metadata database type\n */\n databaseType?: string\n}\n\n/**\n * Import the JabRef groups from the `@string` comments in which they were stored. You would typically pass the comments parsed by [[bibtex.parse]] in here.\n *\n * JabRef knows several group types, and this parser parses most, but not all of them:\n *\n * * independent group: the keys listed in the group are the entries that are considered to belong to it\n * * intersection: the keys listed in the group are considered to belong to the group if they're also in the parent group\n * * union: the keys listed in the group are considered to belong to the group, and also the keys that are in the parent group\n * * query: not supported by this parser\n */\nexport function parse(comments: string[]): { comments: string[]; jabref: JabRefMetadata } {\n const result: JabRefMetadata = {\n root: [],\n groups: {},\n }\n\n const levels: Group[] = []\n\n const decoded = {\n fileDirectory: null as string[] | null,\n groupsversion: null as string[] | null,\n groupstree: null as string[] | null,\n grouping: null as string[] | null,\n databaseType: null as string[] | null,\n }\n\n comments = comments.filter(comment => {\n const m = comment.match(/^jabref-meta:\\s*([^:]+):([\\s\\S]*)/) // use \\s\\S because mozilla doesn't understand /s\n if (m) {\n decoded[m[1]] = decode(m[2])\n return false\n }\n return true\n })\n\n if (decoded.groupsversion) result.groupsversion = parseInt(decoded.groupsversion[0].trim()) // eslint-disable-line @typescript-eslint/no-unsafe-argument\n if (decoded.fileDirectory) result.fileDirectory = decoded.fileDirectory[0]\n if (decoded.databaseType) result.databaseType = decoded.databaseType[0]\n\n for (const tree of ['groupstree', 'grouping']) {\n if (!decoded[tree]) continue\n\n for (const encoded of decoded[tree]) {\n const fields = decode(encoded)\n\n const level_type_name = decode(fields.shift(), ':')\n const m = /^([0-9]+) (.+)/.exec(level_type_name[0])\n if (!m) break\n\n const level = parseInt(m[1])\n const type = m[2] // test for StaticGroup?\n\n if (type === 'AllEntriesGroup') continue // root\n\n const name = level_type_name[1]\n const intersection = decode(fields.shift())[0]\n const keys = tree === 'grouping' ? [] : fields.map(field => decode(field)[0])\n\n const group = {\n name,\n entries: keys,\n groups: [],\n }\n\n result.groups[name] = result.groups[name] || group\n\n if (levels.length < level) {\n levels.push(group)\n }\n else {\n levels[level - 1] = group\n }\n\n if (level === 1) {\n result.root.push(group)\n }\n else {\n const parent: Group = levels[level - 2]\n switch (intersection) {\n case '0': // independent\n break\n case '1': // intersect\n group.entries = group.entries.filter(key => parent.entries.includes(key))\n break\n case '2': // union\n group.entries = group.entries.concat(parent.entries.filter(key => !group.entries.includes(key)))\n break\n }\n\n levels[level - 2].groups.push(group)\n }\n }\n }\n\n return { comments, jabref: result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= ';') {\n s = s.replace(/\\r?\\n/g, '')\n let pos = 0\n const records = ['']\n while (pos < s.length) {\n switch (s[pos]) {\n case '\\\\':\n pos++\n records[0] += s[pos]\n break\n\n case sep:\n records.unshift('')\n break\n\n default:\n records[0] += s[pos]\n }\n pos++\n }\n return records.reverse().filter(record => record)\n}\n\n/**\n * A JabRef group.\n */\nexport interface Group {\n /**\n * the group name\n */\n name: string\n\n /**\n * The citation keys which are specified to belong to this group, after intersection calculation has been applied\n */\n entries: string[]\n\n /**\n * Sub-groups under this group\n */\n groups: Group[]\n}\n\nexport class JabRefMetadata {\n #groups = new Map<string, Group>()\n\n /**\n * The root groups. You can find the nested groups in their `groups` property\n */\n root: Group[] = []\n\n /**\n * The base path for file paths\n */\n declare fileDirectory?: string\n\n /**\n * The JabRef metadata format version\n */\n declare groupsversion?: number\n\n /**\n * The JabRef metadata database type\n */\n declare databaseType?: string\n\n constructor(data: Partial<Pick<JabRefMetadata, 'root' | 'fileDirectory' | 'groupsversion' | 'databaseType'>> = {}) {\n this.root = data.root ?? []\n for (const field of ['fileDirectory', 'groupsversion', 'databaseType'] as const) {\n if (data[field] !== undefined) Object.assign(this, { [field]: data[field] })\n }\n const index = (groups: Group[]) => {\n for (const group of groups) {\n if (!this.#groups.has(group.name)) this.#groups.set(group.name, group)\n index(group.groups)\n }\n }\n index(this.root)\n }\n\n /** Populates JabRef 3.8+ memberships in `root` by group name; duplicate names select the first node. */\n addEntry(name: string, key: string): boolean {\n const group = this.#groups.get(name)\n if (!group) return false\n if (!group.entries.includes(key)) group.entries.push(key)\n return true\n }\n}\n\n/**\n * Import the JabRef groups from the `@string` comments in which they were stored. You would typically pass the comments parsed by [[bibtex.parse]] in here.\n *\n * JabRef knows several group types, and this parser parses most, but not all of them:\n *\n * * independent group: the keys listed in the group are the entries that are considered to belong to it\n * * intersection: the keys listed in the group are considered to belong to the group if they're also in the parent group\n * * union: the keys listed in the group are considered to belong to the group, and also the keys that are in the parent group\n * * query: not supported by this parser\n */\nexport function parse(comments: string[]): { comments: string[]; jabref: JabRefMetadata } {\n const result = new JabRefMetadata()\n\n const levels: Group[] = []\n\n const decoded: Record<string, string[] | null> = {\n fileDirectory: null as string[] | null,\n groupsversion: null as string[] | null,\n groupstree: null as string[] | null,\n grouping: null as string[] | null,\n databaseType: null as string[] | null,\n }\n\n comments = comments.filter(comment => {\n const m = comment.match(/^jabref-meta:\\s*([^:]+):([\\s\\S]*)/) // use \\s\\S because mozilla doesn't understand /s\n if (m) {\n decoded[m[1]] = decode(m[2])\n return false\n }\n return true\n })\n\n if (decoded.groupsversion) result.groupsversion = parseInt(decoded.groupsversion[0].trim()) // eslint-disable-line @typescript-eslint/no-unsafe-argument\n if (decoded.fileDirectory) result.fileDirectory = decoded.fileDirectory[0]\n if (decoded.databaseType) result.databaseType = decoded.databaseType[0]\n\n for (const tree of ['groupstree', 'grouping']) {\n if (!decoded[tree]) continue\n\n for (const encoded of decoded[tree]) {\n const fields = decode(encoded)\n\n const level_type_name = decode(fields.shift(), ':')\n const m = /^([0-9]+) (.+)/.exec(level_type_name[0])\n if (!m) break\n\n const level = parseInt(m[1])\n const type = m[2] // test for StaticGroup?\n\n if (type === 'AllEntriesGroup') continue // root\n\n const name = level_type_name[1]\n const intersection = decode(fields.shift())[0]\n const keys = tree === 'grouping' ? [] : fields.map(field => decode(field)[0])\n\n const group = {\n name,\n entries: keys,\n groups: [],\n }\n\n if (levels.length < level) {\n levels.push(group)\n }\n else {\n levels[level - 1] = group\n }\n\n if (level === 1) {\n result.root.push(group)\n }\n else {\n const parent: Group = levels[level - 2]\n switch (intersection) {\n case '0': // independent\n break\n case '1': // intersect\n group.entries = group.entries.filter(key => parent.entries.includes(key))\n break\n case '2': // union\n group.entries = group.entries.concat(parent.entries.filter(key => !group.entries.includes(key)))\n break\n }\n\n levels[level - 2].groups.push(group)\n }\n }\n }\n\n return { comments, jabref: new JabRefMetadata(result) }\n}\n"],
5
+ "mappings": ";;;;;;;;;AAAA;AAAA,SAAS,O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,MACX;AAEA,UAAI,OAAO,SAAS,OAAO;AACzB,eAAO,KAAK,KAAK;AAAA,MACnB,OACK;AACH,eAAO,QAAQ,CAAC,IAAI;AAAA,MACtB;AAEA,UAAI,UAAU,GAAG;AACf,eAAO,KAAK,KAAK,KAAK;AAAA,MACxB,OACK;AACH,cAAM,SAAgB,OAAO,QAAQ,CAAC;AACtC,gBAAQ,cAAc;AAAA,UACpB,KAAK;AACH;AAAA,UACF,KAAK;AACH,kBAAM,UAAU,MAAM,QAAQ,OAAO,SAAO,OAAO,QAAQ,SAAS,GAAG,CAAC;AACxE;AAAA,UACF,KAAK;AACH,kBAAM,UAAU,MAAM,QAAQ,OAAO,OAAO,QAAQ,OAAO,SAAO,CAAC,MAAM,QAAQ,SAAS,GAAG,CAAC,CAAC;AAC/F;AAAA,QACJ;AAEA,eAAO,QAAQ,CAAC,EAAE,OAAO,KAAK,KAAK;AAAA,MACrC;AAAA,IACF;AAAA,EACF;AAEA,SAAO,EAAE,UAAU,QAAQ,IAAI,eAAe,MAAM,EAAE;AACxD;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,7 @@
1
1
  import * as JabRef from './jabref.js';
2
2
  import * as bibtex from './verbatim.js';
3
- export type { Group as JabRefGroup, JabRefMetadata } from './jabref.js';
3
+ export type { Group as JabRefGroup } from './jabref.js';
4
+ export { JabRefMetadata } from './jabref.js';
4
5
  export type { ParseError } from './verbatim.js';
5
6
  /** Parses BibTeX without interpreting field contents as LaTeX. */
6
7
  export { Library as VerbatimLibrary, parse as parseVerbatim } from './verbatim.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,YAAY,EAAE,KAAK,IAAI,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACvE,YAAY,EAAE,UAAU,EAAE,MA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,MAAM,CAAC,GAAG,MAAM,CAAA;IAEzC;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED,gDAAgD;AAChD,MAAM,WAAW,OAAO;IACtB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED,eAAO,MAAM,SAAS;;;;;;CA0DrB,CAAA;AAED,yDAAyD;AACzD,MAAM,MAAM,SAAS,GAAG,MAAM,OAAO,SAAS,GAAG,SAAS,GAAG,cAAc,CAAA;AAE3E,eAAO,MAAM,OAAO,UA0BnB,CAAA;AA2oCD,kEAAkE;AAClE,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,OAAY,GAAG,OAAO,CAGnE;AAED,wFAAwF;AACxF,wBAAsB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,OAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAGvF"}
@@ -15,19 +15,12 @@ export interface Group {
15
15
  */
16
16
  groups: Group[];
17
17
  }
18
- export interface JabRefMetadata {
18
+ export declare class JabRefMetadata {
19
+ #private;
19
20
  /**
20
21
  * The root groups. You can find the nested groups in their `groups` property
21
22
  */
22
23
  root: Group[];
23
- /**
24
- * JabRef since 3.8 has changed their groups format. Entries have a `groups` field which has the names of the groups they belong to -- this name does not have to be unique in the groups hierarchy so if you
25
- * have multiple groups with the same name, it's not well-defined where the entries should end up. This property gives you the for each group name the first time the group showed up in the hierarchy. Note that
26
- * keys from the entries themselves have *not* yet been added to the [[Group]]s. You need to combine this yourself as you're parsing the entries.
27
- */
28
- groups: {
29
- [key: string]: Group;
30
- };
31
24
  /**
32
25
  * The base path for file paths
33
26
  */
@@ -40,6 +33,9 @@ export interface JabRefMetadata {
40
33
  * The JabRef metadata database type
41
34
  */
42
35
  databaseType?: string;
36
+ constructor(data?: Partial<Pick<JabRefMetadata, 'root' | 'fileDirectory' | 'groupsversion' | 'databaseType'>>);
37
+ /** Populates JabRef 3.8+ memberships in `root` by group name; duplicate names select the first node. */
38
+ addEntry(name: string, key: string): boolean;
43
39
  }
44
40
  /**
45
41
  * Import the JabRef groups from the `@string` comments in which they were stored. You would typically pass the comments parsed by [[bibtex.parse]] in here.