From 9c2a0e505472c43d384f3cc78543ad90877b7c3d Mon Sep 17 00:00:00 2001 From: "Thomas F. K. Jorna" Date: Thu, 9 Mar 2023 21:34:24 +0100 Subject: [PATCH] fix: enter a new era --- libs/citations/apa-parser/src/index.ts | 2 +- .../citations/crossref-json/tsconfig.lib.json | 2 +- libs/citations/crossref-to-csl/src/index.ts | 2 +- libs/citations/csl-consolidate/src/index.ts | 2 +- libs/citations/csl-to-biblatex/src/index.ts | 2 +- .../src/lib/csl-to-biblatex.spec.ts | 10 +- libs/citations/ojs-types/src/index.ts | 2 +- libs/citations/parse-text-cite/.eslintrc.json | 2 +- libs/citations/parse-text-cite/src/index.ts | 2 +- libs/citations/parse-text-cite/src/lib/apa.ts | 1312 ++++++++++++----- .../parse-text-cite/src/lib/lexer.ts | 1 + .../src/lib/parse-text-cite.spec.ts | 65 +- .../src/lib/parse-text-cite.ts | 12 +- .../parse-text-cite/src/lib/testcites copy.ts | 2 +- .../parse-text-cite/src/lib/testcites.ts | 80 +- .../parse-text-cite/src/lib/testnames.ts | 2 +- libs/jast/jast-util-from-csl/src/index.ts | 2 +- libs/jast/jast-util-to-csl/src/index.ts | 2 +- libs/jast/jast-util-to-texast/src/index.ts | 4 +- .../src/lib/handlers/index.ts | 2 +- libs/jast/jast/src/index.ts | 4 +- libs/jast/jast/src/lib/jats.ts | 15 +- libs/jast/jast/src/lib/rejour.ts | 20 +- .../notion/html-to-notion-blocks/src/index.ts | 2 +- libs/ojs/ojs-client/src/index.ts | 4 +- libs/ojs/ojs-relatex/src/index.ts | 2 +- .../ooxast-util-citation-plugin/src/index.ts | 2 +- .../lib/ooxast-util-citation-plugin.spec.ts | 6 +- .../ooxast/ooxast-util-citations/src/index.ts | 4 +- .../src/lib/constructMendeleyCitation.ts | 9 +- .../src/lib/constructZoteroCitation.ts | 14 +- .../src/lib/findRefInBib.ts | 14 +- .../lib/ooxast-ooxast-util-citations.spec.ts | 17 +- .../src/lib/ooxast-util-citations.ts | 6 +- .../ooxast-util-citations/tsconfig.lib.json | 2 +- .../ooxast/ooxast-util-get-style/src/index.ts | 4 +- .../src/lib/ooxast-util-get-pstyle.spec.ts | 2 +- .../src/lib/ooxast-util-get-rstyle.spec.ts | 2 +- .../src/index.ts | 2 +- .../ooxast-util-parse-bib-node/src/index.ts | 2 +- .../src/index-browser.ts | 2 +- .../ooxast/ooxast-util-parse-bib/src/index.ts | 2 +- .../src/lib/bib-to-csl-browser.ts | 10 +- .../src/lib/bib-to-csl-node.ts | 10 +- .../src/lib/ooxast-util-parse-bib-browser.ts | 2 +- .../src/lib/ooxast-util-parse-bib.spec.ts | 16 +- .../src/lib/ooxast-util-parse-bib.ts | 2 +- .../ooxast-util-remove-rsid/src/index.ts | 2 +- .../src/lib/ooxast-util-remove-rsid.spec.ts | 26 +- .../ooxast-util-to-unified-latex/src/index.ts | 4 +- .../src/lib/all.ts | 6 +- .../src/lib/handlers/body.ts | 40 +- .../src/lib/handlers/citation.ts | 5 +- .../src/lib/handlers/displayMath.ts | 4 +- .../src/lib/handlers/document.ts | 5 +- .../src/lib/handlers/drawing.ts | 4 +- .../src/lib/handlers/endnote.ts | 5 +- .../src/lib/handlers/footnote.ts | 5 +- .../src/lib/handlers/footnoteReference.ts | 2 +- .../src/lib/handlers/index.ts | 36 +- .../src/lib/handlers/oMath.ts | 5 +- .../src/lib/handlers/oMathPara.ts | 6 +- .../src/lib/handlers/p.spec.ts | 7 +- .../src/lib/handlers/p.ts | 8 +- .../src/lib/handlers/r.ts | 25 +- .../src/lib/handlers/root.ts | 4 +- .../src/lib/handlers/tbl.ts | 14 +- .../src/lib/handlers/tc.ts | 4 +- .../src/lib/handlers/text.ts | 2 +- .../src/lib/handlers/tr.ts | 7 +- .../src/lib/one.ts | 8 +- .../lib/ooxast-util-to-unified-latex.spec.ts | 10 +- .../src/lib/ooxast-util-to-unified-latex.ts | 35 +- .../src/lib/types.ts | 2 - .../src/lib/util/get-pstyle.spec.ts | 2 +- .../src/lib/util/get-pstyle.ts | 5 +- .../src/lib/util/notes.ts | 4 +- .../src/lib/util/wrap-text.ts | 2 +- .../src/test/fixtures.spec.ts | 6 +- libs/ooxast/ooxast/.eslintrc.json | 5 +- libs/ooxast/ooxast/src/index.ts | 6 +- libs/ooxast/ooxast/src/lib/ooxast.ts | 2 +- .../ooxast/src/lib/ooxml/drawingml/main.ts | 67 +- .../ooxast/src/lib/ooxml/drawingml/picture.ts | 4 +- .../ooxml/drawingml/wordprocessingDrawing.ts | 16 +- .../lib/ooxml/officeDocument/bibliography.ts | 9 +- .../src/lib/ooxml/officeDocument/math.ts | 12 +- .../lib/ooxml/officeDocument/relationships.ts | 4 +- .../lib/ooxml/officeDocument/sharedTypes.ts | 12 +- .../src/lib/ooxml/schemaLibrary/main.ts | 4 +- .../src/lib/ooxml/wordprocessingml/main.ts | 128 +- libs/ooxast/ooxast/tsconfig.lib.json | 3 +- libs/processors/docx-to-jats/src/index.ts | 2 +- libs/processors/docx-to-tex/src/index.ts | 2 +- libs/processors/jats-to-tex/src/index.ts | 2 +- libs/processors/jote-docx-tex/src/index.ts | 2 +- .../src/lib/processors-jote-docx-tex.spec.ts | 7 - libs/rejour/rejour-frontmatter/src/index.ts | 2 +- .../src/lib/rejour-frontmatter.spec.ts | 6 +- libs/rejour/rejour-meta/src/index.ts | 2 +- libs/rejour/rejour-move-abstract/src/index.ts | 2 +- .../src/lib/rejour-move-abstract.spec.ts | 4 +- libs/rejour/rejour-parse/src/index.ts | 4 +- libs/rejour/rejour-relatex/src/index.ts | 4 +- .../rejour-relatex/src/lib/rejour-relatex.ts | 28 +- .../src/lib/relatex-add-preamble.spec.ts | 2 +- libs/relatex/relatex-stringify/src/index.ts | 4 +- libs/reoff/docx-to-vfile/package.json | 2 - libs/reoff/docx-to-vfile/src/index.ts | 1 - .../src/lib/docx-to-vfile-unzipit.ts | 1 + libs/reoff/reoff-cite/src/index.ts | 2 +- .../reoff-cite/src/lib/reoff-cite.spec.ts | 2 +- libs/reoff/reoff-clean/.swcrc | 2 +- libs/reoff/reoff-clean/src/index.ts | 2 +- .../reoff-clean/src/lib/reoff-clean.spec.ts | 2 +- .../reoff/reoff-parse-references/src/index.ts | 2 +- .../src/lib/reoff-parse-references.spec.ts | 2 +- .../reoff-parse-references/tsconfig.lib.json | 1 - libs/reoff/reoff-parse/src/index.ts | 2 +- .../texast-util-add-preamble/src/index.ts | 2 +- libs/texast/texast-util-to-latex/src/index.ts | 4 +- libs/texast/texast/src/index.ts | 4 +- libs/utils/misc/package.json | 21 +- libs/utils/misc/src/index.ts | 12 +- libs/utils/misc/src/lib/extractDocx.spec.ts | 6 +- libs/utils/misc/src/lib/extractDocx.ts | 8 +- libs/utils/misc/src/lib/utils.spec.ts | 2 +- libs/utils/ojs-to-preamble/src/index.ts | 2 +- .../xast/xast-util-has-attribute/src/index.ts | 2 +- libs/xast/xast-util-is-element/src/index.ts | 2 +- libs/xast/xast-util-select/src/index.ts | 28 +- libs/xast/xast-util-select/src/lib/any.ts | 28 +- .../xast-util-select/src/lib/enter-state.ts | 18 +- libs/xast/xast-util-select/src/lib/id.ts | 2 +- libs/xast/xast-util-select/src/lib/name.ts | 2 +- libs/xast/xast-util-select/src/lib/nest.ts | 26 +- libs/xast/xast-util-select/src/lib/parse.ts | 12 +- libs/xast/xast-util-select/src/lib/pseudo.ts | 91 +- .../xast-util-select/src/lib/test-node.ts | 16 +- libs/xast/xast-util-select/src/lib/util.ts | 4 +- patches/@nrwl__workspace@15.8.5.patch | 154 -- 141 files changed, 1394 insertions(+), 1405 deletions(-) delete mode 100644 patches/@nrwl__workspace@15.8.5.patch diff --git a/libs/citations/apa-parser/src/index.ts b/libs/citations/apa-parser/src/index.ts index 24c7de2a..f99edc32 100644 --- a/libs/citations/apa-parser/src/index.ts +++ b/libs/citations/apa-parser/src/index.ts @@ -1 +1 @@ -export * from './lib/apa-parser' +export * from './lib/apa-parser.js' diff --git a/libs/citations/crossref-json/tsconfig.lib.json b/libs/citations/crossref-json/tsconfig.lib.json index 50db329d..4e148db0 100755 --- a/libs/citations/crossref-json/tsconfig.lib.json +++ b/libs/citations/crossref-json/tsconfig.lib.json @@ -6,5 +6,5 @@ "types": ["node"] }, "exclude": ["**/*.spec.ts", "**/*.test.ts"], - "include": ["src/index.ts"] + "include": ["src/**/*.ts"] } diff --git a/libs/citations/crossref-to-csl/src/index.ts b/libs/citations/crossref-to-csl/src/index.ts index b613f874..06834de1 100755 --- a/libs/citations/crossref-to-csl/src/index.ts +++ b/libs/citations/crossref-to-csl/src/index.ts @@ -1 +1 @@ -export * from './lib/crossref-to-csl' +export * from './lib/crossref-to-csl.js' diff --git a/libs/citations/csl-consolidate/src/index.ts b/libs/citations/csl-consolidate/src/index.ts index f2c2ed5b..ba9350da 100755 --- a/libs/citations/csl-consolidate/src/index.ts +++ b/libs/citations/csl-consolidate/src/index.ts @@ -1 +1 @@ -export * from './lib/csl-consolidate' +export * from './lib/csl-consolidate.js' diff --git a/libs/citations/csl-to-biblatex/src/index.ts b/libs/citations/csl-to-biblatex/src/index.ts index ff747d49..a222dd66 100644 --- a/libs/citations/csl-to-biblatex/src/index.ts +++ b/libs/citations/csl-to-biblatex/src/index.ts @@ -1 +1 @@ -export * from './lib/csl-to-biblatex' +export * from './lib/csl-to-biblatex.js' diff --git a/libs/citations/csl-to-biblatex/src/lib/csl-to-biblatex.spec.ts b/libs/citations/csl-to-biblatex/src/lib/csl-to-biblatex.spec.ts index a68afd50..86a5c54d 100644 --- a/libs/citations/csl-to-biblatex/src/lib/csl-to-biblatex.spec.ts +++ b/libs/citations/csl-to-biblatex/src/lib/csl-to-biblatex.spec.ts @@ -1,7 +1,7 @@ -import { cslToBiblatex } from './csl-to-biblatex'; +import { cslToBiblatex } from './csl-to-biblatex.js' describe('cslToBiblatex', () => { - it('should work', () => { - expect(cslToBiblatex()).toEqual('csl-to-biblatex'); - }) -}) \ No newline at end of file + it('should work', () => { + expect(cslToBiblatex()).toEqual('csl-to-biblatex') + }) +}) diff --git a/libs/citations/ojs-types/src/index.ts b/libs/citations/ojs-types/src/index.ts index be805f4e..900f3967 100644 --- a/libs/citations/ojs-types/src/index.ts +++ b/libs/citations/ojs-types/src/index.ts @@ -1 +1 @@ -export * from './lib/types' +export * from './lib/types.js' diff --git a/libs/citations/parse-text-cite/.eslintrc.json b/libs/citations/parse-text-cite/.eslintrc.json index 630e9d59..f8b44b97 100755 --- a/libs/citations/parse-text-cite/.eslintrc.json +++ b/libs/citations/parse-text-cite/.eslintrc.json @@ -1,6 +1,6 @@ { "extends": ["../../../.eslintrc.json"], - "ignorePatterns": ["**/apa.ts"], + "ignorePatterns": ["!**/*", "**/apa.ts"], "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], diff --git a/libs/citations/parse-text-cite/src/index.ts b/libs/citations/parse-text-cite/src/index.ts index 91dae13f..1a7832bc 100755 --- a/libs/citations/parse-text-cite/src/index.ts +++ b/libs/citations/parse-text-cite/src/index.ts @@ -1 +1 @@ -export * from './lib/parse-text-cite' +export * from './lib/parse-text-cite.js' diff --git a/libs/citations/parse-text-cite/src/lib/apa.ts b/libs/citations/parse-text-cite/src/lib/apa.ts index bf1da649..b0eb281a 100755 --- a/libs/citations/parse-text-cite/src/lib/apa.ts +++ b/libs/citations/parse-text-cite/src/lib/apa.ts @@ -2,436 +2,942 @@ // http://github.com/Hardmath123/nearley // Bypasses TS6133. Allow declared but unused functions. // @ts-ignore -function id(d: any[]): any { return d[0]; } -declare var Rp: any; -declare var Year: any; -declare var Lp: any; -declare var __: any; -declare var Number: any; -declare var Com: any; -declare var Dot: any; -declare var Sem: any; -declare var Col: any; -declare var Amp: any; -declare var And: any; -declare var Ca: any; -declare var Quote: any; -declare var Apo: any; -declare var Slash: any; -declare var Dash: any; -declare var Punct: any; -declare var Mc: any; -declare var Cap: any; -declare var Lowword: any; -declare var NL: any; -declare var Misc: any; -declare var End: any; -declare var Et: any; -declare var Low: any; -declare var DutchPref: any; -declare var BCE: any; +function id(d: any[]): any { + return d[0] +} +declare var Rp: any +declare var Year: any +declare var Lp: any +declare var __: any +declare var Number: any +declare var Com: any +declare var Dot: any +declare var Sem: any +declare var Col: any +declare var Amp: any +declare var And: any +declare var Ca: any +declare var Quote: any +declare var Apo: any +declare var Slash: any +declare var Dash: any +declare var Punct: any +declare var Mc: any +declare var Cap: any +declare var Lowword: any +declare var NL: any +declare var Misc: any +declare var End: any +declare var Et: any +declare var Low: any +declare var DutchPref: any +declare var BCE: any -import {lexer} from './lexer' +import { lexer } from './lexer.js' // TODO: [parser] It's currently extremely slow for large sentences, not good. -const getFullName = (name: {family:string, - 'non-dropping-particle':string - } - ) => `${name?.['non-dropping-particle'] - ? name?.['non-dropping-particle']+' ' - :''}${name.family}` - +const getFullName = (name: { family: string; 'non-dropping-particle': string }) => + `${name?.['non-dropping-particle'] ? name?.['non-dropping-particle'] + ' ' : ''}${name.family}` const locators = [ - "act", - "appendix", - "article-locator", - "book", - "canon", - "chapter", - "column", - "elocation", - "equation", - "figure", - "folio", - "issue", - "line", - "note", - "opus", - "page", - "paragraph", - "part", - "rule", - "scene", - "section", - "sub-verbo", - "supplement", - "table", - "timestamp", - "title-locator", - "verse", - "version", - "volume" + 'act', + 'appendix', + 'article-locator', + 'book', + 'canon', + 'chapter', + 'column', + 'elocation', + 'equation', + 'figure', + 'folio', + 'issue', + 'line', + 'note', + 'opus', + 'page', + 'paragraph', + 'part', + 'rule', + 'scene', + 'section', + 'sub-verbo', + 'supplement', + 'table', + 'timestamp', + 'title-locator', + 'verse', + 'version', + 'volume', ] -const labelMap: {[key:string]:string}= { - 'p': 'page', - 'pp': 'page', - 'chapter': 'chapter', - 'ch': 'chapter', - 'sec': 'section', - 'par': 'paragraph', - 'paras': 'paragraph', - "vol": 'volume', - 'app':'appendix', +const labelMap: { [key: string]: string } = { + p: 'page', + pp: 'page', + chapter: 'chapter', + ch: 'chapter', + sec: 'section', + par: 'paragraph', + paras: 'paragraph', + vol: 'volume', + app: 'appendix', } interface NearleyToken { - value: any; - [key: string]: any; -}; + value: any + [key: string]: any +} interface NearleyLexer { - reset: (chunk: string, info: any) => void; - next: () => NearleyToken | undefined; - save: () => any; - formatError: (token: never) => string; - has: (tokenType: string) => boolean; -}; + reset: (chunk: string, info: any) => void + next: () => NearleyToken | undefined + save: () => any + formatError: (token: never) => string + has: (tokenType: string) => boolean +} interface NearleyRule { - name: string; - symbols: NearleySymbol[]; - postprocess?: (d: any[], loc?: number, reject?: {}) => any; -}; + name: string + symbols: NearleySymbol[] + postprocess?: (d: any[], loc?: number, reject?: {}) => any +} -type NearleySymbol = string | { literal: any } | { test: (token: any) => boolean }; +type NearleySymbol = string | { literal: any } | { test: (token: any) => boolean } interface Grammar { - Lexer: NearleyLexer | undefined; - ParserRules: NearleyRule[]; - ParserStart: string; -}; + Lexer: NearleyLexer | undefined + ParserRules: NearleyRule[] + ParserStart: string +} const grammar: Grammar = { Lexer: lexer, ParserRules: [ - {"name": "Input$ebnf$1", "symbols": ["InputContent"]}, - {"name": "Input$ebnf$1", "symbols": ["Input$ebnf$1", "InputContent"], "postprocess": (d) => d[0].concat([d[1]])}, - {"name": "Input", "symbols": ["Input$ebnf$1"], "postprocess": (inp: any[])=>{ + { name: 'Input$ebnf$1', symbols: ['InputContent'] }, + { + name: 'Input$ebnf$1', + symbols: ['Input$ebnf$1', 'InputContent'], + postprocess: (d) => d[0].concat([d[1]]), + }, + { + name: 'Input', + symbols: ['Input$ebnf$1'], + postprocess: (inp: any[]) => { const [content] = inp - return content - .reduce((acc: any[], - curr: Record - )=>{ - - if(!curr.value){ - acc.push(curr) - return acc - } - - if(typeof acc[acc.length-1] ==='string'){ - acc[acc.length-1]+=curr.value - return acc - } - - acc.push(curr.value) - return acc - - }, []) - } - }, - {"name": "InputContent", "symbols": ["ParenCite"], "postprocess": id}, - {"name": "InputContent", "symbols": ["NarrCite"], "postprocess": id}, - {"name": "InputContent", "symbols": ["NonCiteContent"], "postprocess": id}, - {"name": "InputContent", "symbols": [(lexer.has("Rp") ? {type: "Rp"} : Rp), "NonCiteContent"], "postprocess": n => n.join('')}, - {"name": "NonCiteContent", "symbols": [(lexer.has("Year") ? {type: "Year"} : Year)], "postprocess": id}, - {"name": "NonCiteContent", "symbols": ["NonYearParenContent"], "postprocess": id}, - {"name": "NonCiteContent$ebnf$1", "symbols": ["NonYearParenContent"]}, - {"name": "NonCiteContent$ebnf$1", "symbols": ["NonCiteContent$ebnf$1", "NonYearParenContent"], "postprocess": (d) => d[0].concat([d[1]])}, - {"name": "NonCiteContent", "symbols": [(lexer.has("Lp") ? {type: "Lp"} : Lp), "NonCiteContent$ebnf$1", (lexer.has("Rp") ? {type: "Rp"} : Rp)], "postprocess": ([l,c,r]) => l+c.join('')+r}, - {"name": "NonYearParenContent", "symbols": [(lexer.has("__") ? {type: "__"} : __)], "postprocess": id}, - {"name": "NonYearParenContent", "symbols": [(lexer.has("Number") ? {type: "Number"} : Number)], "postprocess": id}, - {"name": "NonYearParenContent", "symbols": [(lexer.has("Com") ? {type: "Com"} : Com)], "postprocess": id}, - {"name": "NonYearParenContent", "symbols": [(lexer.has("Dot") ? {type: "Dot"} : Dot)], "postprocess": id}, - {"name": "NonYearParenContent", "symbols": [(lexer.has("Sem") ? {type: "Sem"} : Sem)], "postprocess": id}, - {"name": "NonYearParenContent", "symbols": [(lexer.has("Col") ? {type: "Col"} : Col)], "postprocess": id}, - {"name": "NonYearParenContent", "symbols": [(lexer.has("Amp") ? {type: "Amp"} : Amp)], "postprocess": id}, - {"name": "NonYearParenContent", "symbols": [(lexer.has("And") ? {type: "And"} : And)], "postprocess": id}, - {"name": "NonYearParenContent", "symbols": [(lexer.has("Ca") ? {type: "Ca"} : Ca)], "postprocess": id}, - {"name": "NonYearParenContent", "symbols": [(lexer.has("Quote") ? {type: "Quote"} : Quote)], "postprocess": id}, - {"name": "NonYearParenContent", "symbols": [(lexer.has("Apo") ? {type: "Apo"} : Apo)], "postprocess": id}, - {"name": "NonYearParenContent", "symbols": [(lexer.has("Slash") ? {type: "Slash"} : Slash)], "postprocess": id}, - {"name": "NonYearParenContent", "symbols": [(lexer.has("Dash") ? {type: "Dash"} : Dash)], "postprocess": id}, - {"name": "NonYearParenContent", "symbols": [(lexer.has("Punct") ? {type: "Punct"} : Punct)], "postprocess": id}, - {"name": "NonYearParenContent", "symbols": [(lexer.has("Mc") ? {type: "Mc"} : Mc)], "postprocess": id}, - {"name": "NonYearParenContent", "symbols": [(lexer.has("Cap") ? {type: "Cap"} : Cap)], "postprocess": id}, - {"name": "NonYearParenContent", "symbols": [(lexer.has("Lowword") ? {type: "Lowword"} : Lowword)], "postprocess": id}, - {"name": "NonYearParenContent", "symbols": [(lexer.has("NL") ? {type: "NL"} : NL)], "postprocess": id}, - {"name": "NonYearParenContent", "symbols": [(lexer.has("Misc") ? {type: "Misc"} : Misc)], "postprocess": id}, - {"name": "NonYearParenContent", "symbols": [(lexer.has("End") ? {type: "End"} : End)], "postprocess": id}, - {"name": "NarrCite$ebnf$1", "symbols": ["Loc"], "postprocess": id}, - {"name": "NarrCite$ebnf$1", "symbols": [], "postprocess": () => null}, - {"name": "NarrCite", "symbols": ["NameList", (lexer.has("__") ? {type: "__"} : __), (lexer.has("Lp") ? {type: "Lp"} : Lp), "YearList", "NarrCite$ebnf$1", (lexer.has("Rp") ? {type: "Rp"} : Rp)], "postprocess": ([name,,,yearlist])=>( - { - citationId: 'CITE-X', - citationItems: - yearlist.map((y:string[])=>({ - "id":getFullName(name[0]) - .replace(/ /g,'')+y[0], - itemData:{ - author: name, - issued: { - 'date-parts': [[y[0] - .replace(/(\d|.-?)[a-z]/,'$1')]] - - }, - ...(y[1]? {'original-date': { - 'date-parts': [[y[1].replace(/(\d)[a-z]/,'$1')]] - } - }:{}) - } - })), - properties: {noteIndex: 0,mode: "composite"} - } - ) - }, - {"name": "ParenCite", "symbols": [(lexer.has("Lp") ? {type: "Lp"} : Lp), "ParenContent", (lexer.has("Rp") ? {type: "Rp"} : Rp)], "postprocess": ([,content,])=>{ - // This is CSL-JSON cite items - return { - citationId:"CITE-X", - citationItems: content.flat(), - properties: {"noteIndex":0} + return content.reduce((acc: any[], curr: Record) => { + if (!curr.value) { + acc.push(curr) + return acc } - } - }, - {"name": "ParenContent", "symbols": ["SingleParenEntry"], "postprocess": id}, - {"name": "ParenContent", "symbols": ["ParenContent", (lexer.has("Sem") ? {type: "Sem"} : Sem), (lexer.has("__") ? {type: "__"} : __), "SingleParenEntry"], "postprocess": - ([content, semi,,single])=> [ - ...(content.flat()), - ...single - ] - }, - {"name": "ParenContent", "symbols": ["ParenContent", "PreAuthsMiddle", "SingleParenEntry"], "postprocess": - ([content, pre,single])=>{ - //const sing = single[0] - if(pre){ - single[0].prefix = pre.join('') - } - return [ - ...(content.flat()), - ...single - ] - } - }, - {"name": "SingleParenEntry$ebnf$1", "symbols": []}, - {"name": "SingleParenEntry$ebnf$1", "symbols": ["SingleParenEntry$ebnf$1", "PreAuthsPre"], "postprocess": (d) => d[0].concat([d[1]])}, - {"name": "SingleParenEntry$ebnf$2", "symbols": ["Loc"], "postprocess": id}, - {"name": "SingleParenEntry$ebnf$2", "symbols": [], "postprocess": () => null}, - {"name": "SingleParenEntry", "symbols": ["SingleParenEntry$ebnf$1", "ParenCiteAuthYear", "SingleParenEntry$ebnf$2"], "postprocess": - ([pre, content, loc]) => { - const l = Object.assign({},loc) - const p = pre.length - ? {prefix: pre?.join('')} - : {} - - if(content.length===1){ - content[0] = {...content[0], - ...l, - ...p} - return content + + if (typeof acc[acc.length - 1] === 'string') { + acc[acc.length - 1] += curr.value + return acc } - content[0] = {...content[0], - ...p} - content[content.length-1]={... - content[content.length-1], ...l} - return content - } - }, - {"name": "PreAuthsPre$ebnf$1", "symbols": ["GenericContent"]}, - {"name": "PreAuthsPre$ebnf$1", "symbols": ["PreAuthsPre$ebnf$1", "GenericContent"], "postprocess": (d) => d[0].concat([d[1]])}, - {"name": "PreAuthsPre", "symbols": ["PreAuthsPre$ebnf$1", (lexer.has("Sem") ? {type: "Sem"} : Sem), (lexer.has("__") ? {type: "__"} : __)], "postprocess": - content=> { - return content[0] - } - }, - {"name": "PreAuthsPre$ebnf$2", "symbols": ["GenericContent"]}, - {"name": "PreAuthsPre$ebnf$2", "symbols": ["PreAuthsPre$ebnf$2", "GenericContent"], "postprocess": (d) => d[0].concat([d[1]])}, - {"name": "PreAuthsPre", "symbols": ["PreAuthsPre$ebnf$2", (lexer.has("Com") ? {type: "Com"} : Com), (lexer.has("__") ? {type: "__"} : __)], "postprocess": content=> content[0]}, - {"name": "PreAuthsPre$ebnf$3", "symbols": ["GenericContent"]}, - {"name": "PreAuthsPre$ebnf$3", "symbols": ["PreAuthsPre$ebnf$3", "GenericContent"], "postprocess": (d) => d[0].concat([d[1]])}, - {"name": "PreAuthsPre", "symbols": ["PreAuthsPre$ebnf$3", (lexer.has("__") ? {type: "__"} : __)], "postprocess": content=>content[0]}, - {"name": "PreAuthsMiddle$ebnf$1", "symbols": ["GenericContent"]}, - {"name": "PreAuthsMiddle$ebnf$1", "symbols": ["PreAuthsMiddle$ebnf$1", "GenericContent"], "postprocess": (d) => d[0].concat([d[1]])}, - {"name": "PreAuthsMiddle", "symbols": [(lexer.has("Sem") ? {type: "Sem"} : Sem), (lexer.has("__") ? {type: "__"} : __), "PreAuthsMiddle$ebnf$1"], "postprocess": - content=> { - return content[2] - } - }, - {"name": "Loc", "symbols": [(lexer.has("Com") ? {type: "Com"} : Com), (lexer.has("__") ? {type: "__"} : __), "LocContent"], "postprocess": ([,,loc])=>loc}, - {"name": "LocContent$ebnf$1", "symbols": ["LocGenericContent"]}, - {"name": "LocContent$ebnf$1", "symbols": ["LocContent$ebnf$1", "LocGenericContent"], "postprocess": (d) => d[0].concat([d[1]])}, - {"name": "LocContent$ebnf$2", "symbols": ["LocGenericContent"]}, - {"name": "LocContent$ebnf$2", "symbols": ["LocContent$ebnf$2", "LocGenericContent"], "postprocess": (d) => d[0].concat([d[1]])}, - {"name": "LocContent", "symbols": ["LocContent$ebnf$1", (lexer.has("__") ? {type: "__"} : __), "LocContent$ebnf$2"], "postprocess": ([label,space,loc]) => { - const rawLabel=label - .join('') - .trim() - .toLowerCase() - .replace(/\./g,'') - - if(!(labelMap[rawLabel]) - && !locators.includes(rawLabel)){ - return { - label:'none', - locator: label - .join('') - + space + - loc - .join('') - } - } - - const properLabel = labelMap[rawLabel] || rawLabel - - return { - label: properLabel, - locator: loc.join('').trim() - } + + acc.push(curr.value) + return acc + }, []) + }, + }, + { name: 'InputContent', symbols: ['ParenCite'], postprocess: id }, + { name: 'InputContent', symbols: ['NarrCite'], postprocess: id }, + { name: 'InputContent', symbols: ['NonCiteContent'], postprocess: id }, + { + name: 'InputContent', + symbols: [lexer.has('Rp') ? { type: 'Rp' } : Rp, 'NonCiteContent'], + postprocess: (n) => n.join(''), + }, + { + name: 'NonCiteContent', + symbols: [lexer.has('Year') ? { type: 'Year' } : Year], + postprocess: id, + }, + { name: 'NonCiteContent', symbols: ['NonYearParenContent'], postprocess: id }, + { name: 'NonCiteContent$ebnf$1', symbols: ['NonYearParenContent'] }, + { + name: 'NonCiteContent$ebnf$1', + symbols: ['NonCiteContent$ebnf$1', 'NonYearParenContent'], + postprocess: (d) => d[0].concat([d[1]]), + }, + { + name: 'NonCiteContent', + symbols: [ + lexer.has('Lp') ? { type: 'Lp' } : Lp, + 'NonCiteContent$ebnf$1', + lexer.has('Rp') ? { type: 'Rp' } : Rp, + ], + postprocess: ([l, c, r]) => l + c.join('') + r, + }, + { + name: 'NonYearParenContent', + symbols: [lexer.has('__') ? { type: '__' } : __], + postprocess: id, + }, + { + name: 'NonYearParenContent', + symbols: [lexer.has('Number') ? { type: 'Number' } : Number], + postprocess: id, + }, + { + name: 'NonYearParenContent', + symbols: [lexer.has('Com') ? { type: 'Com' } : Com], + postprocess: id, + }, + { + name: 'NonYearParenContent', + symbols: [lexer.has('Dot') ? { type: 'Dot' } : Dot], + postprocess: id, + }, + { + name: 'NonYearParenContent', + symbols: [lexer.has('Sem') ? { type: 'Sem' } : Sem], + postprocess: id, + }, + { + name: 'NonYearParenContent', + symbols: [lexer.has('Col') ? { type: 'Col' } : Col], + postprocess: id, + }, + { + name: 'NonYearParenContent', + symbols: [lexer.has('Amp') ? { type: 'Amp' } : Amp], + postprocess: id, + }, + { + name: 'NonYearParenContent', + symbols: [lexer.has('And') ? { type: 'And' } : And], + postprocess: id, + }, + { + name: 'NonYearParenContent', + symbols: [lexer.has('Ca') ? { type: 'Ca' } : Ca], + postprocess: id, + }, + { + name: 'NonYearParenContent', + symbols: [lexer.has('Quote') ? { type: 'Quote' } : Quote], + postprocess: id, + }, + { + name: 'NonYearParenContent', + symbols: [lexer.has('Apo') ? { type: 'Apo' } : Apo], + postprocess: id, + }, + { + name: 'NonYearParenContent', + symbols: [lexer.has('Slash') ? { type: 'Slash' } : Slash], + postprocess: id, + }, + { + name: 'NonYearParenContent', + symbols: [lexer.has('Dash') ? { type: 'Dash' } : Dash], + postprocess: id, + }, + { + name: 'NonYearParenContent', + symbols: [lexer.has('Punct') ? { type: 'Punct' } : Punct], + postprocess: id, + }, + { + name: 'NonYearParenContent', + symbols: [lexer.has('Mc') ? { type: 'Mc' } : Mc], + postprocess: id, + }, + { + name: 'NonYearParenContent', + symbols: [lexer.has('Cap') ? { type: 'Cap' } : Cap], + postprocess: id, + }, + { + name: 'NonYearParenContent', + symbols: [lexer.has('Lowword') ? { type: 'Lowword' } : Lowword], + postprocess: id, + }, + { + name: 'NonYearParenContent', + symbols: [lexer.has('NL') ? { type: 'NL' } : NL], + postprocess: id, + }, + { + name: 'NonYearParenContent', + symbols: [lexer.has('Misc') ? { type: 'Misc' } : Misc], + postprocess: id, + }, + { + name: 'NonYearParenContent', + symbols: [lexer.has('End') ? { type: 'End' } : End], + postprocess: id, + }, + { name: 'NarrCite$ebnf$1', symbols: ['Loc'], postprocess: id }, + { name: 'NarrCite$ebnf$1', symbols: [], postprocess: () => null }, + { + name: 'NarrCite', + symbols: [ + 'NameList', + lexer.has('__') ? { type: '__' } : __, + lexer.has('Lp') ? { type: 'Lp' } : Lp, + 'YearList', + 'NarrCite$ebnf$1', + lexer.has('Rp') ? { type: 'Rp' } : Rp, + ], + postprocess: ([name, , , yearlist]) => ({ + citationId: 'CITE-X', + citationItems: yearlist.map((y: string[]) => ({ + id: getFullName(name[0]).replace(/ /g, '') + y[0], + itemData: { + author: name, + issued: { + 'date-parts': [[y[0].replace(/(\d|.-?)[a-z]/, '$1')]], + }, + ...(y[1] + ? { + 'original-date': { + 'date-parts': [[y[1].replace(/(\d)[a-z]/, '$1')]], + }, + } + : {}), + }, + })), + properties: { noteIndex: 0, mode: 'composite' }, + }), + }, + { + name: 'ParenCite', + symbols: [ + lexer.has('Lp') ? { type: 'Lp' } : Lp, + 'ParenContent', + lexer.has('Rp') ? { type: 'Rp' } : Rp, + ], + postprocess: ([, content]) => { + // This is CSL-JSON cite items + return { + citationId: 'CITE-X', + citationItems: content.flat(), + properties: { noteIndex: 0 }, } - }, - {"name": "LocContent$ebnf$3", "symbols": ["LocGenericContent"]}, - {"name": "LocContent$ebnf$3", "symbols": ["LocContent$ebnf$3", "LocGenericContent"], "postprocess": (d) => d[0].concat([d[1]])}, - {"name": "LocContent", "symbols": ["LocContent$ebnf$3"], "postprocess": ([loc]) => ({locator: loc.join(''),label:'none'})}, - {"name": "LocGenericContent", "symbols": ["GenericContent"], "postprocess": content => content}, - {"name": "LocGenericContent", "symbols": [(lexer.has("Cap") ? {type: "Cap"} : Cap), (lexer.has("Lowword") ? {type: "Lowword"} : Lowword), "LocGenericContent"], "postprocess": ([cap,low,rest])=> [cap+low+rest.join('')]}, - {"name": "LocGenericContent", "symbols": [(lexer.has("Cap") ? {type: "Cap"} : Cap), (lexer.has("Lowword") ? {type: "Lowword"} : Lowword)], "postprocess": ([cap,low])=> [cap+low]}, - {"name": "GenericContent", "symbols": [(lexer.has("Lowword") ? {type: "Lowword"} : Lowword)], "postprocess": id}, - {"name": "GenericContent$ebnf$1", "symbols": [(lexer.has("Cap") ? {type: "Cap"} : Cap)]}, - {"name": "GenericContent$ebnf$1", "symbols": ["GenericContent$ebnf$1", (lexer.has("Cap") ? {type: "Cap"} : Cap)], "postprocess": (d) => d[0].concat([d[1]])}, - {"name": "GenericContent", "symbols": [(lexer.has("Cap") ? {type: "Cap"} : Cap), "GenericContent$ebnf$1"], "postprocess": ([cap,caps]) => cap+caps.join('')}, - {"name": "GenericContent", "symbols": [(lexer.has("Cap") ? {type: "Cap"} : Cap), (lexer.has("__") ? {type: "__"} : __)], "postprocess": content=>content.join('')}, - {"name": "GenericContent", "symbols": ["GenericContent", (lexer.has("Cap") ? {type: "Cap"} : Cap), (lexer.has("Lowword") ? {type: "Lowword"} : Lowword)], "postprocess": content=>content.join('')}, - {"name": "GenericContent$ebnf$2$subexpression$1", "symbols": [(lexer.has("Cap") ? {type: "Cap"} : Cap), (lexer.has("Dot") ? {type: "Dot"} : Dot)]}, - {"name": "GenericContent$ebnf$2", "symbols": ["GenericContent$ebnf$2$subexpression$1"]}, - {"name": "GenericContent$ebnf$2$subexpression$2", "symbols": [(lexer.has("Cap") ? {type: "Cap"} : Cap), (lexer.has("Dot") ? {type: "Dot"} : Dot)]}, - {"name": "GenericContent$ebnf$2", "symbols": ["GenericContent$ebnf$2", "GenericContent$ebnf$2$subexpression$2"], "postprocess": (d) => d[0].concat([d[1]])}, - {"name": "GenericContent", "symbols": [(lexer.has("Cap") ? {type: "Cap"} : Cap), (lexer.has("Dot") ? {type: "Dot"} : Dot), "GenericContent$ebnf$2"], "postprocess": ([c,d,content])=>c+d+content.flat().join('')}, - {"name": "GenericContent", "symbols": [(lexer.has("Col") ? {type: "Col"} : Col)], "postprocess": id}, - {"name": "GenericContent", "symbols": [(lexer.has("Number") ? {type: "Number"} : Number)], "postprocess": id}, - {"name": "GenericContent", "symbols": [(lexer.has("Dot") ? {type: "Dot"} : Dot)], "postprocess": id}, - {"name": "GenericContent", "symbols": [(lexer.has("Dash") ? {type: "Dash"} : Dash)], "postprocess": id}, - {"name": "GenericContent", "symbols": [(lexer.has("Com") ? {type: "Com"} : Com)], "postprocess": id}, - {"name": "GenericContent", "symbols": [(lexer.has("__") ? {type: "__"} : __)], "postprocess": id}, - {"name": "ParenCiteAuthYear", "symbols": ["ParenNameMaybeList", (lexer.has("Com") ? {type: "Com"} : Com), (lexer.has("__") ? {type: "__"} : __), "YearList"], "postprocess": (content) => { - const [name,,,yearlist] = content - return yearlist.map((y:string[])=>({ - "id":getFullName(name[0]).replace(/ /g,'')+y[0], - itemData:{ - author: name, - issued: { - 'date-parts': [[y[0].replace(/(\d)[a-z]/,'$1')]] - }, - ...(y[1]? {'original-date': { - 'date-parts': [[y[1].replace(/(\d)[a-z]/,'$1')]] - } - }:{}) - } - })) + }, + }, + { name: 'ParenContent', symbols: ['SingleParenEntry'], postprocess: id }, + { + name: 'ParenContent', + symbols: [ + 'ParenContent', + lexer.has('Sem') ? { type: 'Sem' } : Sem, + lexer.has('__') ? { type: '__' } : __, + 'SingleParenEntry', + ], + postprocess: ([content, semi, , single]) => [...content.flat(), ...single], + }, + { + name: 'ParenContent', + symbols: ['ParenContent', 'PreAuthsMiddle', 'SingleParenEntry'], + postprocess: ([content, pre, single]) => { + //const sing = single[0] + if (pre) { + single[0].prefix = pre.join('') } - }, - {"name": "YearList", "symbols": ["Year"], "postprocess": year=>year}, - {"name": "YearList$ebnf$1", "symbols": [(lexer.has("__") ? {type: "__"} : __)]}, - {"name": "YearList$ebnf$1", "symbols": ["YearList$ebnf$1", (lexer.has("__") ? {type: "__"} : __)], "postprocess": (d) => d[0].concat([d[1]])}, - {"name": "YearList", "symbols": ["YearList", (lexer.has("Com") ? {type: "Com"} : Com), "YearList$ebnf$1", "Year"], "postprocess": ([list,,,year])=> { - return [...list,year] + return [...content.flat(), ...single] + }, + }, + { name: 'SingleParenEntry$ebnf$1', symbols: [] }, + { + name: 'SingleParenEntry$ebnf$1', + symbols: ['SingleParenEntry$ebnf$1', 'PreAuthsPre'], + postprocess: (d) => d[0].concat([d[1]]), + }, + { name: 'SingleParenEntry$ebnf$2', symbols: ['Loc'], postprocess: id }, + { name: 'SingleParenEntry$ebnf$2', symbols: [], postprocess: () => null }, + { + name: 'SingleParenEntry', + symbols: ['SingleParenEntry$ebnf$1', 'ParenCiteAuthYear', 'SingleParenEntry$ebnf$2'], + postprocess: ([pre, content, loc]) => { + const l = Object.assign({}, loc) + const p = pre.length ? { prefix: pre?.join('') } : {} + + if (content.length === 1) { + content[0] = { ...content[0], ...l, ...p } + return content } - }, - {"name": "NameList", "symbols": ["Name"], "postprocess": name=>name}, - {"name": "NameList", "symbols": ["NameList", (lexer.has("Com") ? {type: "Com"} : Com), (lexer.has("__") ? {type: "__"} : __), "Name"], "postprocess": ([name,,,n])=>([name,n].flat())}, - {"name": "NameList", "symbols": ["NameList", (lexer.has("Com") ? {type: "Com"} : Com), (lexer.has("__") ? {type: "__"} : __), "NameList"], "postprocess": ([name,,,n])=>([name,n].flat())}, - {"name": "NameList", "symbols": ["NameList", (lexer.has("Com") ? {type: "Com"} : Com), (lexer.has("__") ? {type: "__"} : __), "Comp", (lexer.has("__") ? {type: "__"} : __), "NameList"], "postprocess": ([name,,,,,n])=>([name,n].flat())}, - {"name": "NameList", "symbols": ["NameList", (lexer.has("Com") ? {type: "Com"} : Com), (lexer.has("__") ? {type: "__"} : __), "Comp", (lexer.has("__") ? {type: "__"} : __)], "postprocess": ([name,,,,])=>([name].flat())}, - {"name": "NameList", "symbols": ["NameList", (lexer.has("__") ? {type: "__"} : __), "Comp", (lexer.has("__") ? {type: "__"} : __), "NameList"], "postprocess": ([name,_,and,__,n])=>([name,n].flat())}, - {"name": "NameList", "symbols": ["NameList", (lexer.has("__") ? {type: "__"} : __), "Comp", (lexer.has("__") ? {type: "__"} : __), "Name"], "postprocess": ([name,_,and,__,n])=>([name,n].flat())}, - {"name": "NameList", "symbols": ["NameList", (lexer.has("__") ? {type: "__"} : __), "Comp", (lexer.has("__") ? {type: "__"} : __)], "postprocess": ([name])=>([name].flat())}, - {"name": "NameList", "symbols": ["NameList", (lexer.has("Com") ? {type: "Com"} : Com), (lexer.has("__") ? {type: "__"} : __), "Etal"], "postprocess": ([name])=>([name].flat())}, - {"name": "NameList", "symbols": ["NameList", "Etal"], "postprocess": ([name])=>([name].flat())}, - {"name": "ParenNameMaybeList", "symbols": ["ParenNameMaybe"], "postprocess": name=>name}, - {"name": "ParenNameMaybeList", "symbols": ["ParenNameMaybeList", (lexer.has("Com") ? {type: "Com"} : Com), (lexer.has("__") ? {type: "__"} : __), "Name"], "postprocess": ([name,,,n])=>([name,n].flat())}, - {"name": "ParenNameMaybeList", "symbols": ["ParenNameMaybeList", (lexer.has("Com") ? {type: "Com"} : Com), (lexer.has("__") ? {type: "__"} : __), "NameList"], "postprocess": ([name,,,n])=>([name,n].flat())}, - {"name": "ParenNameMaybeList", "symbols": ["ParenNameMaybeList", (lexer.has("Com") ? {type: "Com"} : Com), (lexer.has("__") ? {type: "__"} : __), "Comp", (lexer.has("__") ? {type: "__"} : __), "NameList"], "postprocess": ([name,,,,,n])=>([name,n].flat())}, - {"name": "ParenNameMaybeList", "symbols": ["ParenNameMaybeList", (lexer.has("Com") ? {type: "Com"} : Com), (lexer.has("__") ? {type: "__"} : __), "Comp", (lexer.has("__") ? {type: "__"} : __)], "postprocess": ([name])=>([name].flat())}, - {"name": "ParenNameMaybeList", "symbols": ["ParenNameMaybeList", (lexer.has("__") ? {type: "__"} : __), "Comp", (lexer.has("__") ? {type: "__"} : __), "NameList"], "postprocess": ([name,,,,n])=>([name,n].flat())}, - {"name": "ParenNameMaybeList", "symbols": ["ParenNameMaybeList", (lexer.has("__") ? {type: "__"} : __), "Comp", (lexer.has("__") ? {type: "__"} : __)], "postprocess": ([name])=>([name].flat())}, - {"name": "ParenNameMaybe", "symbols": ["Name"], "postprocess": id}, - {"name": "ParenNameMaybe", "symbols": ["Name", "Etal"], "postprocess": ([n])=>n}, - {"name": "ParenNameMaybe", "symbols": ["ParenNameMaybe", (lexer.has("__") ? {type: "__"} : __), "ParenNameMaybe"], "postprocess": ([n,,nn]) => ({...n,...nn,family:n.family+nn.family})}, - {"name": "ParenNameMaybe", "symbols": ["ParenNameMaybe", (lexer.has("__") ? {type: "__"} : __), (lexer.has("Lowword") ? {type: "Lowword"} : Lowword)], "postprocess": ([n,,nn]) => ({...n,family:n.family+nn})}, - {"name": "Etal$ebnf$1", "symbols": [(lexer.has("__") ? {type: "__"} : __)], "postprocess": id}, - {"name": "Etal$ebnf$1", "symbols": [], "postprocess": () => null}, - {"name": "Etal", "symbols": ["Etal$ebnf$1", (lexer.has("Et") ? {type: "Et"} : Et)], "postprocess": etal=>null}, - {"name": "Name", "symbols": ["Initials", (lexer.has("__") ? {type: "__"} : __), "LastName"], "postprocess": ([initials, ,name])=> ({given: initials.join(''),...name})}, - {"name": "Name", "symbols": ["LastName"], "postprocess": id}, - {"name": "LastName", "symbols": ["SingleName"], "postprocess": id}, - {"name": "LastName", "symbols": ["HyphenName"], "postprocess": id}, - {"name": "Comp", "symbols": [(lexer.has("And") ? {type: "And"} : And)], "postprocess": id}, - {"name": "Comp", "symbols": [(lexer.has("Amp") ? {type: "Amp"} : Amp)], "postprocess": id}, - {"name": "HyphenName", "symbols": ["SingleName", (lexer.has("Dash") ? {type: "Dash"} : Dash), "SingleName"], "postprocess": ([first,d,last])=> ( { - family: `${getFullName(first) - + d - + getFullName(last)}` - } - ) - }, - {"name": "SingleName", "symbols": ["BoringNameMaybe"], "postprocess": ([name]) => ({family:name})}, - {"name": "SingleName", "symbols": ["DutchName"], "postprocess": id}, - {"name": "SingleName", "symbols": ["OReilly"], "postprocess": id}, - {"name": "SingleName", "symbols": ["McConnel"], "postprocess": id}, - {"name": "SingleName", "symbols": ["SpanishName"], "postprocess": id}, - {"name": "Initials", "symbols": ["Initial"]}, - {"name": "Initials$ebnf$1", "symbols": []}, - {"name": "Initials$ebnf$1", "symbols": ["Initials$ebnf$1", (lexer.has("__") ? {type: "__"} : __)], "postprocess": (d) => d[0].concat([d[1]])}, - {"name": "Initials", "symbols": ["Initials", "Initials$ebnf$1", "Initial"]}, - {"name": "Initial", "symbols": [(lexer.has("Cap") ? {type: "Cap"} : Cap), (lexer.has("Dot") ? {type: "Dot"} : Dot)], "postprocess": id}, - {"name": "SpanishName", "symbols": ["BoringNameMaybe", (lexer.has("__") ? {type: "__"} : __), "BoringNameMaybe"], "postprocess": - ([first,,last]) => ({ - family: `${first} ${last}` - }) - }, - {"name": "DutchName", "symbols": ["DutchPrefix", (lexer.has("__") ? {type: "__"} : __), "BoringNameMaybe"], "postprocess": ([pref,space, rest]) => ( - { - family: rest, - 'non-dropping-particle': pref - .join('') + content[0] = { ...content[0], ...p } + content[content.length - 1] = { ...content[content.length - 1], ...l } + return content + }, + }, + { name: 'PreAuthsPre$ebnf$1', symbols: ['GenericContent'] }, + { + name: 'PreAuthsPre$ebnf$1', + symbols: ['PreAuthsPre$ebnf$1', 'GenericContent'], + postprocess: (d) => d[0].concat([d[1]]), + }, + { + name: 'PreAuthsPre', + symbols: [ + 'PreAuthsPre$ebnf$1', + lexer.has('Sem') ? { type: 'Sem' } : Sem, + lexer.has('__') ? { type: '__' } : __, + ], + postprocess: (content) => { + return content[0] + }, + }, + { name: 'PreAuthsPre$ebnf$2', symbols: ['GenericContent'] }, + { + name: 'PreAuthsPre$ebnf$2', + symbols: ['PreAuthsPre$ebnf$2', 'GenericContent'], + postprocess: (d) => d[0].concat([d[1]]), + }, + { + name: 'PreAuthsPre', + symbols: [ + 'PreAuthsPre$ebnf$2', + lexer.has('Com') ? { type: 'Com' } : Com, + lexer.has('__') ? { type: '__' } : __, + ], + postprocess: (content) => content[0], + }, + { name: 'PreAuthsPre$ebnf$3', symbols: ['GenericContent'] }, + { + name: 'PreAuthsPre$ebnf$3', + symbols: ['PreAuthsPre$ebnf$3', 'GenericContent'], + postprocess: (d) => d[0].concat([d[1]]), + }, + { + name: 'PreAuthsPre', + symbols: ['PreAuthsPre$ebnf$3', lexer.has('__') ? { type: '__' } : __], + postprocess: (content) => content[0], + }, + { name: 'PreAuthsMiddle$ebnf$1', symbols: ['GenericContent'] }, + { + name: 'PreAuthsMiddle$ebnf$1', + symbols: ['PreAuthsMiddle$ebnf$1', 'GenericContent'], + postprocess: (d) => d[0].concat([d[1]]), + }, + { + name: 'PreAuthsMiddle', + symbols: [ + lexer.has('Sem') ? { type: 'Sem' } : Sem, + lexer.has('__') ? { type: '__' } : __, + 'PreAuthsMiddle$ebnf$1', + ], + postprocess: (content) => { + return content[2] + }, + }, + { + name: 'Loc', + symbols: [ + lexer.has('Com') ? { type: 'Com' } : Com, + lexer.has('__') ? { type: '__' } : __, + 'LocContent', + ], + postprocess: ([, , loc]) => loc, + }, + { name: 'LocContent$ebnf$1', symbols: ['LocGenericContent'] }, + { + name: 'LocContent$ebnf$1', + symbols: ['LocContent$ebnf$1', 'LocGenericContent'], + postprocess: (d) => d[0].concat([d[1]]), + }, + { name: 'LocContent$ebnf$2', symbols: ['LocGenericContent'] }, + { + name: 'LocContent$ebnf$2', + symbols: ['LocContent$ebnf$2', 'LocGenericContent'], + postprocess: (d) => d[0].concat([d[1]]), + }, + { + name: 'LocContent', + symbols: ['LocContent$ebnf$1', lexer.has('__') ? { type: '__' } : __, 'LocContent$ebnf$2'], + postprocess: ([label, space, loc]) => { + const rawLabel = label.join('').trim().toLowerCase().replace(/\./g, '') + + if (!labelMap[rawLabel] && !locators.includes(rawLabel)) { + return { + label: 'none', + locator: label.join('') + space + loc.join(''), } - ) - }, - {"name": "OReilly", "symbols": ["BoringNameMaybe", {"literal":"'"}, "BoringNameMaybe"], "postprocess": ([o, a, name]) =>({family:o+a+name })}, - {"name": "McConnel", "symbols": [(lexer.has("Mc") ? {type: "Mc"} : Mc), "BoringNameMaybe"], "postprocess": (name) =>({family:name.join('')})}, - {"name": "BoringNameMaybe$ebnf$1", "symbols": []}, - {"name": "BoringNameMaybe$ebnf$1", "symbols": ["BoringNameMaybe$ebnf$1", (lexer.has("Lowword") ? {type: "Lowword"} : Lowword)], "postprocess": (d) => d[0].concat([d[1]])}, - {"name": "BoringNameMaybe", "symbols": [(lexer.has("Cap") ? {type: "Cap"} : Cap), "BoringNameMaybe$ebnf$1"], "postprocess": ([cap, rest]) =>( `${cap}${rest.join('')}`)}, - {"name": "BoringWord$ebnf$1", "symbols": [(lexer.has("Low") ? {type: "Low"} : Low)]}, - {"name": "BoringWord$ebnf$1", "symbols": ["BoringWord$ebnf$1", (lexer.has("Low") ? {type: "Low"} : Low)], "postprocess": (d) => d[0].concat([d[1]])}, - {"name": "BoringWord", "symbols": ["BoringWord$ebnf$1"], "postprocess": (word) =>(word.join(''))}, - {"name": "DutchPrefix", "symbols": [(lexer.has("DutchPref") ? {type: "DutchPref"} : DutchPref)]}, - {"name": "DutchPrefix", "symbols": ["DutchPrefix", (lexer.has("__") ? {type: "__"} : __), (lexer.has("DutchPref") ? {type: "DutchPref"} : DutchPref)]}, - {"name": "Year", "symbols": [(lexer.has("Year") ? {type: "Year"} : Year)], "postprocess": ([year]) => ([`${year}`.replace(/\./g,'').toUpperCase()])}, - {"name": "Year$ebnf$1", "symbols": [(lexer.has("Dash") ? {type: "Dash"} : Dash)], "postprocess": id}, - {"name": "Year$ebnf$1", "symbols": [], "postprocess": () => null}, - {"name": "Year", "symbols": [(lexer.has("Year") ? {type: "Year"} : Year), "Year$ebnf$1", (lexer.has("Lowword") ? {type: "Lowword"} : Lowword)], "postprocess": ([year,, low])=> ([year + low])}, - {"name": "Year", "symbols": ["Year", (lexer.has("Slash") ? {type: "Slash"} : Slash), "Year"], "postprocess": (content) => {const[year, sl, year2]=content - return([...year2,...year])} - }, - {"name": "Year$ebnf$2", "symbols": [(lexer.has("Number") ? {type: "Number"} : Number)]}, - {"name": "Year$ebnf$2", "symbols": ["Year$ebnf$2", (lexer.has("Number") ? {type: "Number"} : Number)], "postprocess": (d) => d[0].concat([d[1]])}, - {"name": "Year$ebnf$3", "symbols": []}, - {"name": "Year$ebnf$3", "symbols": ["Year$ebnf$3", (lexer.has("__") ? {type: "__"} : __)], "postprocess": (d) => d[0].concat([d[1]])}, - {"name": "Year", "symbols": ["Year$ebnf$2", "Year$ebnf$3", (lexer.has("BCE") ? {type: "BCE"} : BCE)], "postprocess": ([num,,rest])=> ([`${/b\.?c\.?/i.test(rest) ? '-' : ''}${num}`])}, - {"name": "Year", "symbols": [(lexer.has("Ca") ? {type: "Ca"} : Ca), (lexer.has("__") ? {type: "__"} : __), "Year"], "postprocess": ([ca,,year])=> ([`${year}`])} + } + + const properLabel = labelMap[rawLabel] || rawLabel + + return { + label: properLabel, + locator: loc.join('').trim(), + } + }, + }, + { name: 'LocContent$ebnf$3', symbols: ['LocGenericContent'] }, + { + name: 'LocContent$ebnf$3', + symbols: ['LocContent$ebnf$3', 'LocGenericContent'], + postprocess: (d) => d[0].concat([d[1]]), + }, + { + name: 'LocContent', + symbols: ['LocContent$ebnf$3'], + postprocess: ([loc]) => ({ locator: loc.join(''), label: 'none' }), + }, + { name: 'LocGenericContent', symbols: ['GenericContent'], postprocess: (content) => content }, + { + name: 'LocGenericContent', + symbols: [ + lexer.has('Cap') ? { type: 'Cap' } : Cap, + lexer.has('Lowword') ? { type: 'Lowword' } : Lowword, + 'LocGenericContent', + ], + postprocess: ([cap, low, rest]) => [cap + low + rest.join('')], + }, + { + name: 'LocGenericContent', + symbols: [ + lexer.has('Cap') ? { type: 'Cap' } : Cap, + lexer.has('Lowword') ? { type: 'Lowword' } : Lowword, + ], + postprocess: ([cap, low]) => [cap + low], + }, + { + name: 'GenericContent', + symbols: [lexer.has('Lowword') ? { type: 'Lowword' } : Lowword], + postprocess: id, + }, + { name: 'GenericContent$ebnf$1', symbols: [lexer.has('Cap') ? { type: 'Cap' } : Cap] }, + { + name: 'GenericContent$ebnf$1', + symbols: ['GenericContent$ebnf$1', lexer.has('Cap') ? { type: 'Cap' } : Cap], + postprocess: (d) => d[0].concat([d[1]]), + }, + { + name: 'GenericContent', + symbols: [lexer.has('Cap') ? { type: 'Cap' } : Cap, 'GenericContent$ebnf$1'], + postprocess: ([cap, caps]) => cap + caps.join(''), + }, + { + name: 'GenericContent', + symbols: [lexer.has('Cap') ? { type: 'Cap' } : Cap, lexer.has('__') ? { type: '__' } : __], + postprocess: (content) => content.join(''), + }, + { + name: 'GenericContent', + symbols: [ + 'GenericContent', + lexer.has('Cap') ? { type: 'Cap' } : Cap, + lexer.has('Lowword') ? { type: 'Lowword' } : Lowword, + ], + postprocess: (content) => content.join(''), + }, + { + name: 'GenericContent$ebnf$2$subexpression$1', + symbols: [lexer.has('Cap') ? { type: 'Cap' } : Cap, lexer.has('Dot') ? { type: 'Dot' } : Dot], + }, + { name: 'GenericContent$ebnf$2', symbols: ['GenericContent$ebnf$2$subexpression$1'] }, + { + name: 'GenericContent$ebnf$2$subexpression$2', + symbols: [lexer.has('Cap') ? { type: 'Cap' } : Cap, lexer.has('Dot') ? { type: 'Dot' } : Dot], + }, + { + name: 'GenericContent$ebnf$2', + symbols: ['GenericContent$ebnf$2', 'GenericContent$ebnf$2$subexpression$2'], + postprocess: (d) => d[0].concat([d[1]]), + }, + { + name: 'GenericContent', + symbols: [ + lexer.has('Cap') ? { type: 'Cap' } : Cap, + lexer.has('Dot') ? { type: 'Dot' } : Dot, + 'GenericContent$ebnf$2', + ], + postprocess: ([c, d, content]) => c + d + content.flat().join(''), + }, + { + name: 'GenericContent', + symbols: [lexer.has('Col') ? { type: 'Col' } : Col], + postprocess: id, + }, + { + name: 'GenericContent', + symbols: [lexer.has('Number') ? { type: 'Number' } : Number], + postprocess: id, + }, + { + name: 'GenericContent', + symbols: [lexer.has('Dot') ? { type: 'Dot' } : Dot], + postprocess: id, + }, + { + name: 'GenericContent', + symbols: [lexer.has('Dash') ? { type: 'Dash' } : Dash], + postprocess: id, + }, + { + name: 'GenericContent', + symbols: [lexer.has('Com') ? { type: 'Com' } : Com], + postprocess: id, + }, + { name: 'GenericContent', symbols: [lexer.has('__') ? { type: '__' } : __], postprocess: id }, + { + name: 'ParenCiteAuthYear', + symbols: [ + 'ParenNameMaybeList', + lexer.has('Com') ? { type: 'Com' } : Com, + lexer.has('__') ? { type: '__' } : __, + 'YearList', + ], + postprocess: (content) => { + const [name, , , yearlist] = content + return yearlist.map((y: string[]) => ({ + id: getFullName(name[0]).replace(/ /g, '') + y[0], + itemData: { + author: name, + issued: { + 'date-parts': [[y[0].replace(/(\d)[a-z]/, '$1')]], + }, + ...(y[1] + ? { + 'original-date': { + 'date-parts': [[y[1].replace(/(\d)[a-z]/, '$1')]], + }, + } + : {}), + }, + })) + }, + }, + { name: 'YearList', symbols: ['Year'], postprocess: (year) => year }, + { name: 'YearList$ebnf$1', symbols: [lexer.has('__') ? { type: '__' } : __] }, + { + name: 'YearList$ebnf$1', + symbols: ['YearList$ebnf$1', lexer.has('__') ? { type: '__' } : __], + postprocess: (d) => d[0].concat([d[1]]), + }, + { + name: 'YearList', + symbols: ['YearList', lexer.has('Com') ? { type: 'Com' } : Com, 'YearList$ebnf$1', 'Year'], + postprocess: ([list, , , year]) => { + return [...list, year] + }, + }, + { name: 'NameList', symbols: ['Name'], postprocess: (name) => name }, + { + name: 'NameList', + symbols: [ + 'NameList', + lexer.has('Com') ? { type: 'Com' } : Com, + lexer.has('__') ? { type: '__' } : __, + 'Name', + ], + postprocess: ([name, , , n]) => [name, n].flat(), + }, + { + name: 'NameList', + symbols: [ + 'NameList', + lexer.has('Com') ? { type: 'Com' } : Com, + lexer.has('__') ? { type: '__' } : __, + 'NameList', + ], + postprocess: ([name, , , n]) => [name, n].flat(), + }, + { + name: 'NameList', + symbols: [ + 'NameList', + lexer.has('Com') ? { type: 'Com' } : Com, + lexer.has('__') ? { type: '__' } : __, + 'Comp', + lexer.has('__') ? { type: '__' } : __, + 'NameList', + ], + postprocess: ([name, , , , , n]) => [name, n].flat(), + }, + { + name: 'NameList', + symbols: [ + 'NameList', + lexer.has('Com') ? { type: 'Com' } : Com, + lexer.has('__') ? { type: '__' } : __, + 'Comp', + lexer.has('__') ? { type: '__' } : __, + ], + postprocess: ([name, , , ,]) => [name].flat(), + }, + { + name: 'NameList', + symbols: [ + 'NameList', + lexer.has('__') ? { type: '__' } : __, + 'Comp', + lexer.has('__') ? { type: '__' } : __, + 'NameList', + ], + postprocess: ([name, _, and, __, n]) => [name, n].flat(), + }, + { + name: 'NameList', + symbols: [ + 'NameList', + lexer.has('__') ? { type: '__' } : __, + 'Comp', + lexer.has('__') ? { type: '__' } : __, + 'Name', + ], + postprocess: ([name, _, and, __, n]) => [name, n].flat(), + }, + { + name: 'NameList', + symbols: [ + 'NameList', + lexer.has('__') ? { type: '__' } : __, + 'Comp', + lexer.has('__') ? { type: '__' } : __, + ], + postprocess: ([name]) => [name].flat(), + }, + { + name: 'NameList', + symbols: [ + 'NameList', + lexer.has('Com') ? { type: 'Com' } : Com, + lexer.has('__') ? { type: '__' } : __, + 'Etal', + ], + postprocess: ([name]) => [name].flat(), + }, + { name: 'NameList', symbols: ['NameList', 'Etal'], postprocess: ([name]) => [name].flat() }, + { name: 'ParenNameMaybeList', symbols: ['ParenNameMaybe'], postprocess: (name) => name }, + { + name: 'ParenNameMaybeList', + symbols: [ + 'ParenNameMaybeList', + lexer.has('Com') ? { type: 'Com' } : Com, + lexer.has('__') ? { type: '__' } : __, + 'Name', + ], + postprocess: ([name, , , n]) => [name, n].flat(), + }, + { + name: 'ParenNameMaybeList', + symbols: [ + 'ParenNameMaybeList', + lexer.has('Com') ? { type: 'Com' } : Com, + lexer.has('__') ? { type: '__' } : __, + 'NameList', + ], + postprocess: ([name, , , n]) => [name, n].flat(), + }, + { + name: 'ParenNameMaybeList', + symbols: [ + 'ParenNameMaybeList', + lexer.has('Com') ? { type: 'Com' } : Com, + lexer.has('__') ? { type: '__' } : __, + 'Comp', + lexer.has('__') ? { type: '__' } : __, + 'NameList', + ], + postprocess: ([name, , , , , n]) => [name, n].flat(), + }, + { + name: 'ParenNameMaybeList', + symbols: [ + 'ParenNameMaybeList', + lexer.has('Com') ? { type: 'Com' } : Com, + lexer.has('__') ? { type: '__' } : __, + 'Comp', + lexer.has('__') ? { type: '__' } : __, + ], + postprocess: ([name]) => [name].flat(), + }, + { + name: 'ParenNameMaybeList', + symbols: [ + 'ParenNameMaybeList', + lexer.has('__') ? { type: '__' } : __, + 'Comp', + lexer.has('__') ? { type: '__' } : __, + 'NameList', + ], + postprocess: ([name, , , , n]) => [name, n].flat(), + }, + { + name: 'ParenNameMaybeList', + symbols: [ + 'ParenNameMaybeList', + lexer.has('__') ? { type: '__' } : __, + 'Comp', + lexer.has('__') ? { type: '__' } : __, + ], + postprocess: ([name]) => [name].flat(), + }, + { name: 'ParenNameMaybe', symbols: ['Name'], postprocess: id }, + { name: 'ParenNameMaybe', symbols: ['Name', 'Etal'], postprocess: ([n]) => n }, + { + name: 'ParenNameMaybe', + symbols: ['ParenNameMaybe', lexer.has('__') ? { type: '__' } : __, 'ParenNameMaybe'], + postprocess: ([n, , nn]) => ({ ...n, ...nn, family: n.family + nn.family }), + }, + { + name: 'ParenNameMaybe', + symbols: [ + 'ParenNameMaybe', + lexer.has('__') ? { type: '__' } : __, + lexer.has('Lowword') ? { type: 'Lowword' } : Lowword, + ], + postprocess: ([n, , nn]) => ({ ...n, family: n.family + nn }), + }, + { name: 'Etal$ebnf$1', symbols: [lexer.has('__') ? { type: '__' } : __], postprocess: id }, + { name: 'Etal$ebnf$1', symbols: [], postprocess: () => null }, + { + name: 'Etal', + symbols: ['Etal$ebnf$1', lexer.has('Et') ? { type: 'Et' } : Et], + postprocess: (etal) => null, + }, + { + name: 'Name', + symbols: ['Initials', lexer.has('__') ? { type: '__' } : __, 'LastName'], + postprocess: ([initials, , name]) => ({ given: initials.join(''), ...name }), + }, + { name: 'Name', symbols: ['LastName'], postprocess: id }, + { name: 'LastName', symbols: ['SingleName'], postprocess: id }, + { name: 'LastName', symbols: ['HyphenName'], postprocess: id }, + { name: 'Comp', symbols: [lexer.has('And') ? { type: 'And' } : And], postprocess: id }, + { name: 'Comp', symbols: [lexer.has('Amp') ? { type: 'Amp' } : Amp], postprocess: id }, + { + name: 'HyphenName', + symbols: ['SingleName', lexer.has('Dash') ? { type: 'Dash' } : Dash, 'SingleName'], + postprocess: ([first, d, last]) => ({ + family: `${getFullName(first) + d + getFullName(last)}`, + }), + }, + { + name: 'SingleName', + symbols: ['BoringNameMaybe'], + postprocess: ([name]) => ({ family: name }), + }, + { name: 'SingleName', symbols: ['DutchName'], postprocess: id }, + { name: 'SingleName', symbols: ['OReilly'], postprocess: id }, + { name: 'SingleName', symbols: ['McConnel'], postprocess: id }, + { name: 'SingleName', symbols: ['SpanishName'], postprocess: id }, + { name: 'Initials', symbols: ['Initial'] }, + { name: 'Initials$ebnf$1', symbols: [] }, + { + name: 'Initials$ebnf$1', + symbols: ['Initials$ebnf$1', lexer.has('__') ? { type: '__' } : __], + postprocess: (d) => d[0].concat([d[1]]), + }, + { name: 'Initials', symbols: ['Initials', 'Initials$ebnf$1', 'Initial'] }, + { + name: 'Initial', + symbols: [lexer.has('Cap') ? { type: 'Cap' } : Cap, lexer.has('Dot') ? { type: 'Dot' } : Dot], + postprocess: id, + }, + { + name: 'SpanishName', + symbols: ['BoringNameMaybe', lexer.has('__') ? { type: '__' } : __, 'BoringNameMaybe'], + postprocess: ([first, , last]) => ({ + family: `${first} ${last}`, + }), + }, + { + name: 'DutchName', + symbols: ['DutchPrefix', lexer.has('__') ? { type: '__' } : __, 'BoringNameMaybe'], + postprocess: ([pref, space, rest]) => ({ + family: rest, + 'non-dropping-particle': pref.join(''), + }), + }, + { + name: 'OReilly', + symbols: ['BoringNameMaybe', { literal: "'" }, 'BoringNameMaybe'], + postprocess: ([o, a, name]) => ({ family: o + a + name }), + }, + { + name: 'McConnel', + symbols: [lexer.has('Mc') ? { type: 'Mc' } : Mc, 'BoringNameMaybe'], + postprocess: (name) => ({ family: name.join('') }), + }, + { name: 'BoringNameMaybe$ebnf$1', symbols: [] }, + { + name: 'BoringNameMaybe$ebnf$1', + symbols: ['BoringNameMaybe$ebnf$1', lexer.has('Lowword') ? { type: 'Lowword' } : Lowword], + postprocess: (d) => d[0].concat([d[1]]), + }, + { + name: 'BoringNameMaybe', + symbols: [lexer.has('Cap') ? { type: 'Cap' } : Cap, 'BoringNameMaybe$ebnf$1'], + postprocess: ([cap, rest]) => `${cap}${rest.join('')}`, + }, + { name: 'BoringWord$ebnf$1', symbols: [lexer.has('Low') ? { type: 'Low' } : Low] }, + { + name: 'BoringWord$ebnf$1', + symbols: ['BoringWord$ebnf$1', lexer.has('Low') ? { type: 'Low' } : Low], + postprocess: (d) => d[0].concat([d[1]]), + }, + { name: 'BoringWord', symbols: ['BoringWord$ebnf$1'], postprocess: (word) => word.join('') }, + { name: 'DutchPrefix', symbols: [lexer.has('DutchPref') ? { type: 'DutchPref' } : DutchPref] }, + { + name: 'DutchPrefix', + symbols: [ + 'DutchPrefix', + lexer.has('__') ? { type: '__' } : __, + lexer.has('DutchPref') ? { type: 'DutchPref' } : DutchPref, + ], + }, + { + name: 'Year', + symbols: [lexer.has('Year') ? { type: 'Year' } : Year], + postprocess: ([year]) => [`${year}`.replace(/\./g, '').toUpperCase()], + }, + { + name: 'Year$ebnf$1', + symbols: [lexer.has('Dash') ? { type: 'Dash' } : Dash], + postprocess: id, + }, + { name: 'Year$ebnf$1', symbols: [], postprocess: () => null }, + { + name: 'Year', + symbols: [ + lexer.has('Year') ? { type: 'Year' } : Year, + 'Year$ebnf$1', + lexer.has('Lowword') ? { type: 'Lowword' } : Lowword, + ], + postprocess: ([year, , low]) => [year + low], + }, + { + name: 'Year', + symbols: ['Year', lexer.has('Slash') ? { type: 'Slash' } : Slash, 'Year'], + postprocess: (content) => { + const [year, sl, year2] = content + return [...year2, ...year] + }, + }, + { name: 'Year$ebnf$2', symbols: [lexer.has('Number') ? { type: 'Number' } : Number] }, + { + name: 'Year$ebnf$2', + symbols: ['Year$ebnf$2', lexer.has('Number') ? { type: 'Number' } : Number], + postprocess: (d) => d[0].concat([d[1]]), + }, + { name: 'Year$ebnf$3', symbols: [] }, + { + name: 'Year$ebnf$3', + symbols: ['Year$ebnf$3', lexer.has('__') ? { type: '__' } : __], + postprocess: (d) => d[0].concat([d[1]]), + }, + { + name: 'Year', + symbols: ['Year$ebnf$2', 'Year$ebnf$3', lexer.has('BCE') ? { type: 'BCE' } : BCE], + postprocess: ([num, , rest]) => [`${/b\.?c\.?/i.test(rest) ? '-' : ''}${num}`], + }, + { + name: 'Year', + symbols: [ + lexer.has('Ca') ? { type: 'Ca' } : Ca, + lexer.has('__') ? { type: '__' } : __, + 'Year', + ], + postprocess: ([ca, , year]) => [`${year}`], + }, ], - ParserStart: "Input", -}; + ParserStart: 'Input', +} -export default grammar; +export default grammar diff --git a/libs/citations/parse-text-cite/src/lib/lexer.ts b/libs/citations/parse-text-cite/src/lib/lexer.ts index 60ff19a0..537af04c 100755 --- a/libs/citations/parse-text-cite/src/lib/lexer.ts +++ b/libs/citations/parse-text-cite/src/lib/lexer.ts @@ -1,6 +1,7 @@ import moo from 'moo' console.log(moo) export const lexer = moo.compile({ + // eslint-disable-next-line __: /[ \t ]+/u, //_: /[ \t]*/u, Year: /(?:\b\d{4}(?=[a-z]|\b)|n\.d\.?)/u, diff --git a/libs/citations/parse-text-cite/src/lib/parse-text-cite.spec.ts b/libs/citations/parse-text-cite/src/lib/parse-text-cite.spec.ts index 721b7062..0aca0dd6 100755 --- a/libs/citations/parse-text-cite/src/lib/parse-text-cite.spec.ts +++ b/libs/citations/parse-text-cite/src/lib/parse-text-cite.spec.ts @@ -1,6 +1,6 @@ -import { tests } from './testcites' -import { names } from './testnames' -import { parseTextCite } from './parse-text-cite' +import { tests } from './testcites.js' +import { names } from './testnames.js' +import { parseTextCite } from './parse-text-cite.js' import nearley, { Parser } from 'nearley' const MODE: 'dev' | 'test' = 'test' @@ -11,7 +11,7 @@ const MODE: 'dev' | 'test' = 'test' type ContentArr = [ description: string, input: string, - result: string | boolean | Record + result: string | boolean | Record, ] type Table = [apa: string, desc: string, content: ContentArr[]][] @@ -28,13 +28,7 @@ type Content = { const tableReducer = (testdata: TestData) => Object.entries(testdata).reduce( - ( - acc: Table, - [apa, val]: [ - apa: string, - val: { description: string; content: Content[] } - ] - ) => { + (acc: Table, [apa, val]: [apa: string, val: { description: string; content: Content[] }]) => { const { description, content } = val const contarr: ContentArr[] = content.map((c: Content) => { @@ -47,22 +41,18 @@ const tableReducer = (testdata: TestData) => acc.push(tableEntry) return acc }, - [] + [], ) const citeTable = tableReducer(tests) const nameTable = tableReducer(names) -//@ts-ignore +//@ts-expect-error shhh if (MODE === 'dev') { describe.each(nameTable)('%s: %s', (apa, desc, content) => { it.each(content)( '%s %s', - ( - desc: string, - inp: string, - res: boolean | string | Record - ) => { + (desc: string, inp: string, res: boolean | string | Record) => { const parser = // eslint-disable-next-line // @ts-ignore @@ -81,28 +71,25 @@ if (MODE === 'dev') { } catch (e) { expect(res).toBeFalsy() } - } + }, ) }) } -describe.each(citeTable)( - '%s: %s', - (apa: string, desc: string, content: ContentArr[]) => { - it.each(content)('%s %s', (desc, inp, res) => { - const parser = - // eslint-disable-next-line - // @ts-ignore - MODE === 'dev' - ? // eslint-disable-next-line - // @ts-ignore - new nearley.Parser(nearley.Grammar.fromCompiled(grammar)) - : null - parser && parser.feed(inp) - const results = parser ? parser.results : parseTextCite(inp) - // console.dir(results, { depth: null }) - const expectancy = Array.isArray(res) ? res : [res] - expect(results).toEqual(expectancy) - }) - } -) +describe.each(citeTable)('%s: %s', (apa: string, desc: string, content: ContentArr[]) => { + it.each(content)('%s %s', (desc, inp, res) => { + const parser = + // eslint-disable-next-line + // @ts-ignore + MODE === 'dev' + ? // eslint-disable-next-line + // @ts-ignore + new nearley.Parser(nearley.Grammar.fromCompiled(grammar)) + : null + parser && parser.feed(inp) + const results = parser ? parser.results : parseTextCite(inp) + // console.dir(results, { depth: null }) + const expectancy = Array.isArray(res) ? res : [res] + expect(results).toEqual(expectancy) + }) +}) diff --git a/libs/citations/parse-text-cite/src/lib/parse-text-cite.ts b/libs/citations/parse-text-cite/src/lib/parse-text-cite.ts index e5c097d1..754fd1da 100755 --- a/libs/citations/parse-text-cite/src/lib/parse-text-cite.ts +++ b/libs/citations/parse-text-cite/src/lib/parse-text-cite.ts @@ -1,5 +1,5 @@ import nearley from 'nearley' -import grammar from './apa' +import grammar from './apa.js' import { Data as CSL } from 'csl-json' export interface Citation { @@ -36,10 +36,7 @@ export const parseTextCite = (string: string, options?: Options) => { const splitCites = string .split(')') - .map( - (c: string, idx, arr) => - `${c}${arr.length > 1 && idx === arr.length - 1 ? '' : ')'}` - ) + .map((c: string, idx, arr) => `${c}${arr.length > 1 && idx === arr.length - 1 ? '' : ')'}`) try { parser.feed(string) @@ -84,10 +81,7 @@ function recoverOriginalCitation(cite: (string | Citation)[], ogText: string) { const originalCites = narrowString .split(')') .filter((c) => c) - .map( - (c: string, idx, arr) => - `${c}${arr.length > 1 && idx === arr.length - 1 ? '' : ')'}` - ) + .map((c: string, idx, arr) => `${c}${arr.length > 1 && idx === arr.length - 1 ? '' : ')'}`) let stupidCounterYouShouldKnowBetter = 0 diff --git a/libs/citations/parse-text-cite/src/lib/testcites copy.ts b/libs/citations/parse-text-cite/src/lib/testcites copy.ts index 557464b7..d6ed6a2a 100755 --- a/libs/citations/parse-text-cite/src/lib/testcites copy.ts +++ b/libs/citations/parse-text-cite/src/lib/testcites copy.ts @@ -1,4 +1,4 @@ -import type { TestData } from './parse-text-cite.spec' +import type { TestData } from './parse-text-cite.spec.js' export const tests: TestData = { 'APA-8-6': { description: `which use a semi-colon`, diff --git a/libs/citations/parse-text-cite/src/lib/testcites.ts b/libs/citations/parse-text-cite/src/lib/testcites.ts index be09b320..1390a897 100755 --- a/libs/citations/parse-text-cite/src/lib/testcites.ts +++ b/libs/citations/parse-text-cite/src/lib/testcites.ts @@ -1,4 +1,4 @@ -import type { TestData } from './parse-text-cite.spec' +import type { TestData } from './parse-text-cite.spec.js' export const tests: TestData = { 'Custom-Shit': { description: 'own cases i wanna catch', @@ -299,9 +299,7 @@ export const tests: TestData = { { id: 'vanRavenzwaai2016', itemData: { - author: [ - { family: 'Ravenzwaai', 'non-dropping-particle': 'van' }, - ], + author: [{ family: 'Ravenzwaai', 'non-dropping-particle': 'van' }], issued: { 'date-parts': [['2016']] }, }, }, @@ -390,11 +388,9 @@ export const tests: TestData = { }, ], properties: { noteIndex: 0 }, - originalText: - '(Adams et al., 2019; Shumway & Shulman, 2015; Westinghouse, 2017)', + originalText: '(Adams et al., 2019; Shumway & Shulman, 2015; Westinghouse, 2017)', }, - input: - '(Adams et al., 2019; Shumway & Shulman, 2015; Westinghouse, 2017)', + input: '(Adams et al., 2019; Shumway & Shulman, 2015; Westinghouse, 2017)', }, { description: 'tough for some reason', @@ -421,8 +417,7 @@ export const tests: TestData = { ], properties: { noteIndex: 0 }, - originalText: - '(Gillich et al., 2019; van Moorselaar & Slagter, 2019)', + originalText: '(Gillich et al., 2019; van Moorselaar & Slagter, 2019)', }, input: '(Gillich et al., 2019; van Moorselaar & Slagter, 2019)', }, @@ -436,10 +431,7 @@ export const tests: TestData = { { id: 'Vallée-Tourangeau2020', itemData: { - author: [ - { family: 'Vallée-Tourangeau' }, - { family: 'March' }, - ], + author: [{ family: 'Vallée-Tourangeau' }, { family: 'March' }], issued: { 'date-parts': [['2020']] }, }, }, @@ -478,8 +470,7 @@ export const tests: TestData = { ], properties: { noteIndex: 0 }, - originalText: - '(Gillich et al., 2019; van Moorselaar & Slagter, 2019)', + originalText: '(Gillich et al., 2019; van Moorselaar & Slagter, 2019)', }, ], input: @@ -561,33 +552,21 @@ export const tests: TestData = { { id: 'Carraway2013', itemData: { - author: [ - { family: 'Carraway' }, - { family: 'Guy' }, - { family: 'Man' }, - ], + author: [{ family: 'Carraway' }, { family: 'Guy' }, { family: 'Man' }], issued: { 'date-parts': [['2013']] }, }, }, { id: 'Carraway2014', itemData: { - author: [ - { family: 'Carraway' }, - { family: 'Guy' }, - { family: 'Man' }, - ], + author: [{ family: 'Carraway' }, { family: 'Guy' }, { family: 'Man' }], issued: { 'date-parts': [['2014']] }, }, }, { id: 'Carraway2019', itemData: { - author: [ - { family: 'Carraway' }, - { family: 'Guy' }, - { family: 'Man' }, - ], + author: [{ family: 'Carraway' }, { family: 'Guy' }, { family: 'Man' }], issued: { 'date-parts': [['2019']] }, }, }, @@ -729,8 +708,7 @@ export const tests: TestData = { }, ], properties: { noteIndex: 0 }, - originalText: - '(Centers for Disease Control and Prevention, 2019, p. 10)', + originalText: '(Centers for Disease Control and Prevention, 2019, p. 10)', }, input: '(Centers for Disease Control and Prevention, 2019, p. 10)', }, @@ -842,9 +820,7 @@ export const tests: TestData = { { id: 'BeckInstituteforCognitiveBehaviourTherapy2012', itemData: { - author: [ - { family: 'BeckInstituteforCognitiveBehaviourTherapy' }, - ], + author: [{ family: 'BeckInstituteforCognitiveBehaviourTherapy' }], issued: { 'date-parts': [['2012']] }, }, label: 'none', @@ -852,11 +828,9 @@ export const tests: TestData = { }, ], properties: { noteIndex: 0 }, - originalText: - '(Beck Institute for Cognitive Behaviour Therapy, 2012, 1:30:40)', + originalText: '(Beck Institute for Cognitive Behaviour Therapy, 2012, 1:30:40)', }, - input: - '(Beck Institute for Cognitive Behaviour Therapy, 2012, 1:30:40)', + input: '(Beck Institute for Cognitive Behaviour Therapy, 2012, 1:30:40)', }, { description: '', @@ -965,8 +939,7 @@ export const tests: TestData = { }, ], properties: { noteIndex: 0 }, - originalText: - '(Shakespeare, 1623/1995, 1.3.36–37; Johnson, 2021, p. 1)', + originalText: '(Shakespeare, 1623/1995, 1.3.36–37; Johnson, 2021, p. 1)', }, input: '(Shakespeare, 1623/1995, 1.3.36–37; Johnson, 2021, p. 1)', }, @@ -1100,8 +1073,7 @@ export const tests: TestData = { }, ], properties: { noteIndex: 0 }, - originalText: - '(American Educational Research Association et al., 2014)', + originalText: '(American Educational Research Association et al., 2014)', }, input: '(American Educational Research Association et al., 2014)', }, @@ -1119,11 +1091,7 @@ export const tests: TestData = { { id: 'Kapoor2017', itemData: { - author: [ - { family: 'Kapoor' }, - { family: 'Bloom' }, - { family: 'Montez' }, - ], + author: [{ family: 'Kapoor' }, { family: 'Bloom' }, { family: 'Montez' }], issued: { 'date-parts': [['2017']] }, }, }, @@ -1141,11 +1109,7 @@ export const tests: TestData = { { id: 'Kapoor2017', itemData: { - author: [ - { family: 'Kapoor' }, - { family: 'Bloom' }, - { family: 'Zucker' }, - ], + author: [{ family: 'Kapoor' }, { family: 'Bloom' }, { family: 'Zucker' }], issued: { 'date-parts': [['2017']] }, }, }, @@ -1341,10 +1305,7 @@ export const tests: TestData = { { id: 'Taylor2015', itemData: { - author: [ - { family: 'Taylor', given: 'J M' }, - { family: 'Neimeyer' }, - ], + author: [{ family: 'Taylor', given: 'J M' }, { family: 'Neimeyer' }], issued: { 'date-parts': [['2015']] }, }, }, @@ -1362,8 +1323,7 @@ export const tests: TestData = { input: '(J. M. Taylor & Neimeyer, 2015; T. Taylor, 2014)', }, { - description: - 'When initials are also the same, revert to standard format', + description: 'When initials are also the same, revert to standard format', result: { citationId: 'CITE-X', citationItems: [ diff --git a/libs/citations/parse-text-cite/src/lib/testnames.ts b/libs/citations/parse-text-cite/src/lib/testnames.ts index 498a28a8..1da8a7c4 100755 --- a/libs/citations/parse-text-cite/src/lib/testnames.ts +++ b/libs/citations/parse-text-cite/src/lib/testnames.ts @@ -1,4 +1,4 @@ -import { TestData } from './parse-text-cite.spec' +import { TestData } from './parse-text-cite.spec.js' export const names: TestData = { 'Boring names': { diff --git a/libs/jast/jast-util-from-csl/src/index.ts b/libs/jast/jast-util-from-csl/src/index.ts index c9ffd47b..8cfe19a3 100755 --- a/libs/jast/jast-util-from-csl/src/index.ts +++ b/libs/jast/jast-util-from-csl/src/index.ts @@ -1 +1 @@ -export * from './lib/csl-to-jast' +export * from './lib/csl-to-jast.js' diff --git a/libs/jast/jast-util-to-csl/src/index.ts b/libs/jast/jast-util-to-csl/src/index.ts index 944bb3bb..d594f30b 100755 --- a/libs/jast/jast-util-to-csl/src/index.ts +++ b/libs/jast/jast-util-to-csl/src/index.ts @@ -1 +1 @@ -export * from './lib/jast-util-to-csl' +export * from './lib/jast-util-to-csl.js' diff --git a/libs/jast/jast-util-to-texast/src/index.ts b/libs/jast/jast-util-to-texast/src/index.ts index fb1c8064..e0dd3886 100755 --- a/libs/jast/jast-util-to-texast/src/index.ts +++ b/libs/jast/jast-util-to-texast/src/index.ts @@ -1,2 +1,2 @@ -export * from './lib/jast-util-to-texast' -export * from './lib/types' +export * from './lib/jast-util-to-texast.js' +export * from './lib/types.js' diff --git a/libs/jast/jast-util-to-texast/src/lib/handlers/index.ts b/libs/jast/jast-util-to-texast/src/lib/handlers/index.ts index 462e59b9..9ef9487e 100755 --- a/libs/jast/jast-util-to-texast/src/lib/handlers/index.ts +++ b/libs/jast/jast-util-to-texast/src/lib/handlers/index.ts @@ -24,7 +24,7 @@ import { graphic } from './graphic' import { extLink } from './extLink' import { p } from './p' import { dispQuote } from './disp-quote' -export * from './italic' +export * from './italic.js' export const handlers = { root, diff --git a/libs/jast/jast/src/index.ts b/libs/jast/jast/src/index.ts index 925b03f0..44fc561f 100755 --- a/libs/jast/jast/src/index.ts +++ b/libs/jast/jast/src/index.ts @@ -1,2 +1,2 @@ -export * from './lib/rejour' -export * from './lib/jats' +export * from './lib/rejour.js' +export * from './lib/jats.js' diff --git a/libs/jast/jast/src/lib/jats.ts b/libs/jast/jast/src/lib/jats.ts index ebc8ad9d..73f93294 100755 --- a/libs/jast/jast/src/lib/jats.ts +++ b/libs/jast/jast/src/lib/jats.ts @@ -1,6 +1,6 @@ -import * as Primitive from './xml-primitives' +import * as Primitive from './xml-primitives.js' import type { Literal as UnistLiteral, Node as UnistNode } from 'unist' -import type { RequiredMap } from './rejour' +import type { RequiredMap } from './rejour.js' import type { ValuesType } from 'utility-types' // Source files: // http://localhost:3001/jats.xsd @@ -7749,10 +7749,7 @@ export interface ProcessingMetaChildrenMap { restrictedBy?: RestrictedBy[] } -type ProcessingMetaTypeUnistNodeTagset = - | 'archiving' - | 'authoring' - | 'publishing' +type ProcessingMetaTypeUnistNodeTagset = 'archiving' | 'authoring' | 'publishing' type ProcessingMetaTypeMathmlVersion = '2.0' | '3.0' @@ -11081,11 +11078,7 @@ export interface SupplementaryMaterialChildrenMap { type SupplementaryMaterialTypeOrientation = 'landscape' | 'portrait' -type SupplementaryMaterialTypePosition = - | 'anchor' - | 'background' - | 'float' - | 'margin' +type SupplementaryMaterialTypePosition = 'anchor' | 'background' | 'float' | 'margin' export interface Supplement extends UnistNode { type: 'element' diff --git a/libs/jast/jast/src/lib/rejour.ts b/libs/jast/jast/src/lib/rejour.ts index 2c503c56..902d7312 100755 --- a/libs/jast/jast/src/lib/rejour.ts +++ b/libs/jast/jast/src/lib/rejour.ts @@ -1,18 +1,16 @@ import { Instruction, Doctype, Attributes as XastAttributes } from 'xast' import { Node as UnistNode, Parent as UnistParent } from 'unist' -import { Text, Article, Content, Glossary, P, pMap } from './jats' +import { Text, Article, Content, Glossary, P, pMap } from './jats.js' import { RequiredKeys, ValuesType } from 'utility-types' -import { names } from './names' +import { names } from './names.js' export type NoUndefined = Exclude -export type ArrayValueMaybe = T extends any[] - ? ValuesType> - : NoUndefined -export type AllTypes | Record> = - ArrayValueMaybe> +export type ArrayValueMaybe = T extends any[] ? ValuesType> : NoUndefined +export type AllTypes | Record> = ArrayValueMaybe< + ValuesType +> -export type RequiredMap | Record> = - AllTypes +export type RequiredMap | Record> = AllTypes export interface Attributes { [name: string]: string | null | undefined | boolean | number @@ -38,9 +36,7 @@ export function isElement(node: UnistNode): node is Element { return node.hasOwnProperty('name') && node.hasOwnProperty('attributes') } -export function isParagraphContent( - node: UnistNode -): node is P['children'][number] { +export function isParagraphContent(node: UnistNode): node is P['children'][number] { return node.type === 'text' || (isElement(node) && node.name in pMap) } diff --git a/libs/notion/html-to-notion-blocks/src/index.ts b/libs/notion/html-to-notion-blocks/src/index.ts index 4c982e03..fd3db56a 100644 --- a/libs/notion/html-to-notion-blocks/src/index.ts +++ b/libs/notion/html-to-notion-blocks/src/index.ts @@ -1 +1 @@ -export * from './lib/html-to-notion-blocks' +export * from './lib/html-to-notion-blocks.js' diff --git a/libs/ojs/ojs-client/src/index.ts b/libs/ojs/ojs-client/src/index.ts index 99fdbbbc..60716863 100755 --- a/libs/ojs/ojs-client/src/index.ts +++ b/libs/ojs/ojs-client/src/index.ts @@ -1,3 +1,3 @@ -export * from './lib/swagger-types' -export * from './lib/types' +export * from './lib/swagger-types.js' +export * from './lib/types.js' export { default } from './lib/ojs-client' diff --git a/libs/ojs/ojs-relatex/src/index.ts b/libs/ojs/ojs-relatex/src/index.ts index d8e2e59b..56764625 100755 --- a/libs/ojs/ojs-relatex/src/index.ts +++ b/libs/ojs/ojs-relatex/src/index.ts @@ -1 +1 @@ -export * from './lib/ojs-relatex' +export * from './lib/ojs-relatex.js' diff --git a/libs/ooxast/ooxast-util-citation-plugin/src/index.ts b/libs/ooxast/ooxast-util-citation-plugin/src/index.ts index c8a9f854..cfe443d5 100755 --- a/libs/ooxast/ooxast-util-citation-plugin/src/index.ts +++ b/libs/ooxast/ooxast-util-citation-plugin/src/index.ts @@ -1 +1 @@ -export * from './lib/ooxast-util-citation-plugin' +export * from './lib/ooxast-util-citation-plugin.js' diff --git a/libs/ooxast/ooxast-util-citation-plugin/src/lib/ooxast-util-citation-plugin.spec.ts b/libs/ooxast/ooxast-util-citation-plugin/src/lib/ooxast-util-citation-plugin.spec.ts index 038723fe..524b3c60 100755 --- a/libs/ooxast/ooxast-util-citation-plugin/src/lib/ooxast-util-citation-plugin.spec.ts +++ b/libs/ooxast/ooxast-util-citation-plugin/src/lib/ooxast-util-citation-plugin.spec.ts @@ -1,10 +1,8 @@ -import { Node } from 'unist' -import { detectCitePlugin } from './ooxast-util-citation-plugin' +import { detectCitePlugin } from './ooxast-util-citation-plugin.js' import fs from 'fs' import { docxToVFile } from 'docx-to-vfile' import reoffParse from 'reoff-parse' import { unified } from 'unified' -import path from 'path' const fromDocx = async (file: string) => { const arr = new Uint8Array(await fs.promises.readFile(file)) @@ -18,7 +16,7 @@ const fromDocx = async (file: string) => { const testfile = (type: string) => new URL( `../../../../processors/docx-to-tex/src/test/fixtures/${type}/index.docx`, - import.meta.url + import.meta.url, ).pathname describe('ooxast-util-citation-plugin', () => { diff --git a/libs/ooxast/ooxast-util-citations/src/index.ts b/libs/ooxast/ooxast-util-citations/src/index.ts index 5cce0f06..896a86d6 100755 --- a/libs/ooxast/ooxast-util-citations/src/index.ts +++ b/libs/ooxast/ooxast-util-citations/src/index.ts @@ -1,2 +1,2 @@ -export * from './lib/ooxast-util-citations' -export * from './lib/types' +export * from './lib/ooxast-util-citations.js' +export * from './lib/types.js' diff --git a/libs/ooxast/ooxast-util-citations/src/lib/constructMendeleyCitation.ts b/libs/ooxast/ooxast-util-citations/src/lib/constructMendeleyCitation.ts index a15eff96..f21bedfd 100755 --- a/libs/ooxast/ooxast-util-citations/src/lib/constructMendeleyCitation.ts +++ b/libs/ooxast/ooxast-util-citations/src/lib/constructMendeleyCitation.ts @@ -1,14 +1,13 @@ -import { Citation, CitationItem, Mendeley, MendeleyCitation } from './types' +import { Citation, CitationItem, Mendeley, MendeleyCitation } from './types.js' import { Data as CSL } from 'csl-json' -import { findRef } from './findRefInBib' +import { findRef } from './findRefInBib.js' export function constructMendeleyCitation( curr: Citation, index: number, - bibliography?: CSL[] + bibliography?: CSL[], ): MendeleyCitation { - const schema = - 'https://github.com/citation-style-language/schema/raw/master/csl-citation.json' + const schema = 'https://github.com/citation-style-language/schema/raw/master/csl-citation.json' const mendeley: Mendeley = { formattedCitation: curr.originalText || '', diff --git a/libs/ooxast/ooxast-util-citations/src/lib/constructZoteroCitation.ts b/libs/ooxast/ooxast-util-citations/src/lib/constructZoteroCitation.ts index 3507a563..9784d349 100755 --- a/libs/ooxast/ooxast-util-citations/src/lib/constructZoteroCitation.ts +++ b/libs/ooxast/ooxast-util-citations/src/lib/constructZoteroCitation.ts @@ -1,19 +1,13 @@ -import { findRef } from './findRefInBib' -import { - Citation, - CitationItem, - ZoteroCitation, - ZoteroProperties, -} from './types' +import { findRef } from './findRefInBib.js' +import { Citation, CitationItem, ZoteroCitation, ZoteroProperties } from './types.js' import { Data as CSL } from 'csl-json' export function constructZoteroCitation( curr: Citation, index: number, - bibliography?: CSL[] + bibliography?: CSL[], ): ZoteroCitation { - const schema = - 'https://github.com/citation-style-language/schema/raw/master/csl-citation.json' + const schema = 'https://github.com/citation-style-language/schema/raw/master/csl-citation.json' const properties: ZoteroProperties = { noteIndex: 0, diff --git a/libs/ooxast/ooxast-util-citations/src/lib/findRefInBib.ts b/libs/ooxast/ooxast-util-citations/src/lib/findRefInBib.ts index 29f33c0f..4379a76c 100755 --- a/libs/ooxast/ooxast-util-citations/src/lib/findRefInBib.ts +++ b/libs/ooxast/ooxast-util-citations/src/lib/findRefInBib.ts @@ -1,16 +1,13 @@ import { dateSim } from 'csl-consolidate' -import { CitationItem } from './types' +import { CitationItem } from './types.js' import similarity from 'similarity' import { Data as CSL } from 'csl-json' -export function findRef( - citeItem: CitationItem, - bibliography: CSL[] -): CitationItem { +export function findRef(citeItem: CitationItem, bibliography: CSL[]): CitationItem { // we'll take it if it has 90% match with the author and the year, except if there are multiple thiingies const cite = citeItem.itemData const gottemInOne = bibliography.find( - (bib) => bib.id && (bib.id === cite.id || bib.id === citeItem.id) + (bib) => bib.id && (bib.id === cite.id || bib.id === citeItem.id), ) // console.dir(citeItem, { depth: null }) // console.dir(gottemInOne, { depth: null }) @@ -30,10 +27,7 @@ export function findRef( cite.author.reduce((acc, curr, index) => { if (!csl?.author?.[index]) return acc - acc += similarity( - curr?.family || '', - csl?.author?.[index]?.family || 'aipugbbrwshotnat' - ) + acc += similarity(curr?.family || '', csl?.author?.[index]?.family || 'aipugbbrwshotnat') return acc }, 0) / (cite?.author?.length || 100) diff --git a/libs/ooxast/ooxast-util-citations/src/lib/ooxast-ooxast-util-citations.spec.ts b/libs/ooxast/ooxast-util-citations/src/lib/ooxast-ooxast-util-citations.spec.ts index 009714f8..d6be4731 100755 --- a/libs/ooxast/ooxast-util-citations/src/lib/ooxast-ooxast-util-citations.spec.ts +++ b/libs/ooxast/ooxast-util-citations/src/lib/ooxast-ooxast-util-citations.spec.ts @@ -1,22 +1,15 @@ -import { findCitations } from './ooxast-util-citations' +import { findCitations } from './ooxast-util-citations.js' import { readFileSync, writeFileSync } from 'fs' -import { join } from 'path' describe('ooxastOoxastUtilCitations', () => { const ooxast = JSON.parse( readFileSync( - new URL( - '../../../../ooxast/ooxast-util-remove-rsid/src/lib/removedRsid', - import.meta.url - ), - { encoding: 'utf-8' } - ) + new URL('../../../../ooxast/ooxast-util-remove-rsid/src/lib/removedRsid', import.meta.url), + { encoding: 'utf-8' }, + ), ) const citetree = findCitations(ooxast) - writeFileSync( - new URL('citetree.json', import.meta.url), - JSON.stringify(citetree, null, 2) - ) + writeFileSync(new URL('citetree.json', import.meta.url), JSON.stringify(citetree, null, 2)) it('should work', () => { expect(citetree).toEqual('ooxast-ooxast-util-citations') }) diff --git a/libs/ooxast/ooxast-util-citations/src/lib/ooxast-util-citations.ts b/libs/ooxast/ooxast-util-citations/src/lib/ooxast-util-citations.ts index 5c3a4bd4..f37cc038 100755 --- a/libs/ooxast/ooxast-util-citations/src/lib/ooxast-util-citations.ts +++ b/libs/ooxast/ooxast-util-citations/src/lib/ooxast-util-citations.ts @@ -9,11 +9,11 @@ import { toString } from 'xast-util-to-string' import { select as unistSelect } from 'unist-util-select' import { x } from 'xastscript' import { Data as CSL } from 'csl-json' -import { CiteOutput, Citation, MendeleyCitation, ZoteroCitation } from './types' +import { CiteOutput, Citation, MendeleyCitation, ZoteroCitation } from './types.js' import { detectCitePlugin } from 'ooxast-util-citation-plugin' import { VFile } from 'vfile' -import { constructMendeleyCitation } from './constructMendeleyCitation' -import { constructZoteroCitation } from './constructZoteroCitation' +import { constructMendeleyCitation } from './constructMendeleyCitation.js' +import { constructZoteroCitation } from './constructZoteroCitation.js' const isInstrT = convertElement('w:instrText') const isP = convertElement

('w:p') diff --git a/libs/ooxast/ooxast-util-citations/tsconfig.lib.json b/libs/ooxast/ooxast-util-citations/tsconfig.lib.json index 5c108b84..53047cda 100755 --- a/libs/ooxast/ooxast-util-citations/tsconfig.lib.json +++ b/libs/ooxast/ooxast-util-citations/tsconfig.lib.json @@ -6,5 +6,5 @@ "types": ["node"] }, "exclude": ["**/*.spec.ts", "**/*.test.ts", "jest.config.ts"], - "include": ["**/*.ts"] + "include": ["src/**/*.ts"] } diff --git a/libs/ooxast/ooxast-util-get-style/src/index.ts b/libs/ooxast/ooxast-util-get-style/src/index.ts index 36b42c04..336f2821 100755 --- a/libs/ooxast/ooxast-util-get-style/src/index.ts +++ b/libs/ooxast/ooxast-util-get-style/src/index.ts @@ -1,2 +1,2 @@ -export * from './lib/ooxast-util-get-pstyle' -export * from './lib/ooxast-util-get-rstyle' +export * from './lib/ooxast-util-get-pstyle.js' +export * from './lib/ooxast-util-get-rstyle.js' diff --git a/libs/ooxast/ooxast-util-get-style/src/lib/ooxast-util-get-pstyle.spec.ts b/libs/ooxast/ooxast-util-get-style/src/lib/ooxast-util-get-pstyle.spec.ts index 6ce2e945..ddcd39ba 100755 --- a/libs/ooxast/ooxast-util-get-style/src/lib/ooxast-util-get-pstyle.spec.ts +++ b/libs/ooxast/ooxast-util-get-style/src/lib/ooxast-util-get-pstyle.spec.ts @@ -1,5 +1,5 @@ import { P, PPr, R } from 'ooxast' -import { getPStyle } from './ooxast-util-get-pstyle' +import { getPStyle } from './ooxast-util-get-pstyle.js' export const test: any = { type: 'element', diff --git a/libs/ooxast/ooxast-util-get-style/src/lib/ooxast-util-get-rstyle.spec.ts b/libs/ooxast/ooxast-util-get-style/src/lib/ooxast-util-get-rstyle.spec.ts index 149da0de..6ca808b2 100755 --- a/libs/ooxast/ooxast-util-get-style/src/lib/ooxast-util-get-rstyle.spec.ts +++ b/libs/ooxast/ooxast-util-get-style/src/lib/ooxast-util-get-rstyle.spec.ts @@ -1,5 +1,5 @@ import { P, PPr, R } from 'ooxast' -import { getPStyle } from './ooxast-util-get-pstyle' +import { getPStyle } from './ooxast-util-get-pstyle.js' export const test: any = { type: 'element', diff --git a/libs/ooxast/ooxast-util-parse-bib-browser/src/index.ts b/libs/ooxast/ooxast-util-parse-bib-browser/src/index.ts index 025219ee..fdfa6841 100755 --- a/libs/ooxast/ooxast-util-parse-bib-browser/src/index.ts +++ b/libs/ooxast/ooxast-util-parse-bib-browser/src/index.ts @@ -1 +1 @@ -export * from './lib/ooxast-util-parse-bib-browser' +export * from './lib/ooxast-util-parse-bib-browser.js' diff --git a/libs/ooxast/ooxast-util-parse-bib-node/src/index.ts b/libs/ooxast/ooxast-util-parse-bib-node/src/index.ts index ffab7ec9..4ea5af53 100755 --- a/libs/ooxast/ooxast-util-parse-bib-node/src/index.ts +++ b/libs/ooxast/ooxast-util-parse-bib-node/src/index.ts @@ -1 +1 @@ -export * from './lib/ooxast-util-parse-bib' +export * from './lib/ooxast-util-parse-bib.js' diff --git a/libs/ooxast/ooxast-util-parse-bib/src/index-browser.ts b/libs/ooxast/ooxast-util-parse-bib/src/index-browser.ts index 025219ee..fdfa6841 100755 --- a/libs/ooxast/ooxast-util-parse-bib/src/index-browser.ts +++ b/libs/ooxast/ooxast-util-parse-bib/src/index-browser.ts @@ -1 +1 @@ -export * from './lib/ooxast-util-parse-bib-browser' +export * from './lib/ooxast-util-parse-bib-browser.js' diff --git a/libs/ooxast/ooxast-util-parse-bib/src/index.ts b/libs/ooxast/ooxast-util-parse-bib/src/index.ts index ffab7ec9..4ea5af53 100755 --- a/libs/ooxast/ooxast-util-parse-bib/src/index.ts +++ b/libs/ooxast/ooxast-util-parse-bib/src/index.ts @@ -1 +1 @@ -export * from './lib/ooxast-util-parse-bib' +export * from './lib/ooxast-util-parse-bib.js' diff --git a/libs/ooxast/ooxast-util-parse-bib/src/lib/bib-to-csl-browser.ts b/libs/ooxast/ooxast-util-parse-bib/src/lib/bib-to-csl-browser.ts index 6d65c502..683dbe57 100755 --- a/libs/ooxast/ooxast-util-parse-bib/src/lib/bib-to-csl-browser.ts +++ b/libs/ooxast/ooxast-util-parse-bib/src/lib/bib-to-csl-browser.ts @@ -1,13 +1,13 @@ import { Data as CSL } from 'csl-json' -import { callAnystyleApi } from './anystyle-api' -import { findBib } from './find-bib' -import { fixBib } from './fix-csl' -import { Options } from './ooxast-util-parse-bib' +import { callAnystyleApi } from './anystyle-api.js' +import { findBib } from './find-bib.js' +import { fixBib } from './fix-csl.js' +import { Options } from './ooxast-util-parse-bib.js' import { Node } from 'ooxast' export async function bibToCSLBrowser( tree: Node, - options: Omit & { apiUrl: string } + options: Omit & { apiUrl: string }, ): Promise { const { apiUrl, apiParams, headers } = options const bib = findBib(tree) diff --git a/libs/ooxast/ooxast-util-parse-bib/src/lib/bib-to-csl-node.ts b/libs/ooxast/ooxast-util-parse-bib/src/lib/bib-to-csl-node.ts index 2d247086..3cf7a1c0 100755 --- a/libs/ooxast/ooxast-util-parse-bib/src/lib/bib-to-csl-node.ts +++ b/libs/ooxast/ooxast-util-parse-bib/src/lib/bib-to-csl-node.ts @@ -1,7 +1,7 @@ -import { callAnystyleApi } from './anystyle-api' -import { findBib } from './find-bib' -import { fixBib } from './fix-csl' -import { Options } from './ooxast-util-parse-bib' +import { callAnystyleApi } from './anystyle-api.js' +import { findBib } from './find-bib.js' +import { fixBib } from './fix-csl.js' +import { Options } from './ooxast-util-parse-bib.js' import { Data as CSL } from 'csl-json' import { Node } from 'ooxast' @@ -12,7 +12,7 @@ export async function bibToCSL(tree: Node, options: Options): Promise { const refs = bib.join('\n') if (!apiUrl || (!apiUrl && typeof window !== 'undefined')) { - const { callAnystyleCLI } = await import('./anystyle-cli') + const { callAnystyleCLI } = await import('./anystyle-cli.js') const parsedBib = await callAnystyleCLI(refs, anyStylePath) return fixBib(parsedBib) } diff --git a/libs/ooxast/ooxast-util-parse-bib/src/lib/ooxast-util-parse-bib-browser.ts b/libs/ooxast/ooxast-util-parse-bib/src/lib/ooxast-util-parse-bib-browser.ts index f3e878ac..1b344e1d 100755 --- a/libs/ooxast/ooxast-util-parse-bib/src/lib/ooxast-util-parse-bib-browser.ts +++ b/libs/ooxast/ooxast-util-parse-bib/src/lib/ooxast-util-parse-bib-browser.ts @@ -1,6 +1,6 @@ import { Node } from 'ooxast' import { consolidate } from 'csl-consolidate' -import { bibToCSLBrowser } from './bib-to-csl-browser' +import { bibToCSLBrowser } from './bib-to-csl-browser.js' export interface Options { apiUrl: string apiParams?: { param: string } diff --git a/libs/ooxast/ooxast-util-parse-bib/src/lib/ooxast-util-parse-bib.spec.ts b/libs/ooxast/ooxast-util-parse-bib/src/lib/ooxast-util-parse-bib.spec.ts index 2961c8f8..4e51711c 100755 --- a/libs/ooxast/ooxast-util-parse-bib/src/lib/ooxast-util-parse-bib.spec.ts +++ b/libs/ooxast/ooxast-util-parse-bib/src/lib/ooxast-util-parse-bib.spec.ts @@ -2,21 +2,13 @@ import { docxToVFile } from 'docx-to-vfile' import reoffParse from 'reoff-parse' import { readFile } from 'fs/promises' import { unified } from 'unified' -import { - callAnystyleApi, - callAnystyleCLI, - findBib, - bibToCSL, - parseBib, -} from './ooxast-util-parse-bib' -import { toString } from 'xast-util-to-string' -import { writeFileSync } from 'fs' +import { parseBib } from './ooxast-util-parse-bib.js' +import { findBib } from './find-bib.js' +import { bibToCSL } from './bib-to-csl-node.js' async function getTree() { // If in node, get the correct docx uintarray like so - const docxBuff = await readFile( - new URL('/../fixtures/index.docx', import.meta.url) - ) + const docxBuff = await readFile(new URL('/../fixtures/index.docx', import.meta.url)) const docxArr = new Uint8Array(docxBuff) // if in the browser, find some way diff --git a/libs/ooxast/ooxast-util-parse-bib/src/lib/ooxast-util-parse-bib.ts b/libs/ooxast/ooxast-util-parse-bib/src/lib/ooxast-util-parse-bib.ts index 379c5d89..d92ef219 100755 --- a/libs/ooxast/ooxast-util-parse-bib/src/lib/ooxast-util-parse-bib.ts +++ b/libs/ooxast/ooxast-util-parse-bib/src/lib/ooxast-util-parse-bib.ts @@ -1,6 +1,6 @@ import { Node } from 'ooxast' import { consolidate } from 'csl-consolidate' -import { bibToCSL } from './bib-to-csl-node' +import { bibToCSL } from './bib-to-csl-node.js' export interface Options { apiUrl?: string apiParams?: { param: string } diff --git a/libs/ooxast/ooxast-util-remove-rsid/src/index.ts b/libs/ooxast/ooxast-util-remove-rsid/src/index.ts index bd87177a..da11be47 100755 --- a/libs/ooxast/ooxast-util-remove-rsid/src/index.ts +++ b/libs/ooxast/ooxast-util-remove-rsid/src/index.ts @@ -1 +1 @@ -export { Options, ooxastUtilRemoveRsid } from './lib/ooxast-util-remove-rsid' +export { Options, ooxastUtilRemoveRsid } from './lib/ooxast-util-remove-rsid.js' diff --git a/libs/ooxast/ooxast-util-remove-rsid/src/lib/ooxast-util-remove-rsid.spec.ts b/libs/ooxast/ooxast-util-remove-rsid/src/lib/ooxast-util-remove-rsid.spec.ts index 19c03a54..c5ca7720 100755 --- a/libs/ooxast/ooxast-util-remove-rsid/src/lib/ooxast-util-remove-rsid.spec.ts +++ b/libs/ooxast/ooxast-util-remove-rsid/src/lib/ooxast-util-remove-rsid.spec.ts @@ -1,30 +1,18 @@ -import { ooxastUtilRemoveRsid } from './ooxast-util-remove-rsid' +import { ooxastUtilRemoveRsid } from './ooxast-util-remove-rsid.js' import { readFileSync, writeFileSync } from 'fs' -import { join } from 'path' -import { select, selectAll } from 'xast-util-select' +import { selectAll } from 'xast-util-select' import { Root } from 'ooxast' describe('ooxastOoxastUtilRemoveRsid', () => { const tree = JSON.parse( - readFileSync( - new URL('../../../../reoff/reoff-parse/src/test/ooxasttree', import.meta.url)), - { encoding: 'utf-8' } - ) + readFileSync(new URL('../../../../reoff/reoff-parse/src/test/ooxasttree', import.meta.url), { + encoding: 'utf-8', + }), ) as Root const cleanedTree = ooxastUtilRemoveRsid(tree as Root, { - rPrRemoveList: [ - 'w:lang', - 'w:shd', - 'w:szCs', - 'w:kern', - 'w:rFonts', - 'w:noProof', - ], + rPrRemoveList: ['w:lang', 'w:shd', 'w:szCs', 'w:kern', 'w:rFonts', 'w:noProof'], }) as Root - writeFileSync( - new URL('./removedRsid', import.meta.url)), - JSON.stringify(cleanedTree, null, 2) - ) + writeFileSync(new URL('./removedRsid', import.meta.url), JSON.stringify(cleanedTree, null, 2)) // console.dir(cleanedTree, { depth: null }) it('should retain rs', () => { diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/index.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/index.ts index 346cecd7..b28c7cec 100644 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/index.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/index.ts @@ -1,2 +1,2 @@ -export { toUnifiedLatex } from './lib/ooxast-util-to-unified-latex' -export { Options, Handle, H, UnifiedLatexNode } from './lib/types' +export { toUnifiedLatex } from './lib/ooxast-util-to-unified-latex.js' +export { Options, Handle, H, UnifiedLatexNode } from './lib/types.js' diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/all.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/all.ts index 63be2811..68b84f4e 100755 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/all.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/all.ts @@ -1,8 +1,8 @@ -import { one } from './one' -import { H, UnifiedLatexNode, Node, Parent, Handle } from './types' +import { one } from './one.js' +import { H, UnifiedLatexNode, Node, Parent } from './types.js' /** - * Convert all nodes in tree using j + * Convert all nodes in tree using h * @param h ooxast constructor function * @param parent * @returns diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/body.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/body.ts index 335fc6d9..e833c4ef 100755 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/body.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/body.ts @@ -1,25 +1,17 @@ // based on https://github.com/syntax-tree/hast-util-to-mdast/blob/main/lib/handlers/em -import { H, Body, Handle, P, UnifiedLatexNode } from '../types' -import { all } from '../all' -import { getPStyle } from '../util/get-pstyle' -import { getListInfo } from '../util/get-listinfo' -import { one } from '../one' +import { H, Body, Handle, P, UnifiedLatexNode } from '../types.js' +import { all } from '../all.js' +import { getPStyle } from '../util/get-pstyle.js' +import { getListInfo } from '../util/get-listinfo.js' +import { one } from '../one.js' import { Element } from 'xast-util-to-string/lib' -import { - Argument, - Environment, - Macro, - Verb, - Whitespace, -} from '@unified-latex/unified-latex-types' -import { WhiteSpace } from 'nlcst' -import { arg, m, SP } from '@unified-latex/unified-latex-builder' -import { PB } from '../util/PB' +import { Environment, Macro } from '@unified-latex/unified-latex-types' +import { m, SP } from '@unified-latex/unified-latex-builder' +import { PB } from '../util/PB.js' import { updateRenderInfo } from '@unified-latex/unified-latex-util-render-info' -const isP = (node: Element): node is P => - node.type === 'element' && node.name === 'w:p' +const isP = (node: Element): node is P => node.type === 'element' && node.name === 'w:p' export const body: Handle = (h: H, body: Body) => { const processedBody = body.children.reduce((acc, child, index) => { @@ -46,11 +38,9 @@ export const body: Handle = (h: H, body: Body) => { const prevChild = body.children[index - 1] - const isPrevListItem = - prevChild && isP(prevChild) && getPStyle(prevChild) === 'ListParagraph' + const isPrevListItem = prevChild && isP(prevChild) && getPStyle(prevChild) === 'ListParagraph' - const { ilvl: prevIlvl, numId: prevNumId } = - (isPrevListItem && getListInfo(prevChild)) || {} + const { ilvl: prevIlvl, numId: prevNumId } = (isPrevListItem && getListInfo(prevChild)) || {} const listItem = makeItem(h, child) @@ -107,8 +97,7 @@ export const body: Handle = (h: H, body: Body) => { if (isPrevListItem && ilvl < prevIlvl) { const mainEnv = acc[acc.length - 1] as Environment const embeddedEnvs = findEmbeddedEnvs(mainEnv) - const toBeEmbeddedEnv = - embeddedEnvs[embeddedEnvs.length - (prevIlvl - ilvl) - 1] + const toBeEmbeddedEnv = embeddedEnvs[embeddedEnvs.length - (prevIlvl - ilvl) - 1] const env: Environment = { type: 'environment', @@ -159,10 +148,7 @@ export const body: Handle = (h: H, body: Body) => { return processedBody } -function makeItem( - h: H, - item: P -): [typeof PB, Macro, typeof SP, ...UnifiedLatexNode[], typeof PB] { +function makeItem(h: H, item: P): [typeof PB, Macro, typeof SP, ...UnifiedLatexNode[], typeof PB] { const mIte = m('item') updateRenderInfo(mIte, { hangingIndent: true, diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/citation.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/citation.ts index da846dae..c22498df 100755 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/citation.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/citation.ts @@ -1,8 +1,11 @@ -import { H, Handle } from '../types' +import { H, Handle } from '../types.js' import { T } from 'ooxast' import { Data as CSL } from 'csl-json' + import { CitationItem, MendeleyCitationItem } from 'ooxast-util-citations' + import { m } from '@unified-latex/unified-latex-builder' + import { Parent } from 'unist' export const citation: Handle = (h: H, citation: T, parent?: Parent) => { diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/displayMath.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/displayMath.ts index 99ca1384..468c6f64 100644 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/displayMath.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/displayMath.ts @@ -1,6 +1,6 @@ import { DisplayMath } from '@unified-latex/unified-latex-types' -import { all } from '../all' -import { H, Handle } from '../types' +import { all } from '../all.js' +import { H, Handle } from '../types.js' export const displayMath: Handle = (h: H, node): DisplayMath => { h.inMath = true diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/document.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/document.ts index 813048cf..fbcb0811 100755 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/document.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/document.ts @@ -1,8 +1,7 @@ -import { all } from '../all' -import { H, Handle } from '../types' +import { all } from '../all.js' +import { H, Handle } from '../types.js' import { Body, Document, Endnotes, Footnotes } from 'ooxast' import { select } from 'xast-util-select' -import { notes } from '../util/notes' import { convertElement } from 'xast-util-is-element' const isFootnotes = convertElement('w:footnotes') diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/drawing.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/drawing.ts index 48f17599..f4cfb85c 100755 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/drawing.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/drawing.ts @@ -1,8 +1,8 @@ -import { H, Handle } from '../types' +import { H, Handle } from '../types.js' import { Drawing } from 'ooxast' import { select } from 'xast-util-select' import { env, m } from '@unified-latex/unified-latex-builder' -import { PB } from '../util/PB' +import { PB } from '../util/PB.js' export const drawing: Handle = (h: H, node: Drawing) => { const blip = select('a\\:blip', node) diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/endnote.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/endnote.ts index 33cc89f8..2cc1986b 100755 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/endnote.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/endnote.ts @@ -1,6 +1,5 @@ -import { H, Element } from '../types' -import { m } from '@unified-latex/unified-latex-builder' -import { all } from '../all' +import { H, Element } from '../types.js' +import { all } from '../all.js' export function footnote(h: H, node: Element) { if (node?.attributes?.type === 'separator') { diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/footnote.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/footnote.ts index 71eaa4fa..0e296c53 100755 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/footnote.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/footnote.ts @@ -1,6 +1,5 @@ -import { H, Element } from '../types' -import { m } from '@unified-latex/unified-latex-builder' -import { all } from '../all' +import { H, Element } from '../types.js' +import { all } from '../all.js' export function footnote(h: H, node: Element) { if (node?.attributes?.type === 'separator') { diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/footnoteReference.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/footnoteReference.ts index afbcbc10..33fe1a66 100644 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/footnoteReference.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/footnoteReference.ts @@ -1,4 +1,4 @@ -import { H, Element } from '../types' +import { H, Element } from '../types.js' import { arg, m } from '@unified-latex/unified-latex-builder' export function footnoteReference(h: H, node: Element) { diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/index.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/index.ts index 660a6d67..592c8606 100755 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/index.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/index.ts @@ -1,21 +1,21 @@ -import { all } from '../all' -import { body } from './body' -import { p } from './p' -import { root } from './root' -import { text } from './text' -import { citation } from './citation' -import { tbl } from './tbl' -import { footnote } from './footnote' -import { document } from './document' -import { r } from './r' -import { tr } from './tr' -import { drawing } from './drawing' -import { Context } from '../types' -import { displayMath } from './displayMath' -import { oMathPara } from './oMathPara' -import { tc } from './tc' -import { footnoteReference } from './footnoteReference' -import { oMath } from './oMath' +import { all } from '../all.js' +import { body } from './body.js' +import { p } from './p.js' +import { root } from './root.js' +import { text } from './text.js' +import { citation } from './citation.js' +import { tbl } from './tbl.js' +import { footnote } from './footnote.js' +import { document } from './document.js' +import { r } from './r.js' +import { tr } from './tr.js' +import { drawing } from './drawing.js' +import { Context } from '../types.js' +import { displayMath } from './displayMath.js' +import { oMathPara } from './oMathPara.js' +import { tc } from './tc.js' +import { footnoteReference } from './footnoteReference.js' +import { oMath } from './oMath.js' export const handlers: Context['handlers'] = { p, diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/oMath.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/oMath.ts index 7519adc1..7346ca27 100644 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/oMath.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/oMath.ts @@ -1,8 +1,7 @@ import { s } from '@unified-latex/unified-latex-builder' import { Math } from 'ooxast' -import { all } from '../all' -import { H, Handle } from '../types' -import { PB } from '../util/PB' +import { all } from '../all.js' +import { H, Handle } from '../types.js' export const oMath: Handle = (h: H, node: Math.OMath) => { h.inMath = true diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/oMathPara.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/oMathPara.ts index eb6d18fc..0e922c97 100644 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/oMathPara.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/oMathPara.ts @@ -1,7 +1,7 @@ import { env, s } from '@unified-latex/unified-latex-builder' -import { all } from '../all' -import { H, Handle, Node, Parent } from '../types' -import { PB } from '../util/PB' +import { all } from '../all.js' +import { H, Handle, Node, Parent } from '../types.js' +import { PB } from '../util/PB.js' export const oMathPara: Handle = (h: H, node: Node, parent?: Parent) => { h.inDisplayMath = true diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/p.spec.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/p.spec.ts index dae93f35..560ccac5 100755 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/p.spec.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/p.spec.ts @@ -1,15 +1,12 @@ import { x } from 'xastscript' -import { toUnifiedLatex } from '../ooxast-util-to-unified-latex' +import { toUnifiedLatex } from '../ooxast-util-to-unified-latex.js' import { s, SP } from '@unified-latex/unified-latex-builder' describe('p', () => { it('should do something', () => { const basicp = x('p', { id: 'ayy' }, [ x('w:pPr', {}, []), - x('w:r', {}, [ - x('w:rPr', {}, []), - x('w:t', {}, [{ type: 'text', value: 'lmao' }]), - ]), + x('w:r', {}, [x('w:rPr', {}, []), x('w:t', {}, [{ type: 'text', value: 'lmao' }])]), ]) expect(toUnifiedLatex(basicp)).toEqual([SP]) }) diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/p.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/p.ts index af63119f..3c01852a 100755 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/p.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/p.ts @@ -1,11 +1,11 @@ import { Macro } from '@unified-latex/unified-latex-types' import { P } from 'ooxast' import { SP, m, s, arg, env } from '@unified-latex/unified-latex-builder' -import { all } from '../all' -import { H, Handle } from '../types' -import { getPStyle } from '../util/get-pstyle' +import { all } from '../all.js' +import { H, Handle } from '../types.js' +import { getPStyle } from '../util/get-pstyle.js' import { updateRenderInfo } from '@unified-latex/unified-latex-util-render-info' -import { PB } from '../util/PB' +import { PB } from '../util/PB.js' import { toString } from 'xast-util-to-string' const headingList = [ diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/r.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/r.ts index 615928df..d9a686bb 100755 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/r.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/r.ts @@ -1,21 +1,9 @@ -import { - Color, - FldChar, - Highlight, - R, - RPr, - Shd, - VerticalAlignRun, -} from 'ooxast' +import { Color, FldChar, Highlight, R, RPr, Shd, VerticalAlignRun } from 'ooxast' import { select } from 'xast-util-select' -import { all } from '../all' +import { all } from '../all.js' import { x } from 'xastscript' -import { H, UnifiedLatexNode } from '../types' -import { - Group, - Macro, - String as UnifiedLatexString, -} from '@unified-latex/unified-latex-types' +import { H, UnifiedLatexNode } from '../types.js' +import { Group, Macro, String as UnifiedLatexString } from '@unified-latex/unified-latex-types' import { convertElement } from 'xast-util-is-element' import { m, s } from '@unified-latex/unified-latex-builder' @@ -38,10 +26,7 @@ export function r(h: H, node: R) { return } - const dontProc = select( - 'w\\:footnoteReference, w\\:endnoteReference, w\\:drawing', - node - ) + const dontProc = select('w\\:footnoteReference, w\\:endnoteReference, w\\:drawing', node) if (dontProc) { const content = all(h, node) diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/root.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/root.ts index 390e3dfe..16977444 100755 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/root.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/root.ts @@ -1,7 +1,7 @@ // based on https://github.com/syntax-tree/hast-util-to-mdast/blob/main/lib/handlers/em -import { all } from '../all' -import { H, Node, Root } from '../types' +import { all } from '../all.js' +import { H, Root } from '../types.js' export function root(h: H, node: Root) { // if (!article) { diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/tbl.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/tbl.ts index a1c4933a..1e417afa 100755 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/tbl.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/tbl.ts @@ -1,6 +1,6 @@ -import { H, Handle } from '../types' +import { H, Handle } from '../types.js' import { Tbl } from 'ooxast' -import { all } from '../all' +import { all } from '../all.js' import { env } from '@unified-latex/unified-latex-builder' export const tbl: Handle = (h: H, tbl: Tbl) => { @@ -8,20 +8,16 @@ export const tbl: Handle = (h: H, tbl: Tbl) => { const contents = all(h, tbl) h.inTable = false - const tableRows = tbl.children.filter( - (row) => 'name' in row && row.name === 'w:tr' - ) + const tableRows = tbl.children.filter((row) => 'name' in row && row.name === 'w:tr') - const columns = tableRows - .map((row) => `${h.defaultCol}${h.columnSeparator ? ' |' : ''}`) - .join(' ') + const columns = tableRows.map(() => `${h.defaultCol}${h.columnSeparator ? ' |' : ''}`).join(' ') const colArg = [`@{} ${h.columnSeparator ? '| ' : ''}${columns} @{}`] const table = env( 'table', h.tabularx?.width ? env('tabularx', contents, [h.tabularx.width, ...colArg]) - : env('tabular', contents, colArg) + : env('tabular', contents, colArg), ) return table } diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/tc.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/tc.ts index c66465ec..b137bf6e 100644 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/tc.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/tc.ts @@ -1,8 +1,8 @@ import { m } from '@unified-latex/unified-latex-builder' import { Tc } from 'ooxast' import { select } from 'xast-util-select' -import { all } from '../all' -import { H, Handle, UnifiedLatexNode } from '../types' +import { all } from '../all.js' +import { H, Handle, UnifiedLatexNode } from '../types.js' export const tc: Handle = (h: H, node: Tc): UnifiedLatexNode[] => { const gridSpan = select('w\\:gridSpan', node)?.attributes?.['w:val'] diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/text.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/text.ts index f698d37a..c4049251 100755 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/text.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/text.ts @@ -1,5 +1,5 @@ import { s } from '@unified-latex/unified-latex-builder' -import { H, Text } from '../types' +import { H, Text } from '../types.js' export function text(h: H, node: Text) { return s(node.value) diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/tr.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/tr.ts index 972d3bb7..dd226052 100755 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/tr.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/handlers/tr.ts @@ -1,9 +1,8 @@ -import { H, Handle, UnifiedLatexNode } from '../types' +import { H, Handle, UnifiedLatexNode } from '../types.js' import { Row, Tc } from 'ooxast' -import { all } from '../all' -import { PB } from '../util/PB' +import { PB } from '../util/PB.js' import { select } from 'xast-util-select' -import { tc } from './tc' +import { tc } from './tc.js' import { m, s, SP } from '@unified-latex/unified-latex-builder' export const tr: Handle = (h: H, tr: Row, parent) => { diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/one.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/one.ts index 592ff423..1dd4d8c0 100755 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/one.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/one.ts @@ -1,9 +1,9 @@ import { isElement } from 'xast-util-is-element' import { Parent } from 'ooxast' -import { all } from './all' -import { Handle, H, UnifiedLatexNode, Node, Element } from './types' -import { own } from './util/own' -import { wrapText } from './util/wrap-text' +import { all } from './all.js' +import { Handle, H, UnifiedLatexNode, Node, Element } from './types.js' +import { own } from './util/own.js' +import { wrapText } from './util/wrap-text.js' export function one( h: H, diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/ooxast-util-to-unified-latex.spec.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/ooxast-util-to-unified-latex.spec.ts index d36f48aa..45c26297 100644 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/ooxast-util-to-unified-latex.spec.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/ooxast-util-to-unified-latex.spec.ts @@ -1,11 +1,11 @@ import { Document, P, Root } from 'ooxast' import { Macro } from '@unified-latex/unified-latex-types' -import { p } from './handlers/p' -import { toUnifiedLatex } from './ooxast-util-to-unified-latex' +import { p } from './handlers/p.js' +import { toUnifiedLatex } from './ooxast-util-to-unified-latex.js' import { toString } from '@unified-latex/unified-latex-util-to-string' import { m } from '@unified-latex/unified-latex-builder' import { updateRenderInfo } from '@unified-latex/unified-latex-util-render-info' -import { PB } from './util/PB' +import { PB } from './util/PB.js' import listTree from '../lib/test/list.json' // test whether a ooxast p node with style 'Heading1' is converted to a macro with name 'section' @@ -67,9 +67,7 @@ describe('ooxast-util-to-unified-latex', () => { const res = { type: 'root', content: [PB, sec, PB] } - expect(toString(toUnifiedLatex(ooxastParagraph))).toEqual( - `\n\n\\section{Hello World}\n\n` - ) + expect(toString(toUnifiedLatex(ooxastParagraph))).toEqual(`\n\n\\section{Hello World}\n\n`) expect(toUnifiedLatex(ooxastParagraph)).toEqual(res) }) diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/ooxast-util-to-unified-latex.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/ooxast-util-to-unified-latex.ts index 077366fe..44d1d079 100755 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/ooxast-util-to-unified-latex.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/ooxast-util-to-unified-latex.ts @@ -1,6 +1,7 @@ -import { one } from './one' -import { handlers } from './handlers/index' +import { one } from './one.js' +import { handlers } from './handlers/index.js' import { Data as CSL } from 'csl-json' +// import { Parsed } from 'reoff-parse' import { Context, @@ -14,17 +15,20 @@ import { Element, Text, RenderInfo, -} from './types' +} from './types.js' import rehypeMinifyWhitespace from 'rehype-minify-whitespace' + import { args, env, m, s } from '@unified-latex/unified-latex-builder' -import { PB } from './util/PB' -import { makePackage } from './util/make-package' + +import { PB } from './util/PB.js' + +import { makePackage } from './util/make-package.js' import { cslToBiblatex } from 'csl-to-biblatex' import { VFile } from 'vfile' import { notes } from './util/notes.js' -export { one } from './one' -export { all } from './all' +export { one } from './one.js' +export { all } from './all.js' export { handlers as defaultHandlers } const defaultOptions: Options = { @@ -32,6 +36,7 @@ const defaultOptions: Options = { quotes: ['"'], topSection: 1, columnSeparator: false, + documentClass: { name: 'article' }, bibname: 'References', packages: [ @@ -44,15 +49,23 @@ const defaultOptions: Options = { ], } +declare module 'vfile' { + interface DataMap { + parsed: { + [key: `${string}.xml` | `${string}.rels`]: Root + } + } +} + export function toUnifiedLatex( tree: Root | Element | Text, file: VFile, - options: Options, + options?: Options, ): UnifiedLatexRoot -export function toUnifiedLatex(tree: Root | Element | Text, options: Options): UnifiedLatexRoot +export function toUnifiedLatex(tree: Root | Element | Text, options?: Options): UnifiedLatexRoot export function toUnifiedLatex( tree: Root | Element | Text, - optionsOrVFile: Options | VFile, + optionsOrVFile?: Options | VFile, maybeOptions?: Options, ): UnifiedLatexRoot { const options = { @@ -154,11 +167,13 @@ export function toUnifiedLatex( h.simpleParagraph = true if (unparsedFootnotes) { + //@ts-expect-error shhh whiteSpaceTransformer!(unparsedFootnotes) h.footnotes = notes(h, unparsedFootnotes) } if (unparsedEndnotes) { + //@ts-expect-error shhh whiteSpaceTransformer!(unparsedEndnotes) h.endnotes = notes(h, unparsedEndnotes) } diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/types.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/types.ts index 8ff72fad..42711b13 100755 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/types.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/types.ts @@ -7,7 +7,6 @@ import { Node as UnifiedLatexNode, MacroInfo, EnvInfo, - Macro, } from '@unified-latex/unified-latex-types' import { Attributes as OoxastProperties, Parent, Body, Text, Root, P } from 'ooxast' @@ -18,7 +17,6 @@ export type XastContent = Root['children'][number] | Root * ooxast Node */ export type Node = Parent['children'][number] | Root -type t = Extract export type Attributes = OoxastProperties diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/util/get-pstyle.spec.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/util/get-pstyle.spec.ts index de8316a7..51467dec 100755 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/util/get-pstyle.spec.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/util/get-pstyle.spec.ts @@ -1,5 +1,5 @@ import { P, PPr, R } from 'ooxast' -import { getPStyle } from './get-pstyle' +import { getPStyle } from './get-pstyle.js' export const test: any = { type: 'element', diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/util/get-pstyle.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/util/get-pstyle.ts index 191b2e79..fec9a3bf 100755 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/util/get-pstyle.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/util/get-pstyle.ts @@ -1,6 +1,5 @@ -import { P, BdoContentRun } from 'ooxast' -import { Element } from '../types' -import { select, selectAll } from 'xast-util-select' +import { P } from 'ooxast' +import { select } from 'xast-util-select' export function getPStyle(p: P): string | null | undefined { const style = select('w\\:pStyle', p) diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/util/notes.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/util/notes.ts index 8fe89713..71bbb28a 100644 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/util/notes.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/util/notes.ts @@ -1,6 +1,6 @@ import { Endnotes, Footnotes, FtnEdn } from 'ooxast' -import { all } from '../all' -import { H, UnifiedLatexNode } from '../types' +import { all } from '../all.js' +import { H, UnifiedLatexNode } from '../types.js' import { selectAll } from 'xast-util-select' import { Root } from 'xast' diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/util/wrap-text.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/util/wrap-text.ts index 2c20def1..159a1960 100755 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/lib/util/wrap-text.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/lib/util/wrap-text.ts @@ -1,4 +1,4 @@ -import { H } from '../types' +import { H } from '../types.js' export function wrapText(h: H, value: string): string { return h.wrapText ? value : value.replace(/\r?\n|\r/g, ' ') diff --git a/libs/ooxast/ooxast-util-to-unified-latex/src/test/fixtures.spec.ts b/libs/ooxast/ooxast-util-to-unified-latex/src/test/fixtures.spec.ts index 9e2eb67c..ab2d5c49 100644 --- a/libs/ooxast/ooxast-util-to-unified-latex/src/test/fixtures.spec.ts +++ b/libs/ooxast/ooxast-util-to-unified-latex/src/test/fixtures.spec.ts @@ -5,13 +5,13 @@ import { readFile, writeFile } from 'fs/promises' import { join } from 'path' import { Plugin, CompilerFunction, unified } from 'unified' import { removePosition } from 'unist-util-remove-position' -import { select } from 'xast-util-select' import { reoffClean } from 'reoff-clean' import reoffCite from 'reoff-cite' import reoffParseReferences from 'reoff-parse-references' -import { toUnifiedLatex } from '../lib/ooxast-util-to-unified-latex' +import { toUnifiedLatex } from '../lib/ooxast-util-to-unified-latex.js' import { toString } from '@unified-latex/unified-latex-util-to-string' -import { Options } from '../lib/types' + +import { Options } from '../lib/types.js' import { Node } from 'unist' import { Ast, Root } from '@unified-latex/unified-latex-types' diff --git a/libs/ooxast/ooxast/.eslintrc.json b/libs/ooxast/ooxast/.eslintrc.json index 3456be9b..f5169588 100755 --- a/libs/ooxast/ooxast/.eslintrc.json +++ b/libs/ooxast/ooxast/.eslintrc.json @@ -4,7 +4,10 @@ "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": {} + "rules": { + "no-var": "warn", + "@typescript-eslint/no-empty-interface": "warn" + } }, { "files": ["*.ts", "*.tsx"], diff --git a/libs/ooxast/ooxast/src/index.ts b/libs/ooxast/ooxast/src/index.ts index 2abb4b7b..282fb01d 100755 --- a/libs/ooxast/ooxast/src/index.ts +++ b/libs/ooxast/ooxast/src/index.ts @@ -1,3 +1,3 @@ -export * from './lib/ooxast' -export * from './lib/ooxml/wordprocessingml/main' -export * as Math from './lib/ooxml/officeDocument/math' +export * from './lib/ooxast.js' +export * from './lib/ooxml/wordprocessingml/main.js' +export * as Math from './lib/ooxml/officeDocument/math.js' diff --git a/libs/ooxast/ooxast/src/lib/ooxast.ts b/libs/ooxast/ooxast/src/lib/ooxast.ts index a105e961..6f73dae2 100755 --- a/libs/ooxast/ooxast/src/lib/ooxast.ts +++ b/libs/ooxast/ooxast/src/lib/ooxast.ts @@ -16,7 +16,7 @@ export type { XastLiteral as Literal, XastAttributes as Attributes, } -import { document, Text } from './ooxml/wordprocessingml/main' +import { document, Text } from './ooxml/wordprocessingml/main.js' export type Root = XastRoot & { /** diff --git a/libs/ooxast/ooxast/src/lib/ooxml/drawingml/main.ts b/libs/ooxast/ooxast/src/lib/ooxml/drawingml/main.ts index f907dd4c..d3995276 100755 --- a/libs/ooxast/ooxast/src/lib/ooxml/drawingml/main.ts +++ b/libs/ooxast/ooxast/src/lib/ooxml/drawingml/main.ts @@ -1,7 +1,7 @@ -import * as Primitive from '../../xml-primitives' -import * as r from '../officeDocument/relationships' -import * as s from '../officeDocument/sharedTypes' -import { RequiredMap } from '../../ooxast' +import * as Primitive from '../../xml-primitives.js' +import * as r from '../officeDocument/relationships.js' +import * as s from '../officeDocument/sharedTypes.js' +import { RequiredMap } from '../../ooxast.js' // Source files: // http://localhost:3000/dml-main.xsd @@ -3316,11 +3316,7 @@ export type AnimationBuildTypeVal = 'allAtOnce' export type AnimationChartBuildTypeVal = string -export type AnimationChartOnlyBuildTypeVal = - | 'series' - | 'category' - | 'seriesEl' - | 'categoryEl' +export type AnimationChartOnlyBuildTypeVal = 'series' | 'category' | 'seriesEl' | 'categoryEl' export type AnimationDgmBuildTypeVal = string @@ -3355,12 +3351,7 @@ export type BlackWhiteModeVal = export type BlendModeVal = 'over' | 'mult' | 'screen' | 'darken' | 'lighten' -export type BlipCompressionVal = - | 'email' - | 'screen' - | 'print' - | 'hqprint' - | 'none' +export type BlipCompressionVal = 'email' | 'screen' | 'print' | 'hqprint' | 'none' export type ChartBuildStepVal = | 'category' @@ -3412,15 +3403,7 @@ export type GeomGuideFormulaVal = string export type GeomGuideNameVal = string -export type LightRigDirectionVal = - | 'tl' - | 't' - | 'tr' - | 'l' - | 'r' - | 'bl' - | 'b' - | 'br' +export type LightRigDirectionVal = 'tl' | 't' | 'tr' | 'l' | 'r' | 'bl' | 'b' | 'br' export type LightRigTypeVal = | 'legacyFlat1' @@ -3455,13 +3438,7 @@ export type LineCapVal = 'rnd' | 'sq' | 'flat' export type LineEndLengthVal = 'sm' | 'med' | 'lg' -export type LineEndTypeVal = - | 'none' - | 'triangle' - | 'stealth' - | 'diamond' - | 'oval' - | 'arrow' +export type LineEndTypeVal = 'none' | 'triangle' | 'stealth' | 'diamond' | 'oval' | 'arrow' export type LineEndWidthVal = 'sm' | 'med' | 'lg' @@ -3469,13 +3446,7 @@ export type LineWidthVal = number export type OnOffStyleTypeVal = 'on' | 'off' | 'def' -export type PathFillModeVal = - | 'none' - | 'norm' - | 'lighten' - | 'lightenLess' - | 'darken' - | 'darkenLess' +export type PathFillModeVal = 'none' | 'norm' | 'lighten' | 'lightenLess' | 'darken' | 'darkenLess' export type PathShadeTypeVal = 'shape' | 'circle' | 'rect' @@ -3877,16 +3848,7 @@ export type PresetShadowValVal = | 'shdw19' | 'shdw20' -export type RectAlignmentVal = - | 'tl' - | 't' - | 'tr' - | 'l' - | 'ctr' - | 'r' - | 'bl' - | 'b' - | 'br' +export type RectAlignmentVal = 'tl' | 't' | 'tr' | 'l' | 'ctr' | 'r' | 'bl' | 'b' | 'br' export type SchemeColorValVal = | 'bg1' @@ -4132,14 +4094,7 @@ export type SystemColorValVal = | 'menuHighlight' | 'menuBar' -export type TextAlignTypeVal = - | 'l' - | 'ctr' - | 'r' - | 'just' - | 'justLow' - | 'dist' - | 'thaiDist' +export type TextAlignTypeVal = 'l' | 'ctr' | 'r' | 'just' | 'justLow' | 'dist' | 'thaiDist' export type TextAnchoringTypeVal = 't' | 'ctr' | 'b' | 'just' | 'dist' diff --git a/libs/ooxast/ooxast/src/lib/ooxml/drawingml/picture.ts b/libs/ooxast/ooxast/src/lib/ooxml/drawingml/picture.ts index 1be773a6..ea0a48bf 100755 --- a/libs/ooxast/ooxast/src/lib/ooxml/drawingml/picture.ts +++ b/libs/ooxast/ooxast/src/lib/ooxml/drawingml/picture.ts @@ -1,5 +1,5 @@ -import * as a from './main' -import { RequiredMap } from '../../ooxast' +import * as a from './main.js' +import { RequiredMap } from '../../ooxast.js' // Source files: // http://localhost:3000/dml-picture.xsd diff --git a/libs/ooxast/ooxast/src/lib/ooxml/drawingml/wordprocessingDrawing.ts b/libs/ooxast/ooxast/src/lib/ooxml/drawingml/wordprocessingDrawing.ts index 6b25e0d6..e11064f7 100755 --- a/libs/ooxast/ooxast/src/lib/ooxml/drawingml/wordprocessingDrawing.ts +++ b/libs/ooxast/ooxast/src/lib/ooxml/drawingml/wordprocessingDrawing.ts @@ -1,11 +1,11 @@ -import * as Primitive from '../../xml-primitives' -import * as a from './main' -import * as dpct from './picture' -import * as m from '../officeDocument/math' -import * as r from '../officeDocument/relationships' -import * as w from '../wordprocessingml/main' - -import { RequiredMap } from '../../ooxast' +import * as Primitive from '../../xml-primitives.js' +import * as a from './main.js' +import * as dpct from './picture.js' +import * as m from '../officeDocument/math.js' +import * as r from '../officeDocument/relationships.js' +import * as w from '../wordprocessingml/main.js' + +import { RequiredMap } from '../../ooxast.js' // Source files: // http://localhost:3000/dml-wordprocessingDrawing.xsd diff --git a/libs/ooxast/ooxast/src/lib/ooxml/officeDocument/bibliography.ts b/libs/ooxast/ooxast/src/lib/ooxml/officeDocument/bibliography.ts index d74f3b48..5a897173 100755 --- a/libs/ooxast/ooxast/src/lib/ooxml/officeDocument/bibliography.ts +++ b/libs/ooxast/ooxast/src/lib/ooxml/officeDocument/bibliography.ts @@ -1,6 +1,6 @@ -import * as s from './sharedTypes' -import { Text } from '../wordprocessingml/main' -import { RequiredMap } from '../../ooxast' +import * as s from './sharedTypes.js' +import { Text } from '../wordprocessingml/main.js' +import { RequiredMap } from '../../ooxast.js' import { Node as UnistNode } from 'unist' // Source files: @@ -43,8 +43,7 @@ export interface NameListMap { Person: Person[] } -export interface NameOrCorporate - extends UnistNode { +export interface NameOrCorporate extends UnistNode { type: 'element' name: `b:${name}` attributes: Record diff --git a/libs/ooxast/ooxast/src/lib/ooxml/officeDocument/math.ts b/libs/ooxast/ooxast/src/lib/ooxml/officeDocument/math.ts index 4b6529b8..37ac5af5 100755 --- a/libs/ooxast/ooxast/src/lib/ooxml/officeDocument/math.ts +++ b/libs/ooxast/ooxast/src/lib/ooxml/officeDocument/math.ts @@ -1,7 +1,7 @@ -import * as Primitive from '../../xml-primitives' -import * as s from './sharedTypes' -import * as w from '../wordprocessingml/main' -import { RequiredMap } from '../../ooxast' +import * as Primitive from '../../xml-primitives.js' +import * as s from './sharedTypes.js' +import * as w from '../wordprocessingml/main.js' +import { RequiredMap } from '../../ooxast.js' // Source files: // http://localhost:3000/shared-math.xsd @@ -406,7 +406,7 @@ export interface MathPrMap { intLim?: LimLoc intraSp?: TwipsMeasure lMargin?: TwipsMeasure - mathFont?: String + mathFont?: MString naryLim?: LimLoc postSp?: TwipsMeasure preSp?: TwipsMeasure @@ -924,7 +924,7 @@ export interface SSupPrMap { ctrlPr?: CtrlPr } -export interface String extends UnistNode { +export interface MString extends UnistNode { type: 'element' name: 'm:string' attributes: { diff --git a/libs/ooxast/ooxast/src/lib/ooxml/officeDocument/relationships.ts b/libs/ooxast/ooxast/src/lib/ooxml/officeDocument/relationships.ts index 0898a0c7..380aefaa 100755 --- a/libs/ooxast/ooxast/src/lib/ooxml/officeDocument/relationships.ts +++ b/libs/ooxast/ooxast/src/lib/ooxml/officeDocument/relationships.ts @@ -1,6 +1,6 @@ -import * as Primitive from '../../xml-primitives' +import * as Primitive from '../../xml-primitives.js' -import { RequiredMap } from '../../ooxast' +import { RequiredMap } from '../../ooxast.js' // Source files: // http://localhost:3000/shared-relationshipReference.xsd diff --git a/libs/ooxast/ooxast/src/lib/ooxml/officeDocument/sharedTypes.ts b/libs/ooxast/ooxast/src/lib/ooxml/officeDocument/sharedTypes.ts index b3721ca0..2b86eb85 100755 --- a/libs/ooxast/ooxast/src/lib/ooxml/officeDocument/sharedTypes.ts +++ b/libs/ooxast/ooxast/src/lib/ooxml/officeDocument/sharedTypes.ts @@ -1,6 +1,6 @@ -import * as Primitive from '../../xml-primitives' +import * as Primitive from '../../xml-primitives.js' -import { RequiredMap } from '../../ooxast' +import { RequiredMap } from '../../ooxast.js' // Source files: // http://localhost:3000/shared-commonSimpleTypes.xsd @@ -60,13 +60,7 @@ export type XmlNameVal = string export type XstringVal = string -export type YAlignVal = - | 'inline' - | 'top' - | 'center' - | 'bottom' - | 'inside' - | 'outside' +export type YAlignVal = 'inline' | 'top' | 'center' | 'bottom' | 'inside' | 'outside' export interface document extends UnistNode {} export var document: document diff --git a/libs/ooxast/ooxast/src/lib/ooxml/schemaLibrary/main.ts b/libs/ooxast/ooxast/src/lib/ooxml/schemaLibrary/main.ts index 10873c9f..e583a2a6 100755 --- a/libs/ooxast/ooxast/src/lib/ooxml/schemaLibrary/main.ts +++ b/libs/ooxast/ooxast/src/lib/ooxml/schemaLibrary/main.ts @@ -1,6 +1,6 @@ -import * as Primitive from '../../xml-primitives' +import * as Primitive from '../../xml-primitives.js' -import { RequiredMap } from '../../ooxast' +import { RequiredMap } from '../../ooxast.js' // Source files: // http://localhost:3000/shared-customXmlSchemaProperties.xsd diff --git a/libs/ooxast/ooxast/src/lib/ooxml/wordprocessingml/main.ts b/libs/ooxast/ooxast/src/lib/ooxml/wordprocessingml/main.ts index d345d6f2..9c7e7766 100755 --- a/libs/ooxast/ooxast/src/lib/ooxml/wordprocessingml/main.ts +++ b/libs/ooxast/ooxast/src/lib/ooxml/wordprocessingml/main.ts @@ -1,10 +1,10 @@ -import * as m from '../officeDocument/math' -import * as r from '../officeDocument/relationships' -import * as s from '../officeDocument/sharedTypes' -import * as sl from '../schemaLibrary/main' -import * as wp from '../drawingml/wordprocessingDrawing' +import * as m from '../officeDocument/math.js' +import * as r from '../officeDocument/relationships.js' +import * as s from '../officeDocument/sharedTypes.js' +import * as sl from '../schemaLibrary/main.js' +import * as wp from '../drawingml/wordprocessingDrawing.js' import { Literal as UnistLiteral, Node as UnistNode } from 'unist' -import { RequiredMap } from '../../ooxast' +import { RequiredMap } from '../../ooxast.js' // Source files: // http://localhost:3000/wml.xsd @@ -185,16 +185,15 @@ export type Bookmark = BookmarkRange & { children: [] } -export type BookmarkRange = - MarkupRange & { - type: 'element' - name: `w:${tag}` - attributes: { - 'w:colFirst'?: string - 'w:colLast'?: string - } - children: [] +export type BookmarkRange = MarkupRange & { + type: 'element' + name: `w:${tag}` + attributes: { + 'w:colFirst'?: string + 'w:colLast'?: string } + children: [] +} export interface Border extends UnistNode { type: 'element' @@ -1502,8 +1501,7 @@ export interface Highlight extends UnistNode { children: [] } -export interface HpsMeasure - extends UnistNode { +export interface HpsMeasure extends UnistNode { type: 'element' name: `w:${tag}` attributes: { @@ -1812,8 +1810,7 @@ export interface Markup extends UnistNode { children: any[] } -export interface MarkupRange - extends Markup { +export interface MarkupRange extends Markup { name: `w:${tag}` attributes: { 'w:id': string @@ -2794,8 +2791,7 @@ export interface RubyPrMap { rubyAlign: RubyAlign } -export interface RunTrackChange - extends TrackChange { +export interface RunTrackChange extends TrackChange { type: 'element' name: `w:${tag}` attributes: { @@ -4094,8 +4090,7 @@ export type TopPageBorder = PageBorder & { } } -export interface TrackChange - extends Markup { +export interface TrackChange extends Markup { type: 'element' name: `w:${tag}` attributes: { @@ -4575,12 +4570,7 @@ export type DocPartTypeVal = | 'formFld' | 'bbPlcHdr' -export type DocProtectVal = - | 'none' - | 'readOnly' - | 'comments' - | 'trackedChanges' - | 'forms' +export type DocProtectVal = 'none' | 'readOnly' | 'comments' | 'trackedChanges' | 'forms' export type DocTypeVal = string @@ -4617,23 +4607,13 @@ export type FFTextTypeVal = export type FldCharTypeVal = 'begin' | 'separate' | 'end' -export type FontFamilyVal = - | 'decorative' - | 'modern' - | 'roman' - | 'script' - | 'swiss' - | 'auto' +export type FontFamilyVal = 'decorative' | 'modern' | 'roman' | 'script' | 'swiss' | 'auto' export type FrameLayoutVal = 'rows' | 'cols' | 'none' export type FrameScrollbarVal = 'on' | 'off' | 'auto' -export type FtnEdnVal = - | 'normal' - | 'separator' - | 'continuationSeparator' - | 'continuationNotice' +export type FtnEdnVal = 'normal' | 'separator' | 'continuationSeparator' | 'continuationNotice' export type FtnPosVal = 'pageBottom' | 'beneathText' | 'sectEnd' | 'docEnd' @@ -4692,11 +4672,7 @@ export type LineNumberRestartVal = 'newPage' | 'newSection' | 'continuous' export type LineSpacingRuleVal = 'auto' | 'exact' | 'atLeast' -export type LockVal = - | 'sdtLocked' - | 'contentLocked' - | 'unlocked' - | 'sdtContentLocked' +export type LockVal = 'sdtLocked' | 'contentLocked' | 'unlocked' | 'sdtContentLocked' export type LongHexNumberVal = string @@ -4731,10 +4707,7 @@ export type MeasurementOrPercentVal = string export type MergeVal = 'continue' | 'restart' -export type MultiLevelTypeVal = - | 'singleLevel' - | 'multilevel' - | 'hybridMultilevel' +export type MultiLevelTypeVal = 'singleLevel' | 'multilevel' | 'hybridMultilevel' export type NumberFormatVal = | 'decimal' @@ -4825,12 +4798,7 @@ export type ProofErrVal = 'spellStart' | 'spellEnd' | 'gramStart' | 'gramEnd' export type PTabAlignmentVal = 'left' | 'center' | 'right' -export type PTabLeaderVal = - | 'none' - | 'dot' - | 'hyphen' - | 'underscore' - | 'middleDot' +export type PTabLeaderVal = 'none' | 'dot' | 'hyphen' | 'underscore' | 'middleDot' export type PTabRelativeToVal = 'margin' | 'indent' @@ -4846,12 +4814,7 @@ export type RubyAlignVal = export type SdtDateMappingTypeVal = 'text' | 'date' | 'dateTime' -export type SectionMarkVal = - | 'nextPage' - | 'nextColumn' - | 'continuous' - | 'evenPage' - | 'oddPage' +export type SectionMarkVal = 'nextPage' | 'nextColumn' | 'continuous' | 'evenPage' | 'oddPage' export type ShdVal = | 'nil' @@ -4899,32 +4862,13 @@ export type SignedHpsMeasureVal = string export type SignedTwipsMeasureVal = string -export type StyleSortVal = - | 'name' - | 'priority' - | 'default' - | 'font' - | 'basedOn' - | 'type' +export type StyleSortVal = 'name' | 'priority' | 'default' | 'font' | 'basedOn' | 'type' export type StyleTypeVal = 'paragraph' | 'character' | 'table' | 'numbering' -export type TabJcVal = - | 'clear' - | 'start' - | 'center' - | 'end' - | 'decimal' - | 'bar' - | 'num' +export type TabJcVal = 'clear' | 'start' | 'center' | 'end' | 'decimal' | 'bar' | 'num' -export type TabTlcVal = - | 'none' - | 'dot' - | 'hyphen' - | 'underscore' - | 'heavy' - | 'middleDot' +export type TabTlcVal = 'none' | 'dot' | 'hyphen' | 'underscore' | 'heavy' | 'middleDot' export type TargetScreenSzVal = | '544x376' @@ -5039,13 +4983,7 @@ export type VAnchorVal = 'text' | 'margin' | 'page' export type VerticalJcVal = 'top' | 'center' | 'both' | 'bottom' -export type ViewVal = - | 'none' - | 'print' - | 'outline' - | 'masterPages' - | 'normal' - | 'web' +export type ViewVal = 'none' | 'print' | 'outline' | 'masterPages' | 'normal' | 'web' export type WmlColorSchemeIndexVal = | 'dark1' @@ -5061,13 +4999,7 @@ export type WmlColorSchemeIndexVal = | 'hyperlink' | 'followedHyperlink' -export type WrapVal = - | 'auto' - | 'notBeside' - | 'around' - | 'tight' - | 'through' - | 'none' +export type WrapVal = 'auto' | 'notBeside' | 'around' | 'tight' | 'through' | 'none' export type ZoomVal = 'none' | 'fullPage' | 'bestFit' | 'textFit' diff --git a/libs/ooxast/ooxast/tsconfig.lib.json b/libs/ooxast/ooxast/tsconfig.lib.json index c8223e02..5d395d34 100755 --- a/libs/ooxast/ooxast/tsconfig.lib.json +++ b/libs/ooxast/ooxast/tsconfig.lib.json @@ -3,7 +3,8 @@ "compilerOptions": { "outDir": "../../../dist/out-tsc", "declaration": true, - "types": ["node"] + "types": ["node"], + "moduleResolution": "nodenext" }, "exclude": ["**/*.spec.ts", "**/*.test.ts", "jest.config.ts"], "include": ["**/*.ts", "**/*.d.ts"] diff --git a/libs/processors/docx-to-jats/src/index.ts b/libs/processors/docx-to-jats/src/index.ts index b0dbd81f..73f75ca0 100755 --- a/libs/processors/docx-to-jats/src/index.ts +++ b/libs/processors/docx-to-jats/src/index.ts @@ -1 +1 @@ -export * from './lib/processors-docx-to-jats' +export * from './lib/processors-docx-to-jats.js' diff --git a/libs/processors/docx-to-tex/src/index.ts b/libs/processors/docx-to-tex/src/index.ts index c02e6739..eae0cd19 100755 --- a/libs/processors/docx-to-tex/src/index.ts +++ b/libs/processors/docx-to-tex/src/index.ts @@ -1 +1 @@ -export * from './lib/processors-docx-to-tex' +export * from './lib/processors-docx-to-tex.js' diff --git a/libs/processors/jats-to-tex/src/index.ts b/libs/processors/jats-to-tex/src/index.ts index faca716d..d9532c0e 100755 --- a/libs/processors/jats-to-tex/src/index.ts +++ b/libs/processors/jats-to-tex/src/index.ts @@ -1 +1 @@ -export * from './lib/processors-jats-to-tex' +export * from './lib/processors-jats-to-tex.js' diff --git a/libs/processors/jote-docx-tex/src/index.ts b/libs/processors/jote-docx-tex/src/index.ts index d5e8b7e9..b1acfda1 100755 --- a/libs/processors/jote-docx-tex/src/index.ts +++ b/libs/processors/jote-docx-tex/src/index.ts @@ -1 +1 @@ -export * from './lib/processors-jote-docx-tex' +export * from './lib/processors-jote-docx-tex.js' diff --git a/libs/processors/jote-docx-tex/src/lib/processors-jote-docx-tex.spec.ts b/libs/processors/jote-docx-tex/src/lib/processors-jote-docx-tex.spec.ts index 5f0e8298..e69de29b 100755 --- a/libs/processors/jote-docx-tex/src/lib/processors-jote-docx-tex.spec.ts +++ b/libs/processors/jote-docx-tex/src/lib/processors-jote-docx-tex.spec.ts @@ -1,7 +0,0 @@ -import { processorsJoteDocxTex } from './processors-jote-docx-tex' - -describe('processorsJoteDocxTex', () => { - it('should work', () => { - expect(processorsJoteDocxTex()).toEqual('processors-jote-docx-tex') - }) -}) diff --git a/libs/rejour/rejour-frontmatter/src/index.ts b/libs/rejour/rejour-frontmatter/src/index.ts index 4ed64c26..675f8ef1 100755 --- a/libs/rejour/rejour-frontmatter/src/index.ts +++ b/libs/rejour/rejour-frontmatter/src/index.ts @@ -1 +1 @@ -export * from './lib/rejour-frontmatter' +export * from './lib/rejour-frontmatter.js' diff --git a/libs/rejour/rejour-frontmatter/src/lib/rejour-frontmatter.spec.ts b/libs/rejour/rejour-frontmatter/src/lib/rejour-frontmatter.spec.ts index f93a0b3d..97f9860e 100755 --- a/libs/rejour/rejour-frontmatter/src/lib/rejour-frontmatter.spec.ts +++ b/libs/rejour/rejour-frontmatter/src/lib/rejour-frontmatter.spec.ts @@ -3,15 +3,13 @@ import { toCSL } from 'jast-util-to-csl' import { unified } from 'unified' import { read } from 'to-vfile' import { Root } from 'jast-types' -import { rejourFrontmatter } from './rejour-frontmatter' +import { rejourFrontmatter } from './rejour-frontmatter.js' describe('rejourJastUtilToCsl', () => { const proc = unified().use(rejourParse).use(rejourFrontmatter) // .use(() => (tree, file) => // console.log(file.data)) it('should work', async () => { - const tree = proc.parse( - await read(new URL('../test/index.jats.xml', import.meta.url)) - ) as Root + const tree = proc.parse(await read(new URL('../test/index.jats.xml', import.meta.url))) as Root const csl = toCSL(tree) console.dir(csl.front, { depth: null }) expect(csl).toEqual('') diff --git a/libs/rejour/rejour-meta/src/index.ts b/libs/rejour/rejour-meta/src/index.ts index 86c16d60..0c1f3433 100755 --- a/libs/rejour/rejour-meta/src/index.ts +++ b/libs/rejour/rejour-meta/src/index.ts @@ -1 +1 @@ -export * from './lib/rejour-meta' +export * from './lib/rejour-meta.js' diff --git a/libs/rejour/rejour-move-abstract/src/index.ts b/libs/rejour/rejour-move-abstract/src/index.ts index e21b3ffb..6f9b2a50 100755 --- a/libs/rejour/rejour-move-abstract/src/index.ts +++ b/libs/rejour/rejour-move-abstract/src/index.ts @@ -1 +1 @@ -export * from './lib/rejour-move-abstract' +export * from './lib/rejour-move-abstract.js' diff --git a/libs/rejour/rejour-move-abstract/src/lib/rejour-move-abstract.spec.ts b/libs/rejour/rejour-move-abstract/src/lib/rejour-move-abstract.spec.ts index 041dc689..b13f4abe 100755 --- a/libs/rejour/rejour-move-abstract/src/lib/rejour-move-abstract.spec.ts +++ b/libs/rejour/rejour-move-abstract/src/lib/rejour-move-abstract.spec.ts @@ -1,8 +1,8 @@ import { unified } from 'unified' import rejourParse, { Settings } from 'rejour-parse' import { astStringify } from 'ast-stringify' -import rejourMoveAbstract from './rejour-move-abstract' -import { rejourStringify } from 'rejour-stringify' +import rejourMoveAbstract from './rejour-move-abstract.js' +import rejourStringify from 'rejour-stringify' import { map } from 'unist-util-map' import { reporter } from 'vfile-reporter' diff --git a/libs/rejour/rejour-parse/src/index.ts b/libs/rejour/rejour-parse/src/index.ts index f4db8a80..342700bf 100755 --- a/libs/rejour/rejour-parse/src/index.ts +++ b/libs/rejour/rejour-parse/src/index.ts @@ -1,2 +1,2 @@ -export * from './lib/rejour-parse' -export { default } from './lib/rejour-parse' +export * from './lib/rejour-parse.js' +export { default } from './lib/rejour-parse.js' diff --git a/libs/rejour/rejour-relatex/src/index.ts b/libs/rejour/rejour-relatex/src/index.ts index 8b2d123c..817265fd 100755 --- a/libs/rejour/rejour-relatex/src/index.ts +++ b/libs/rejour/rejour-relatex/src/index.ts @@ -1,3 +1,3 @@ -export * from './lib/rejour-relatex' +export * from './lib/rejour-relatex.js' -export { default } from './lib/rejour-relatex' +export { default } from './lib/rejour-relatex.js' diff --git a/libs/rejour/rejour-relatex/src/lib/rejour-relatex.ts b/libs/rejour/rejour-relatex/src/lib/rejour-relatex.ts index ba446734..4ff77781 100755 --- a/libs/rejour/rejour-relatex/src/lib/rejour-relatex.ts +++ b/libs/rejour/rejour-relatex/src/lib/rejour-relatex.ts @@ -1,12 +1,7 @@ import { toTexast, Options } from 'jast-util-to-texast' import { Root as JastRoot } from 'jast-types' import { Root as TexastRoot } from 'texast' -import { - Plugin, - Processor as UnifiedProcessor, - TransformCallback, - Transformer, -} from 'unified' +import { Plugin, Processor as UnifiedProcessor, TransformCallback, Transformer } from 'unified' import { VFile } from 'vfile' type Processor = UnifiedProcessor @@ -15,10 +10,7 @@ type Processor = UnifiedProcessor * Runs the destination with the new mdast tree. * */ -function bridge( - destination: Processor, - options?: Options -): void | Transformer { +function bridge(destination: Processor, options?: Options): void | Transformer { return (node, file, next) => { //@ts-expect-error there should be a better way to cast this destination.run(toTexast(node, options), file, (error) => { @@ -32,7 +24,7 @@ function bridge( * Further transformers run on the texast tree. */ function mutate( - options: void | Options | undefined = {} + options: void | Options | undefined = {}, ): ReturnType> { //Transformer | void { return (node) => { @@ -44,11 +36,11 @@ function mutate( } /** - * Plugin to bridge or mutate to rehype. + * Plugin to bridge or mutate to relatex * - * If a destination is given, runs the destination with the new mdast + * If a destination is given, runs the destination with the new jast * tree (bridge-mode). - * Without destination, returns the mdast tree: further plugins run on that + * Without destination, returns the jast tree: further plugins run on that * tree (mutate-mode). * * @param destination @@ -56,10 +48,7 @@ function mutate( * @param options * Options passed to `jast-util-to-texast`. */ -const rejourRelatex = function ( - destination?: Processor | Options, - options?: Options -) { +const rejourRelatex = function (destination?: Processor | Options, options?: Options) { let settings: Options | undefined let processor: Processor | undefined @@ -75,7 +64,6 @@ const rejourRelatex = function ( } return processor ? bridge(processor, settings) : mutate(settings) -} as Plugin<[Processor, Options?], JastRoot> & - Plugin<[Options?] | void[], JastRoot, TexastRoot> +} as Plugin<[Processor, Options?], JastRoot> & Plugin<[Options?] | void[], JastRoot, TexastRoot> export default rejourRelatex diff --git a/libs/relatex/relatex-add-preamble/src/lib/relatex-add-preamble.spec.ts b/libs/relatex/relatex-add-preamble/src/lib/relatex-add-preamble.spec.ts index 03371a1a..f4d8d67d 100755 --- a/libs/relatex/relatex-add-preamble/src/lib/relatex-add-preamble.spec.ts +++ b/libs/relatex/relatex-add-preamble/src/lib/relatex-add-preamble.spec.ts @@ -1,4 +1,4 @@ -import { relatexAddPreamble } from './relatex-add-preamble' +import { relatexAddPreamble } from './relatex-add-preamble.js' describe('relatexRelatexAddPreamble', () => { it('should work', () => { diff --git a/libs/relatex/relatex-stringify/src/index.ts b/libs/relatex/relatex-stringify/src/index.ts index 2de9e8f0..d6a95b65 100755 --- a/libs/relatex/relatex-stringify/src/index.ts +++ b/libs/relatex/relatex-stringify/src/index.ts @@ -1,2 +1,2 @@ -export * from './lib/relatex-stringify' -export { default } from './lib/relatex-stringify' +export * from './lib/relatex-stringify.js' +export { default } from './lib/relatex-stringify.js' diff --git a/libs/reoff/docx-to-vfile/package.json b/libs/reoff/docx-to-vfile/package.json index d1de57a1..6127fcea 100755 --- a/libs/reoff/docx-to-vfile/package.json +++ b/libs/reoff/docx-to-vfile/package.json @@ -33,8 +33,6 @@ "files": [ "index.d.ts", "index.js", - "/libindex.js", - "./index.d.ts", "./lib" ] } diff --git a/libs/reoff/docx-to-vfile/src/index.ts b/libs/reoff/docx-to-vfile/src/index.ts index f45e529d..d036d2d7 100755 --- a/libs/reoff/docx-to-vfile/src/index.ts +++ b/libs/reoff/docx-to-vfile/src/index.ts @@ -1,2 +1 @@ -//export * from './lib/get-xml-data.js' export * from './lib/docx-to-vfile-unzipit.js' diff --git a/libs/reoff/docx-to-vfile/src/lib/docx-to-vfile-unzipit.ts b/libs/reoff/docx-to-vfile/src/lib/docx-to-vfile-unzipit.ts index cfdad02b..07f490ce 100755 --- a/libs/reoff/docx-to-vfile/src/lib/docx-to-vfile-unzipit.ts +++ b/libs/reoff/docx-to-vfile/src/lib/docx-to-vfile-unzipit.ts @@ -97,6 +97,7 @@ export async function docxToVFile(file: ArrayBuffer, userOptions: Options = {}): const { entries } = await unzip(file) const rels = await entries['word/_rels/document.xml.rels'].text() const relations = Object.fromEntries( + // eslint-disable-next-line regexp/no-super-linear-backtracking [...rels.matchAll(/Id="(.*?)".*?Target="(.*?)"/g)].map((match) => [match[1], match[2]]), ) diff --git a/libs/reoff/reoff-cite/src/index.ts b/libs/reoff/reoff-cite/src/index.ts index 04fae0d4..c05c6ca8 100755 --- a/libs/reoff/reoff-cite/src/index.ts +++ b/libs/reoff/reoff-cite/src/index.ts @@ -1 +1 @@ -export { default } from './lib/reoff-cite' +export { default } from './lib/reoff-cite.js' diff --git a/libs/reoff/reoff-cite/src/lib/reoff-cite.spec.ts b/libs/reoff/reoff-cite/src/lib/reoff-cite.spec.ts index a7a1c8d2..acd3cd8b 100755 --- a/libs/reoff/reoff-cite/src/lib/reoff-cite.spec.ts +++ b/libs/reoff/reoff-cite/src/lib/reoff-cite.spec.ts @@ -1,4 +1,4 @@ -import reoffCite from './reoff-cite' +import reoffCite from './reoff-cite.js' describe('reoffReoffCite', () => { it('should work', () => { diff --git a/libs/reoff/reoff-clean/.swcrc b/libs/reoff/reoff-clean/.swcrc index eda472cf..36efdfd5 100644 --- a/libs/reoff/reoff-clean/.swcrc +++ b/libs/reoff/reoff-clean/.swcrc @@ -1,7 +1,7 @@ { "$schema": "https://json.schemastore.org/swcrc", "jsc": { - "target": "es2020", + "target": "es2022", "parser": { "syntax": "typescript", "decorators": true, diff --git a/libs/reoff/reoff-clean/src/index.ts b/libs/reoff/reoff-clean/src/index.ts index f2d1d11c..47712676 100755 --- a/libs/reoff/reoff-clean/src/index.ts +++ b/libs/reoff/reoff-clean/src/index.ts @@ -1 +1 @@ -export * from './lib/reoff-clean' +export * from './lib/reoff-clean.js' diff --git a/libs/reoff/reoff-clean/src/lib/reoff-clean.spec.ts b/libs/reoff/reoff-clean/src/lib/reoff-clean.spec.ts index fcf3f36e..58fd0a6f 100755 --- a/libs/reoff/reoff-clean/src/lib/reoff-clean.spec.ts +++ b/libs/reoff/reoff-clean/src/lib/reoff-clean.spec.ts @@ -1,4 +1,4 @@ -import { reoffClean } from './reoff-clean' +import { reoffClean } from './reoff-clean.js' describe('reoffReoffClean', () => { it('should work', () => { diff --git a/libs/reoff/reoff-parse-references/src/index.ts b/libs/reoff/reoff-parse-references/src/index.ts index 7c0b060b..929722ff 100755 --- a/libs/reoff/reoff-parse-references/src/index.ts +++ b/libs/reoff/reoff-parse-references/src/index.ts @@ -1 +1 @@ -export { default } from './lib/reoff-parse-references' +export { default } from './lib/reoff-parse-references.js' diff --git a/libs/reoff/reoff-parse-references/src/lib/reoff-parse-references.spec.ts b/libs/reoff/reoff-parse-references/src/lib/reoff-parse-references.spec.ts index 60f2c08a..a0c6458c 100755 --- a/libs/reoff/reoff-parse-references/src/lib/reoff-parse-references.spec.ts +++ b/libs/reoff/reoff-parse-references/src/lib/reoff-parse-references.spec.ts @@ -1,4 +1,4 @@ -import reoffParseReferences from './reoff-parse-references' +import reoffParseReferences from './reoff-parse-references.js' describe('reoffReoffParseReferences', () => { it('should work', () => { diff --git a/libs/reoff/reoff-parse-references/tsconfig.lib.json b/libs/reoff/reoff-parse-references/tsconfig.lib.json index ff64bb51..5c108b84 100755 --- a/libs/reoff/reoff-parse-references/tsconfig.lib.json +++ b/libs/reoff/reoff-parse-references/tsconfig.lib.json @@ -1,7 +1,6 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "module": "commonjs", "outDir": "../../../dist/out-tsc", "declaration": true, "types": ["node"] diff --git a/libs/reoff/reoff-parse/src/index.ts b/libs/reoff/reoff-parse/src/index.ts index 8365ebb6..21e6f4b8 100755 --- a/libs/reoff/reoff-parse/src/index.ts +++ b/libs/reoff/reoff-parse/src/index.ts @@ -1 +1 @@ -export { default, Settings } from './lib/reoff-parse.js' +export { default, Settings, Parsed, RootWithSource } from './lib/reoff-parse.js' diff --git a/libs/texast/texast-util-add-preamble/src/index.ts b/libs/texast/texast-util-add-preamble/src/index.ts index b801beb4..8721edee 100755 --- a/libs/texast/texast-util-add-preamble/src/index.ts +++ b/libs/texast/texast-util-add-preamble/src/index.ts @@ -1 +1 @@ -export * from './lib/texast-util-add-preamble' +export * from './lib/texast-util-add-preamble.js' diff --git a/libs/texast/texast-util-to-latex/src/index.ts b/libs/texast/texast-util-to-latex/src/index.ts index 388c0abf..37206289 100755 --- a/libs/texast/texast-util-to-latex/src/index.ts +++ b/libs/texast/texast-util-to-latex/src/index.ts @@ -1,3 +1,3 @@ -export * from './lib/texast-util-to-latex' -export * from './lib/types' +export * from './lib/texast-util-to-latex.js' +export * from './lib/types.js' export { default } from './lib/texast-util-to-latex' diff --git a/libs/texast/texast/src/index.ts b/libs/texast/texast/src/index.ts index 3f650ad8..f0352337 100755 --- a/libs/texast/texast/src/index.ts +++ b/libs/texast/texast/src/index.ts @@ -1,2 +1,2 @@ -export * from './lib/texast' -//export * from './lib/utensil-types' +export * from './lib/texast.js' +//export * from './lib/utensil-types.js' diff --git a/libs/utils/misc/package.json b/libs/utils/misc/package.json index 489d61cf..93512621 100755 --- a/libs/utils/misc/package.json +++ b/libs/utils/misc/package.json @@ -1,10 +1,5 @@ { "name": "misc", - "version": "0.0.1", - "dependencies": { - "@types/yauzl": "^2.9.2", - "yauzl": "^2.10.0" - }, "license": "GPL-3.0-or-later", "repository": "https://github.com/TrialAndErrorOrg/parsers", "author": "Thomas F. K. Jorna ", @@ -22,19 +17,5 @@ "readmeFile": "./README.md", "displayName": "misc", "tsconfig": "./tsconfig.lib.json" - }, - "exports": { - ".": { - "types": "./index.d.ts", - "import": "./index.js" - } - }, - "main": "./index.js", - "module": "./index.js", - "types": "./index.d.ts", - "files": [ - "index.d.ts", - "index.js", - "/lib" - ] + } } diff --git a/libs/utils/misc/src/index.ts b/libs/utils/misc/src/index.ts index 27b8d4e7..48814cbf 100755 --- a/libs/utils/misc/src/index.ts +++ b/libs/utils/misc/src/index.ts @@ -1,6 +1,6 @@ -export * from './lib/utils' -export * from './lib/unistVisit' -export * from './lib/tryCatchPromise' -export * from './lib/tryCatchVoid' -export * from './lib/unistMap' -export * from './lib/unistRemove' +export * from './lib/utils.js' +export * from './lib/unistVisit.js' +export * from './lib/tryCatchPromise.js' +export * from './lib/tryCatchVoid.js' +export * from './lib/unistMap.js' +export * from './lib/unistRemove.js' diff --git a/libs/utils/misc/src/lib/extractDocx.spec.ts b/libs/utils/misc/src/lib/extractDocx.spec.ts index 853ee8f3..42bdc2ac 100755 --- a/libs/utils/misc/src/lib/extractDocx.spec.ts +++ b/libs/utils/misc/src/lib/extractDocx.spec.ts @@ -1,10 +1,10 @@ -import { extractDocx } from './extractDocx' +import { extractDocx } from './extractDocx.js' import { readFileSync } from 'fs' -import { tryCatchPromise } from './tryCatchPromise' +import { tryCatchPromise } from './tryCatchPromise.js' describe('utils', () => { const docx = readFileSync( - '/Users/thomas/OneDrive - Journal of Trial and Error/Documents/Publications/Issue 2 and beyond/RGA/Dunleavy/pre/JOTE2_RGA_Dunleavy_v2.docx' + '/Users/thomas/OneDrive - Journal of Trial and Error/Documents/Publications/Issue 2 and beyond/RGA/Dunleavy/pre/JOTE2_RGA_Dunleavy_v2.docx', ) it('should work', async () => { const [res, error] = await tryCatchPromise(extractDocx(docx)) diff --git a/libs/utils/misc/src/lib/extractDocx.ts b/libs/utils/misc/src/lib/extractDocx.ts index 93bd83ef..50239ef5 100755 --- a/libs/utils/misc/src/lib/extractDocx.ts +++ b/libs/utils/misc/src/lib/extractDocx.ts @@ -1,13 +1,13 @@ import { Stream } from 'stream' import { promisify } from 'util' import { ZipFile } from 'yauzl' -import openZipFromBuffer from './openZipFromBuffer' -import { tryCatchPromise } from './tryCatchPromise' -import { tryCatchVoid } from './tryCatchVoid' +import openZipFromBuffer from './openZipFromBuffer.js' +import { tryCatchPromise } from './tryCatchPromise.js' +import { tryCatchVoid } from './tryCatchVoid.js' export async function extractDocx(docx: Buffer, stream?: Stream): Promise { const [zipfile, zipfileError] = await tryCatchPromise( - openZipFromBuffer(docx, { lazyEntries: true }) + openZipFromBuffer(docx, { lazyEntries: true }), ) // console.log(zipfile) if (zipfileError) { diff --git a/libs/utils/misc/src/lib/utils.spec.ts b/libs/utils/misc/src/lib/utils.spec.ts index 764ce6bc..36c24ace 100755 --- a/libs/utils/misc/src/lib/utils.spec.ts +++ b/libs/utils/misc/src/lib/utils.spec.ts @@ -1,4 +1,4 @@ -import { utils } from './utils' +import { utils } from './utils.js' describe('utils', () => { it('should work', () => { diff --git a/libs/utils/ojs-to-preamble/src/index.ts b/libs/utils/ojs-to-preamble/src/index.ts index 83036c1c..266dfccd 100755 --- a/libs/utils/ojs-to-preamble/src/index.ts +++ b/libs/utils/ojs-to-preamble/src/index.ts @@ -1 +1 @@ -export * from './lib/utils-ojs-to-preamble' +export * from './lib/utils-ojs-to-preamble.js' diff --git a/libs/xast/xast-util-has-attribute/src/index.ts b/libs/xast/xast-util-has-attribute/src/index.ts index 1a4f1d2c..5a53728a 100755 --- a/libs/xast/xast-util-has-attribute/src/index.ts +++ b/libs/xast/xast-util-has-attribute/src/index.ts @@ -1 +1 @@ -export * from './lib/xast-util-has-attribute' +export * from './lib/xast-util-has-attribute.js' diff --git a/libs/xast/xast-util-is-element/src/index.ts b/libs/xast/xast-util-is-element/src/index.ts index ba012451..7f9c7277 100755 --- a/libs/xast/xast-util-is-element/src/index.ts +++ b/libs/xast/xast-util-is-element/src/index.ts @@ -1 +1 @@ -export * from './lib/xast-util-is-element' +export * from './lib/xast-util-is-element.js' diff --git a/libs/xast/xast-util-select/src/index.ts b/libs/xast/xast-util-select/src/index.ts index cafbc101..04073799 100755 --- a/libs/xast/xast-util-select/src/index.ts +++ b/libs/xast/xast-util-select/src/index.ts @@ -1,30 +1,16 @@ -import { XastNode, Space, Element } from './lib/types' +import { XastNode, Space, Element } from './lib/types.js' -import { any } from './lib/any' -import { parse } from './lib/parse' +import { any } from './lib/any.js' +import { parse } from './lib/parse.js' -export function matches( - selector: string, - node?: XastNode, - space?: Space -): boolean { - return Boolean( - any(parse(selector), node, { space, one: true, shallow: true })[0] - ) +export function matches(selector: string, node?: XastNode, space?: Space): boolean { + return Boolean(any(parse(selector), node, { space, one: true, shallow: true })[0]) } -export function select( - selector: string, - node?: XastNode, - space?: Space -): Element | null { +export function select(selector: string, node?: XastNode, space?: Space): Element | null { return any(parse(selector), node, { space, one: true })[0] || null } -export function selectAll( - selector: string, - node?: XastNode, - space?: Space -): Array { +export function selectAll(selector: string, node?: XastNode, space?: Space): Array { return any(parse(selector), node, { space }) } diff --git a/libs/xast/xast-util-select/src/lib/any.ts b/libs/xast/xast-util-select/src/lib/any.ts index fd244eaa..ea4f18c1 100755 --- a/libs/xast/xast-util-select/src/lib/any.ts +++ b/libs/xast/xast-util-select/src/lib/any.ts @@ -6,14 +6,14 @@ import { XastNode as Node, XastParent as Parent, SelectState, -} from './types' +} from './types.js' import { html, svg } from 'property-information' import { zwitch } from 'zwitch' -import { enterState } from './enter-state' -import { nest } from './nest' -import { pseudo } from './pseudo' -import { test } from './test-node' +import { enterState } from './enter-state.js' +import { nest } from './nest.js' +import { pseudo } from './pseudo.js' +import { test } from './test-node.js' const type = zwitch('type', { /** @@ -33,7 +33,7 @@ const type = zwitch('type', { export function any( query: Selectors | RuleSet | Rule, node: Node | undefined, - state: SelectState + state: SelectState, ): Array { return query && node ? type(query, node, state) : [] } @@ -44,11 +44,7 @@ export function any( * @param {SelectState} state * @returns {Array.} */ -function selectors( - query: Selectors, - node: Node, - state: SelectState -): Array { +function selectors(query: Selectors, node: Node, state: SelectState): Array { const collector = new Collector(state.one) let index = -1 @@ -65,11 +61,7 @@ function selectors( * @param {SelectState} state * @returns {Array.} */ -function ruleSet( - query: RuleSet, - node: Node, - state: SelectState -): Array { +function ruleSet(query: RuleSet, node: Node, state: SelectState): Array { return rule(query.rule, node, state) } @@ -101,7 +93,7 @@ function rule(query: Rule, tree: Node, state: SelectState): Array { iterator, one: state.one, shallow: state.shallow, - }) + }), ) return collector.result @@ -112,7 +104,7 @@ function rule(query: Rule, tree: Node, state: SelectState): Array { node: Node, index: number, parent: Parent | null, - state: SelectState + state: SelectState, ) { const exit = enterState(state, node) diff --git a/libs/xast/xast-util-select/src/lib/enter-state.ts b/libs/xast/xast-util-select/src/lib/enter-state.ts index 37348ca2..a84ca98b 100755 --- a/libs/xast/xast-util-select/src/lib/enter-state.ts +++ b/libs/xast/xast-util-select/src/lib/enter-state.ts @@ -3,10 +3,8 @@ import { SelectState, XastNode, ElementChild, Direction } from './types.js' import { direction } from 'direction' import { isElement } from 'xast-util-is-element' -import { toString } from 'xast-util-to-string' -import { svg } from 'property-information' import { visit, EXIT, SKIP } from 'unist-util-visit' -import { element } from './util' +import { element } from './util.js' import { Parent } from 'xast' /** @@ -102,15 +100,12 @@ export function enterState(state: SelectState, node: XastNode): () => void { // manually writing this out due to bug with unist-util-visit type Action = boolean | 'skip' type Index = number - type ActionTuple = [ - Action | null | undefined | void, - Index | null | undefined - ] + type ActionTuple = [Action | null | undefined | void, Index | null | undefined] /** @type {Visitor} */ function inferDirectionality( child: ElementChild, index: number | null, - parent: Parent | null + parent: Parent | null, ): null | undefined | Index | Action | ActionTuple | void | [] { if (child.type === 'text') { dirInferred = dirBidi(child.value) @@ -119,8 +114,7 @@ export function enterState(state: SelectState, node: XastNode): () => void { if ( child !== node && - (isElement(child, ['bdi', 'script', 'style', 'textare']) || - dirAttribute(child)) + (isElement(child, ['bdi', 'script', 'style', 'textare']) || dirAttribute(child)) ) { return SKIP } @@ -146,9 +140,7 @@ function dirAttribute(node: ElementChild): Direction | undefined { ? node.attributes.dir.toLowerCase() : undefined - return value === 'auto' || value === 'ltr' || value === 'rtl' - ? value - : undefined + return value === 'auto' || value === 'ltr' || value === 'rtl' ? value : undefined } function noop() { diff --git a/libs/xast/xast-util-select/src/lib/id.ts b/libs/xast/xast-util-select/src/lib/id.ts index 60903e27..8150709d 100755 --- a/libs/xast/xast-util-select/src/lib/id.ts +++ b/libs/xast/xast-util-select/src/lib/id.ts @@ -1,4 +1,4 @@ -import { Rule, Element } from './types' +import { Rule, Element } from './types.js' export function id(query: Rule, element: Element): boolean { return Boolean(element.attributes && element.attributes.id === query.id) } diff --git a/libs/xast/xast-util-select/src/lib/name.ts b/libs/xast/xast-util-select/src/lib/name.ts index a6e67e0e..b174b488 100755 --- a/libs/xast/xast-util-select/src/lib/name.ts +++ b/libs/xast/xast-util-select/src/lib/name.ts @@ -1,4 +1,4 @@ -import { Rule, Element } from './types' +import { Rule, Element } from './types.js' export function name(query: Rule, element: Element): boolean { return query.tagName === '*' || query.tagName === element.name diff --git a/libs/xast/xast-util-select/src/lib/nest.ts b/libs/xast/xast-util-select/src/lib/nest.ts index 6eb8b92b..8afb8706 100755 --- a/libs/xast/xast-util-select/src/lib/nest.ts +++ b/libs/xast/xast-util-select/src/lib/nest.ts @@ -6,11 +6,11 @@ import { SelectState, SelectIterator, Handler, -} from './types' +} from './types.js' import { zwitch } from 'zwitch' -import { enterState } from './enter-state' -import { parent, element } from './util' +import { enterState } from './enter-state.js' +import { parent, element } from './util.js' const own = {}.hasOwnProperty @@ -33,7 +33,7 @@ export function nest( node: Node, index: number | null, parent: Parent | null, - state: SelectState + state: SelectState, ): void { handle(query, node, index, parent, state) } @@ -53,7 +53,7 @@ function topScan( node: Node, index: number | null, parent: Parent | null, - state: SelectState + state: SelectState, ): void { // Shouldn’t happen. /* c8 ignore next 3 */ @@ -77,7 +77,7 @@ function descendant( node: Node, index: number | null, parent: Parent | null, - state: SelectState + state: SelectState, ): void { const previous = state.iterator @@ -90,7 +90,7 @@ function descendant( node: Node, index: number, parent: Parent | null, - state: SelectState + state: SelectState, ): void { // Shouldn’t happen. /* c8 ignore next 3 */ @@ -114,7 +114,7 @@ function child( node: Node, _1: number | null, _2: Parent | null, - state: SelectState + state: SelectState, ): void { if (!parent(node)) return if (node.children.length === 0) return @@ -127,7 +127,7 @@ function adjacentSibling( _: Node, index: number | null, parent: Parent | null, - state: SelectState + state: SelectState, ): void { // Shouldn’t happen. /* c8 ignore next */ @@ -141,7 +141,7 @@ function generalSibling( _: Node, index: number | null, parent: Parent | null, - state: SelectState + state: SelectState, ): void { // Shouldn’t happen. /* c8 ignore next */ @@ -163,7 +163,7 @@ function indexedSearch( parent: Parent, state: SelectState, from = 0, - firstElementOnly = false + firstElementOnly = false, ) { const handle = state.index ? delay : add const children = parent.children @@ -219,9 +219,7 @@ function indexedSearch( */ function delay(node: Element, childIndex: number) { const elementsBefore = elements - const elementsByTypeBefore = own.call(types, node.name) - ? types[node.name] - : 0 + const elementsByTypeBefore = own.call(types, node.name) ? types[node.name] : 0 count(node.name) diff --git a/libs/xast/xast-util-select/src/lib/parse.ts b/libs/xast/xast-util-select/src/lib/parse.ts index e0ae976e..2185d6b8 100755 --- a/libs/xast/xast-util-select/src/lib/parse.ts +++ b/libs/xast/xast-util-select/src/lib/parse.ts @@ -1,7 +1,4 @@ -import { Selector } from './types' -import { Selectors } from './types' -import { RuleSet } from './types' -import { Rule } from './types' +import { Selector, Selectors, RuleSet, Rule } from './types.js' import { CssSelectorParser } from 'css-selector-parser' import fauxEsmNthCheck from 'nth-check' @@ -11,12 +8,7 @@ import { zwitch } from 'zwitch' const nthCheck = fauxEsmNthCheck -const nth = new Set([ - 'nth-child', - 'nth-last-child', - 'nth-of-type', - 'nth-last-of-type', -]) +const nth = new Set(['nth-child', 'nth-last-child', 'nth-of-type', 'nth-last-of-type']) const parser = new CssSelectorParser() diff --git a/libs/xast/xast-util-select/src/lib/pseudo.ts b/libs/xast/xast-util-select/src/lib/pseudo.ts index 45c0d7dc..db6cb0e3 100755 --- a/libs/xast/xast-util-select/src/lib/pseudo.ts +++ b/libs/xast/xast-util-select/src/lib/pseudo.ts @@ -9,7 +9,7 @@ import { SelectState, Element, ElementChild, -} from './types' +} from './types.js' import { extendedFilter } from 'bcp-47-match' import { parse as commas } from 'comma-separated-tokens' @@ -17,7 +17,7 @@ import { hasAttribute } from 'xast-util-has-attribute' import { isElement } from 'xast-util-is-element' import { whitespace } from 'hast-util-whitespace' import { zwitch } from 'zwitch' -import { any } from './any' +import { any } from './any.js' const handle = zwitch('name', { //// @ts-expect-error: hush. @@ -81,7 +81,7 @@ export function pseudo( element: Element, index: number | null, parent: Parent | null, - state: SelectState + state: SelectState, ): boolean { const pseudos = query.pseudos let offset = -1 @@ -106,7 +106,7 @@ function matches( element: Element, _1: number | null, _2: Parent | null, - state: SelectState + state: SelectState, ): boolean { const shallow = state.shallow const one = state.one @@ -135,7 +135,7 @@ function not( element: Element, index: number | null, parent: Parent | null, - state: SelectState + state: SelectState, ): boolean { return !matches(query, element, index, parent, state) } @@ -146,9 +146,7 @@ function not( * @returns {boolean} */ function anyLink(_: RulePseudo, element: Element): boolean { - return ( - isElement(element, ['a', 'area', 'link']) && hasAttribute(element, 'href') - ) + return isElement(element, ['a', 'area', 'link']) && hasAttribute(element, 'href') } /** @@ -160,9 +158,8 @@ function checked(_: RulePseudo, element: Element): boolean { if (isElement(element, ['input', 'menuitem'])) { return Boolean( element.attributes && - (element.attributes.type === 'checkbox' || - element.attributes.type === 'radio') && - hasAttribute(element, 'checked') + (element.attributes.type === 'checkbox' || element.attributes.type === 'radio') && + hasAttribute(element, 'checked'), ) } @@ -186,7 +183,7 @@ function dir( _1: Element, _2: number | null, _3: Parent | null, - state: SelectState + state: SelectState, ): boolean { return state.direction === query.value } @@ -226,10 +223,7 @@ function enabled(query: RulePseudo, element: Element): boolean { * @returns {boolean} */ function required(_: RulePseudo, element: Element): boolean { - return ( - isElement(element, ['input', 'textarea', 'select']) && - hasAttribute(element, 'required') - ) + return isElement(element, ['input', 'textarea', 'select']) && hasAttribute(element, 'required') } /** @@ -254,7 +248,7 @@ function readWrite( element: Element, _1: number | null, _2: Parent | null, - state: SelectState + state: SelectState, ): boolean { return isElement(element, ['input', 'textarea']) ? !hasAttribute(element, 'readOnly') && !hasAttribute(element, 'disabled') @@ -274,7 +268,7 @@ function readOnly( element: Element, index: number | null, parent: Parent | null, - state: SelectState + state: SelectState, ): boolean { return !readWrite(query, element, index, parent, state) } @@ -292,13 +286,13 @@ function root( element: Element, _1: number | null, parent: Parent | null, - state: SelectState + state: SelectState, ): boolean { return Boolean( (!parent || parent.type === 'root') && state.schema && (state.schema.space === 'html' || state.schema.space === 'svg') && - isElement(element, ['html', 'svg']) + isElement(element, ['html', 'svg']), ) } @@ -315,13 +309,9 @@ function scope( element: Element, _1: number | null, _2: Parent | null, - state: SelectState + state: SelectState, ): boolean { - return Boolean( - isElement(element) && - state.scopeElements && - state.scopeElements.includes(element) - ) + return Boolean(isElement(element) && state.scopeElements && state.scopeElements.includes(element)) } /** @@ -354,9 +344,7 @@ function blank(_: RulePseudo, element: Element): boolean { * @returns {boolean} */ function check(child: ElementChild): boolean { - return ( - child.type === 'element' || (child.type === 'text' && !whitespace(child)) - ) + return child.type === 'element' || (child.type === 'text' && !whitespace(child)) } } @@ -373,7 +361,7 @@ function firstChild( _1: Element, _2: number | null, _3: Parent | null, - state: SelectState + state: SelectState, ): boolean { assertDeep(state, query) return state.elementIndex === 0 @@ -392,7 +380,7 @@ function lang( _1: Element, _2: number | null, _3: Parent | null, - state: SelectState + state: SelectState, ): boolean { return ( state.language !== '' && @@ -416,12 +404,10 @@ function lastChild( _1: Element, _2: number | null, _3: Parent | null, - state: SelectState + state: SelectState, ): boolean { assertDeep(state, query) - return Boolean( - state.elementCount && state.elementIndex === state.elementCount - 1 - ) + return Boolean(state.elementCount && state.elementIndex === state.elementCount - 1) } /** @@ -437,7 +423,7 @@ function onlyChild( _1: Element, _2: number | null, _3: Parent | null, - state: SelectState + state: SelectState, ): boolean { assertDeep(state, query) return state.elementCount === 1 @@ -456,12 +442,10 @@ function nthChild( _1: Element, _2: number | null, _3: Parent | null, - state: SelectState + state: SelectState, ): boolean { assertDeep(state, query) - return ( - typeof state.elementIndex === 'number' && query.value(state.elementIndex) - ) + return typeof state.elementIndex === 'number' && query.value(state.elementIndex) } /** @@ -477,13 +461,13 @@ function nthLastChild( _1: Element, _2: number | null, _3: Parent | null, - state: SelectState + state: SelectState, ): boolean { assertDeep(state, query) return Boolean( typeof state.elementCount === 'number' && typeof state.elementIndex === 'number' && - query.value(state.elementCount - state.elementIndex - 1) + query.value(state.elementCount - state.elementIndex - 1), ) } @@ -500,7 +484,7 @@ function nthOfType( _1: Element, _2: number | null, _3: Parent | null, - state: SelectState + state: SelectState, ): boolean { assertDeep(state, query) return typeof state.typeIndex === 'number' && query.value(state.typeIndex) @@ -519,7 +503,7 @@ function nthLastOfType( _1: Element, _2: number | null, _3: Parent | null, - state: SelectState + state: SelectState, ): boolean { assertDeep(state, query) return ( @@ -542,7 +526,7 @@ function firstOfType( _1: Element, _2: number | null, _3: Parent | null, - state: SelectState + state: SelectState, ): boolean { assertDeep(state, query) return state.typeIndex === 0 @@ -561,7 +545,7 @@ function lastOfType( _1: Element, _2: number | null, _3: Parent | null, - state: SelectState + state: SelectState, ): boolean { assertDeep(state, query) return ( @@ -584,7 +568,7 @@ function onlyOfType( _1: Element, _2: number | null, _3: Parent | null, - state: SelectState + state: SelectState, ): boolean { assertDeep(state, query) return state.typeCount === 1 @@ -595,10 +579,7 @@ function onlyOfType( * @param {(child: ElementChild) => boolean} check * @returns {boolean} */ -function someChildren( - element: Element, - check: (child: ElementChild) => boolean -): boolean { +function someChildren(element: Element, check: (child: ElementChild) => boolean): boolean { const children = element.children let index = -1 @@ -649,7 +630,7 @@ function has( element: Element, _2: number | null, _3: Parent | null, - state: SelectState + state: SelectState, ): boolean { const shallow = state.shallow const one = state.one @@ -683,11 +664,7 @@ function appendScope(value: Selector): Selectors { const rule = selector.selectors[index].rule rule.nestingOperator = null - if ( - !rule.pseudos || - rule.pseudos.length !== 1 || - rule.pseudos[0].name !== 'scope' - ) { + if (!rule.pseudos || rule.pseudos.length !== 1 || rule.pseudos[0].name !== 'scope') { selector.selectors[index] = { type: 'ruleSet', // @ts-expect-error pseudos are fine w/ just a name! diff --git a/libs/xast/xast-util-select/src/lib/test-node.ts b/libs/xast/xast-util-select/src/lib/test-node.ts index 023affe0..606dce6d 100755 --- a/libs/xast/xast-util-select/src/lib/test-node.ts +++ b/libs/xast/xast-util-select/src/lib/test-node.ts @@ -1,11 +1,11 @@ -import { Rule, XastNode, XastParent as Parent, SelectState } from './types' +import { Rule, XastNode, XastParent as Parent, SelectState } from './types.js' -import { attribute } from './attribute' +import { attribute } from './attribute.js' //import {className} from './class-name.js' -import { id } from './id' -import { name } from './name' -import { pseudo } from './pseudo' -import { element } from './util' +import { id } from './id.js' +import { name } from './name.js' +import { pseudo } from './pseudo.js' +import { element } from './util.js' /** * @param {Rule} query @@ -20,7 +20,7 @@ export function test( node: XastNode, index: number | null, parent: Parent | null, - state: SelectState + state: SelectState, ): boolean { return Boolean( element(node) && @@ -29,6 +29,6 @@ export function test( // (!query.classNames || className(query, node)) && (!query.id || id(query, node)) && (!query.attrs || attribute(query, node, state.schema)) && - (!query.pseudos || pseudo(query, node, index, parent, state)) + (!query.pseudos || pseudo(query, node, index, parent, state)), ) } diff --git a/libs/xast/xast-util-select/src/lib/util.ts b/libs/xast/xast-util-select/src/lib/util.ts index 1edfcd1d..87b21e29 100755 --- a/libs/xast/xast-util-select/src/lib/util.ts +++ b/libs/xast/xast-util-select/src/lib/util.ts @@ -1,6 +1,4 @@ -import { Node } from './types.js' -import { Element } from './types.js' -import { Parent } from './types.js' +import { Node, Element, Parent } from './types.js' import { AssertPredicate } from 'xast-util-is-element' export type IsElement = AssertPredicate diff --git a/patches/@nrwl__workspace@15.8.5.patch b/patches/@nrwl__workspace@15.8.5.patch deleted file mode 100644 index 09fc594c..00000000 --- a/patches/@nrwl__workspace@15.8.5.patch +++ /dev/null @@ -1,154 +0,0 @@ -diff --git a/src/utilities/buildable-libs-utils.js b/src/utilities/buildable-libs-utils.js -index 1ec6eb948138ebb4ea2b86cf286a6ca99d38fc38..ac23420a413f324ea81ae2d1ec79c7788d577d0e 100644 ---- a/src/utilities/buildable-libs-utils.js -+++ b/src/utilities/buildable-libs-utils.js -@@ -33,42 +33,42 @@ function calculateProjectDependencies(projGraph, root, projectName, targetName, - } - const dependencies = collectedDeps - .map(({ name: dep, isTopLevel }) => { -- let project = null; -- const depNode = projGraph.nodes[dep] || projGraph.externalNodes[dep]; -- if (depNode.type === 'lib') { -- if (isBuildable(targetName, depNode)) { -- const libPackageJsonPath = (0, path_1.join)(root, depNode.data.root, 'package.json'); -+ let project = null; -+ const depNode = projGraph.nodes[dep] || projGraph.externalNodes[dep]; -+ if (depNode.type === 'lib') { -+ if (isBuildable(targetName, depNode)) { -+ const libPackageJsonPath = (0, path_1.join)(root, depNode.data.root, 'package.json'); -+ project = { -+ name: (0, fileutils_1.fileExists)(libPackageJsonPath) -+ ? (0, devkit_1.readJsonFile)(libPackageJsonPath).name // i.e. @workspace/mylib -+ : dep, -+ outputs: (0, devkit_1.getOutputsForTargetAndConfiguration)({ -+ overrides: {}, -+ target: { -+ project: projectName, -+ target: targetName, -+ configuration: configurationName, -+ }, -+ }, depNode), -+ node: depNode, -+ }; -+ } -+ else { -+ nonBuildableDependencies.push(dep); -+ } -+ } -+ else if (depNode.type === 'npm') { - project = { -- name: (0, fileutils_1.fileExists)(libPackageJsonPath) -- ? (0, devkit_1.readJsonFile)(libPackageJsonPath).name // i.e. @workspace/mylib -- : dep, -- outputs: (0, devkit_1.getOutputsForTargetAndConfiguration)({ -- overrides: {}, -- target: { -- project: projectName, -- target: targetName, -- configuration: configurationName, -- }, -- }, depNode), -+ name: depNode.data.packageName, -+ outputs: [], - node: depNode, - }; - } -- else { -- nonBuildableDependencies.push(dep); -+ if (project && isTopLevel) { -+ topLevelDependencies.push(project); - } -- } -- else if (depNode.type === 'npm') { -- project = { -- name: depNode.data.packageName, -- outputs: [], -- node: depNode, -- }; -- } -- if (project && isTopLevel) { -- topLevelDependencies.push(project); -- } -- return project; -- }) -+ return project; -+ }) - .filter((x) => !!x); - dependencies.sort((a, b) => (a.name > b.name ? 1 : b.name > a.name ? -1 : 0)); - return { -@@ -116,10 +116,37 @@ function readTsConfigWithRemappedPaths(tsConfig, generatedTsConfigPath, dependen - */ - function computeCompilerOptionsPaths(tsConfig, dependencies) { - const paths = readPaths(tsConfig) || {}; -- updatePaths(dependencies, paths); -+ const moduleResolution = readModule(tsConfig) || 0 -+ const needsDirectResolution = moduleResolution > 2 -+ updatePaths(dependencies, paths, needsDirectResolution); - return paths; - } - exports.computeCompilerOptionsPaths = computeCompilerOptionsPaths; -+function readModule(tsConfig) { -+ var _a; -+ if (!tsModule) { -+ tsModule = (0, typescript_1.ensureTypescript)(); -+ } -+ try { -+ let config; -+ if (typeof tsConfig === 'string') { -+ const configFile = tsModule.readConfigFile(tsConfig, tsModule.sys.readFile); -+ config = tsModule.parseJsonConfigFileContent(configFile.config, tsModule.sys, (0, path_1.dirname)(tsConfig)); -+ } -+ else { -+ config = tsConfig; -+ } -+ if ((_a = config.options) === null || _a === void 0 ? void 0 : _a.moduleResolution) { -+ return config.options.moduleResolution; -+ } -+ else { -+ return null; -+ } -+ } -+ catch (e) { -+ return null; -+ } -+} - function readPaths(tsConfig) { - var _a; - if (!tsModule) { -@@ -164,7 +191,7 @@ function cleanupTmpTsConfigFile(tmpTsConfigPath) { - function checkDependentProjectsHaveBeenBuilt(root, projectName, targetName, projectDependencies) { - const missing = findMissingBuildDependencies(root, projectName, targetName, projectDependencies); - if (missing.length > 0) { -- console.error((0, devkit_1.stripIndents) ` -+ console.error((0, devkit_1.stripIndents)` - It looks like all of ${projectName}'s dependencies have not been built yet: - ${missing.map((x) => ` - ${x.node.name}`).join('\n')} - -@@ -193,15 +220,24 @@ function findMissingBuildDependencies(root, projectName, targetName, projectDepe - return depLibsToBuildFirst; - } - exports.findMissingBuildDependencies = findMissingBuildDependencies; --function updatePaths(dependencies, paths) { -+function updatePaths(dependencies, paths, moduleResolution) { - const pathsKeys = Object.keys(paths); - // For each registered dependency - dependencies.forEach((dep) => { - var _a; - // If there are outputs - if (dep.outputs && dep.outputs.length > 0) { -- // Directly map the dependency name to the output paths (dist/packages/..., etc.) -- paths[dep.name] = dep.outputs; -+ // if moduleResolution is node16 or nodenext, we need to add a direct path to the output file -+ // we do this by looking at the main entry of the package.json file of the already compiled package, as its the most reliable way -+ if (moduleResolution) { -+ const outputPackageJSON = (0, path_1.join)(dep.outputs[0], 'package.json') -+ const { main, module, exports } = (0, devkit_1.readJsonFile)(outputPackageJSON) -+ const entry = exports?.['.']?.['import'] ?? module ?? main ?? './index.js' -+ paths[dep.name] = [(0, path_1.join)(dep.outputs[0], entry)] -+ } else { -+ // Directly map the dependency name to the output paths (dist/packages/..., etc.) -+ paths[dep.name] = dep.outputs; -+ } - // check for secondary entrypoints - // For each registered path - for (const path of pathsKeys) { \ No newline at end of file