scholarly-parse 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/LICENSE +201 -0
- package/README.md +118 -0
- package/changelog/0.1.x/0.1.0.md +17 -0
- package/changelog/template.md +150 -0
- package/dist/detect.d.ts +11 -0
- package/dist/detect.d.ts.map +1 -0
- package/dist/detect.js +51 -0
- package/dist/detect.js.map +1 -0
- package/dist/formats/html/blocks.d.ts +29 -0
- package/dist/formats/html/blocks.d.ts.map +1 -0
- package/dist/formats/html/blocks.js +527 -0
- package/dist/formats/html/blocks.js.map +1 -0
- package/dist/formats/html/context.d.ts +19 -0
- package/dist/formats/html/context.d.ts.map +1 -0
- package/dist/formats/html/context.js +122 -0
- package/dist/formats/html/context.js.map +1 -0
- package/dist/formats/html/index.d.ts +7 -0
- package/dist/formats/html/index.d.ts.map +1 -0
- package/dist/formats/html/index.js +7 -0
- package/dist/formats/html/index.js.map +1 -0
- package/dist/formats/html/inline.d.ts +26 -0
- package/dist/formats/html/inline.d.ts.map +1 -0
- package/dist/formats/html/inline.js +253 -0
- package/dist/formats/html/inline.js.map +1 -0
- package/dist/formats/html/metadata.d.ts +30 -0
- package/dist/formats/html/metadata.d.ts.map +1 -0
- package/dist/formats/html/metadata.js +212 -0
- package/dist/formats/html/metadata.js.map +1 -0
- package/dist/formats/html/parse.d.ts +17 -0
- package/dist/formats/html/parse.d.ts.map +1 -0
- package/dist/formats/html/parse.js +405 -0
- package/dist/formats/html/parse.js.map +1 -0
- package/dist/formats/html/references.d.ts +12 -0
- package/dist/formats/html/references.d.ts.map +1 -0
- package/dist/formats/html/references.js +123 -0
- package/dist/formats/html/references.js.map +1 -0
- package/dist/formats/jats/blocks.d.ts +52 -0
- package/dist/formats/jats/blocks.d.ts.map +1 -0
- package/dist/formats/jats/blocks.js +614 -0
- package/dist/formats/jats/blocks.js.map +1 -0
- package/dist/formats/jats/context.d.ts +17 -0
- package/dist/formats/jats/context.d.ts.map +1 -0
- package/dist/formats/jats/context.js +2 -0
- package/dist/formats/jats/context.js.map +1 -0
- package/dist/formats/jats/fragment.d.ts +7 -0
- package/dist/formats/jats/fragment.d.ts.map +1 -0
- package/dist/formats/jats/fragment.js +42 -0
- package/dist/formats/jats/fragment.js.map +1 -0
- package/dist/formats/jats/front.d.ts +25 -0
- package/dist/formats/jats/front.d.ts.map +1 -0
- package/dist/formats/jats/front.js +380 -0
- package/dist/formats/jats/front.js.map +1 -0
- package/dist/formats/jats/index.d.ts +8 -0
- package/dist/formats/jats/index.d.ts.map +1 -0
- package/dist/formats/jats/index.js +8 -0
- package/dist/formats/jats/index.js.map +1 -0
- package/dist/formats/jats/inline.d.ts +24 -0
- package/dist/formats/jats/inline.d.ts.map +1 -0
- package/dist/formats/jats/inline.js +274 -0
- package/dist/formats/jats/inline.js.map +1 -0
- package/dist/formats/jats/parse.d.ts +9 -0
- package/dist/formats/jats/parse.d.ts.map +1 -0
- package/dist/formats/jats/parse.js +247 -0
- package/dist/formats/jats/parse.js.map +1 -0
- package/dist/formats/jats/references.d.ts +25 -0
- package/dist/formats/jats/references.d.ts.map +1 -0
- package/dist/formats/jats/references.js +406 -0
- package/dist/formats/jats/references.js.map +1 -0
- package/dist/formats/jats/tables.d.ts +18 -0
- package/dist/formats/jats/tables.d.ts.map +1 -0
- package/dist/formats/jats/tables.js +105 -0
- package/dist/formats/jats/tables.js.map +1 -0
- package/dist/formats/jats/text.d.ts +23 -0
- package/dist/formats/jats/text.d.ts.map +1 -0
- package/dist/formats/jats/text.js +114 -0
- package/dist/formats/jats/text.js.map +1 -0
- package/dist/formats/latexml/blocks.d.ts +13 -0
- package/dist/formats/latexml/blocks.d.ts.map +1 -0
- package/dist/formats/latexml/blocks.js +454 -0
- package/dist/formats/latexml/blocks.js.map +1 -0
- package/dist/formats/latexml/context.d.ts +19 -0
- package/dist/formats/latexml/context.d.ts.map +1 -0
- package/dist/formats/latexml/context.js +18 -0
- package/dist/formats/latexml/context.js.map +1 -0
- package/dist/formats/latexml/index.d.ts +7 -0
- package/dist/formats/latexml/index.d.ts.map +1 -0
- package/dist/formats/latexml/index.js +7 -0
- package/dist/formats/latexml/index.js.map +1 -0
- package/dist/formats/latexml/inline.d.ts +16 -0
- package/dist/formats/latexml/inline.d.ts.map +1 -0
- package/dist/formats/latexml/inline.js +113 -0
- package/dist/formats/latexml/inline.js.map +1 -0
- package/dist/formats/latexml/parse.d.ts +16 -0
- package/dist/formats/latexml/parse.d.ts.map +1 -0
- package/dist/formats/latexml/parse.js +405 -0
- package/dist/formats/latexml/parse.js.map +1 -0
- package/dist/formats/pdf/blocks.d.ts +14 -0
- package/dist/formats/pdf/blocks.d.ts.map +1 -0
- package/dist/formats/pdf/blocks.js +203 -0
- package/dist/formats/pdf/blocks.js.map +1 -0
- package/dist/formats/pdf/index.d.ts +7 -0
- package/dist/formats/pdf/index.d.ts.map +1 -0
- package/dist/formats/pdf/index.js +7 -0
- package/dist/formats/pdf/index.js.map +1 -0
- package/dist/formats/pdf/inline.d.ts +8 -0
- package/dist/formats/pdf/inline.d.ts.map +1 -0
- package/dist/formats/pdf/inline.js +91 -0
- package/dist/formats/pdf/inline.js.map +1 -0
- package/dist/formats/pdf/layout.d.ts +33 -0
- package/dist/formats/pdf/layout.d.ts.map +1 -0
- package/dist/formats/pdf/layout.js +358 -0
- package/dist/formats/pdf/layout.js.map +1 -0
- package/dist/formats/pdf/lines.d.ts +40 -0
- package/dist/formats/pdf/lines.d.ts.map +1 -0
- package/dist/formats/pdf/lines.js +104 -0
- package/dist/formats/pdf/lines.js.map +1 -0
- package/dist/formats/pdf/load.d.ts +43 -0
- package/dist/formats/pdf/load.d.ts.map +1 -0
- package/dist/formats/pdf/load.js +126 -0
- package/dist/formats/pdf/load.js.map +1 -0
- package/dist/formats/pdf/parse.d.ts +9 -0
- package/dist/formats/pdf/parse.d.ts.map +1 -0
- package/dist/formats/pdf/parse.js +126 -0
- package/dist/formats/pdf/parse.js.map +1 -0
- package/dist/formats/pdf/references.d.ts +14 -0
- package/dist/formats/pdf/references.d.ts.map +1 -0
- package/dist/formats/pdf/references.js +104 -0
- package/dist/formats/pdf/references.js.map +1 -0
- package/dist/formats/pdf/structure.d.ts +29 -0
- package/dist/formats/pdf/structure.d.ts.map +1 -0
- package/dist/formats/pdf/structure.js +533 -0
- package/dist/formats/pdf/structure.js.map +1 -0
- package/dist/formats/tei/index.d.ts +7 -0
- package/dist/formats/tei/index.d.ts.map +1 -0
- package/dist/formats/tei/index.js +7 -0
- package/dist/formats/tei/index.js.map +1 -0
- package/dist/formats/tei/inline.d.ts +24 -0
- package/dist/formats/tei/inline.d.ts.map +1 -0
- package/dist/formats/tei/inline.js +107 -0
- package/dist/formats/tei/inline.js.map +1 -0
- package/dist/formats/tei/parse.d.ts +4 -0
- package/dist/formats/tei/parse.d.ts.map +1 -0
- package/dist/formats/tei/parse.js +560 -0
- package/dist/formats/tei/parse.js.map +1 -0
- package/dist/html/dom.d.ts +35 -0
- package/dist/html/dom.d.ts.map +1 -0
- package/dist/html/dom.js +70 -0
- package/dist/html/dom.js.map +1 -0
- package/dist/html/interstitial.d.ts +14 -0
- package/dist/html/interstitial.d.ts.map +1 -0
- package/dist/html/interstitial.js +67 -0
- package/dist/html/interstitial.js.map +1 -0
- package/dist/html/tables.d.ts +12 -0
- package/dist/html/tables.d.ts.map +1 -0
- package/dist/html/tables.js +62 -0
- package/dist/html/tables.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/model/diagnostics.d.ts +15 -0
- package/dist/model/diagnostics.d.ts.map +1 -0
- package/dist/model/diagnostics.js +37 -0
- package/dist/model/diagnostics.js.map +1 -0
- package/dist/model/document.d.ts +289 -0
- package/dist/model/document.d.ts.map +1 -0
- package/dist/model/document.js +13 -0
- package/dist/model/document.js.map +1 -0
- package/dist/model/extremes.d.ts +11 -0
- package/dist/model/extremes.d.ts.map +1 -0
- package/dist/model/extremes.js +23 -0
- package/dist/model/extremes.js.map +1 -0
- package/dist/model/index.d.ts +8 -0
- package/dist/model/index.d.ts.map +1 -0
- package/dist/model/index.js +2 -0
- package/dist/model/index.js.map +1 -0
- package/dist/model/input.d.ts +14 -0
- package/dist/model/input.d.ts.map +1 -0
- package/dist/model/input.js +47 -0
- package/dist/model/input.js.map +1 -0
- package/dist/model/result.d.ts +53 -0
- package/dist/model/result.d.ts.map +1 -0
- package/dist/model/result.js +40 -0
- package/dist/model/result.js.map +1 -0
- package/dist/model/section-ids.d.ts +8 -0
- package/dist/model/section-ids.d.ts.map +1 -0
- package/dist/model/section-ids.js +28 -0
- package/dist/model/section-ids.js.map +1 -0
- package/dist/model/section-kinds.d.ts +19 -0
- package/dist/model/section-kinds.d.ts.map +1 -0
- package/dist/model/section-kinds.js +42 -0
- package/dist/model/section-kinds.js.map +1 -0
- package/dist/model/table-grid.d.ts +40 -0
- package/dist/model/table-grid.d.ts.map +1 -0
- package/dist/model/table-grid.js +79 -0
- package/dist/model/table-grid.js.map +1 -0
- package/dist/parse.d.ts +18 -0
- package/dist/parse.d.ts.map +1 -0
- package/dist/parse.js +35 -0
- package/dist/parse.js.map +1 -0
- package/dist/render/escape.d.ts +53 -0
- package/dist/render/escape.d.ts.map +1 -0
- package/dist/render/escape.js +94 -0
- package/dist/render/escape.js.map +1 -0
- package/dist/render/index.d.ts +8 -0
- package/dist/render/index.d.ts.map +1 -0
- package/dist/render/index.js +8 -0
- package/dist/render/index.js.map +1 -0
- package/dist/render/inline.d.ts +39 -0
- package/dist/render/inline.d.ts.map +1 -0
- package/dist/render/inline.js +87 -0
- package/dist/render/inline.js.map +1 -0
- package/dist/render/markdown.d.ts +35 -0
- package/dist/render/markdown.d.ts.map +1 -0
- package/dist/render/markdown.js +279 -0
- package/dist/render/markdown.js.map +1 -0
- package/dist/render/sections.d.ts +25 -0
- package/dist/render/sections.d.ts.map +1 -0
- package/dist/render/sections.js +45 -0
- package/dist/render/sections.js.map +1 -0
- package/dist/render/text.d.ts +13 -0
- package/dist/render/text.d.ts.map +1 -0
- package/dist/render/text.js +66 -0
- package/dist/render/text.js.map +1 -0
- package/dist/xml/mathml.d.ts +24 -0
- package/dist/xml/mathml.d.ts.map +1 -0
- package/dist/xml/mathml.js +201 -0
- package/dist/xml/mathml.js.map +1 -0
- package/dist/xml/ordered.d.ts +49 -0
- package/dist/xml/ordered.d.ts.map +1 -0
- package/dist/xml/ordered.js +151 -0
- package/dist/xml/ordered.js.map +1 -0
- package/dist/xml/well-formed.d.ts +15 -0
- package/dist/xml/well-formed.d.ts.map +1 -0
- package/dist/xml/well-formed.js +120 -0
- package/dist/xml/well-formed.js.map +1 -0
- package/package.json +137 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview A single-pass well-formedness check run before parsing. fast-xml-parser
|
|
3
|
+
* accepts markup that is not well-formed and drops what follows the fault without an
|
|
4
|
+
* error — an unescaped `<` in `p < 0.05` swallows the rest of its section — so input
|
|
5
|
+
* that fails this check is reported as malformed instead of parsed short.
|
|
6
|
+
*
|
|
7
|
+
* The check covers that failure mode: every `<` opens a tag, comment, CDATA section,
|
|
8
|
+
* processing instruction, or declaration; each of those is terminated; end tags match
|
|
9
|
+
* their start tags; nothing is left open. Entity references and attribute syntax are
|
|
10
|
+
* left to the parser.
|
|
11
|
+
* @module src/xml/well-formed
|
|
12
|
+
*/
|
|
13
|
+
const NAME = /[A-Za-z_:À-][\w.:·À--]*/y;
|
|
14
|
+
/** Describes the first well-formedness fault in `text`, or undefined when there is none. */
|
|
15
|
+
export function findMarkupFault(text) {
|
|
16
|
+
const open = [];
|
|
17
|
+
let at = text.indexOf('<');
|
|
18
|
+
while (at !== -1) {
|
|
19
|
+
let end;
|
|
20
|
+
const next = text[at + 1];
|
|
21
|
+
if (next === '!') {
|
|
22
|
+
if (text.startsWith('<!--', at))
|
|
23
|
+
end = closingIndex(text, '-->', at + 4);
|
|
24
|
+
else if (text.startsWith('<![CDATA[', at))
|
|
25
|
+
end = closingIndex(text, ']]>', at + 9);
|
|
26
|
+
else
|
|
27
|
+
end = declarationEnd(text, at + 2);
|
|
28
|
+
}
|
|
29
|
+
else if (next === '?') {
|
|
30
|
+
end = closingIndex(text, '?>', at + 2);
|
|
31
|
+
}
|
|
32
|
+
else if (next === '/') {
|
|
33
|
+
const name = nameAt(text, at + 2);
|
|
34
|
+
const expected = open.pop();
|
|
35
|
+
if (name === undefined || name !== expected) {
|
|
36
|
+
return fault(text, at, expected
|
|
37
|
+
? `</${name ?? ''}> where </${expected}> was expected`
|
|
38
|
+
: `</${name ?? ''}> closes no element`);
|
|
39
|
+
}
|
|
40
|
+
end = text.indexOf('>', at + 2 + name.length);
|
|
41
|
+
if (end !== -1 && text.slice(at + 2 + name.length, end).trim() !== '')
|
|
42
|
+
return fault(text, at, `malformed end tag </${name}>`);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
const name = nameAt(text, at + 1);
|
|
46
|
+
if (name === undefined)
|
|
47
|
+
return fault(text, at, 'unescaped "<"');
|
|
48
|
+
end = startTagEnd(text, at + 1 + name.length);
|
|
49
|
+
if (end !== -1 && text[end - 1] !== '/')
|
|
50
|
+
open.push(name);
|
|
51
|
+
}
|
|
52
|
+
if (end === -1)
|
|
53
|
+
return fault(text, at, 'markup never terminated');
|
|
54
|
+
at = text.indexOf('<', end + 1);
|
|
55
|
+
}
|
|
56
|
+
const unclosed = open.at(-1);
|
|
57
|
+
return unclosed === undefined ? undefined : `<${unclosed}> is never closed`;
|
|
58
|
+
}
|
|
59
|
+
function nameAt(text, index) {
|
|
60
|
+
NAME.lastIndex = index;
|
|
61
|
+
return NAME.exec(text)?.[0];
|
|
62
|
+
}
|
|
63
|
+
/** Index of the last character of `delimiter` at or after `from`, or -1. */
|
|
64
|
+
function closingIndex(text, delimiter, from) {
|
|
65
|
+
const index = text.indexOf(delimiter, from);
|
|
66
|
+
return index === -1 ? -1 : index + delimiter.length - 1;
|
|
67
|
+
}
|
|
68
|
+
/** The `>` ending a start tag, skipping quoted attribute values; -1 when a `<` or the end comes first. */
|
|
69
|
+
function startTagEnd(text, from) {
|
|
70
|
+
let quote = '';
|
|
71
|
+
for (let i = from; i < text.length; i++) {
|
|
72
|
+
const char = text[i];
|
|
73
|
+
if (quote) {
|
|
74
|
+
if (char === quote)
|
|
75
|
+
quote = '';
|
|
76
|
+
}
|
|
77
|
+
else if (char === '"' || char === "'") {
|
|
78
|
+
quote = char;
|
|
79
|
+
}
|
|
80
|
+
else if (char === '>') {
|
|
81
|
+
return i;
|
|
82
|
+
}
|
|
83
|
+
else if (char === '<') {
|
|
84
|
+
return -1;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return -1;
|
|
88
|
+
}
|
|
89
|
+
/** The `>` ending a `<!DOCTYPE …>` or other declaration, past any `[…]` internal subset. */
|
|
90
|
+
function declarationEnd(text, from) {
|
|
91
|
+
let quote = '';
|
|
92
|
+
let depth = 0;
|
|
93
|
+
for (let i = from; i < text.length; i++) {
|
|
94
|
+
const char = text[i];
|
|
95
|
+
if (quote) {
|
|
96
|
+
if (char === quote)
|
|
97
|
+
quote = '';
|
|
98
|
+
}
|
|
99
|
+
else if (char === '"' || char === "'") {
|
|
100
|
+
quote = char;
|
|
101
|
+
}
|
|
102
|
+
else if (char === '[') {
|
|
103
|
+
depth++;
|
|
104
|
+
}
|
|
105
|
+
else if (char === ']') {
|
|
106
|
+
depth--;
|
|
107
|
+
}
|
|
108
|
+
else if (char === '>' && depth <= 0) {
|
|
109
|
+
return i;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return -1;
|
|
113
|
+
}
|
|
114
|
+
function fault(text, index, problem) {
|
|
115
|
+
let line = 1;
|
|
116
|
+
for (let i = text.indexOf('\n'); i !== -1 && i < index; i = text.indexOf('\n', i + 1))
|
|
117
|
+
line++;
|
|
118
|
+
return `line ${line}: ${problem}`;
|
|
119
|
+
}
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E,CAAC;IAC9F,OAAO,QAAQ,IAAI,KAAK,OAAO,EAAE,CAAC;AACpC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "scholarly-parse",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Parse scholarly papers — JATS, Grobid TEI, arXiv HTML, publisher HTML, PDF — into one document model and Markdown.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"author": "Casey Hand <casey@caseyjhand.com> (https://caseyjhand.com)",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/cyanheads/scholarly-parse.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/cyanheads/scholarly-parse#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/cyanheads/scholarly-parse/issues"
|
|
15
|
+
},
|
|
16
|
+
"funding": [
|
|
17
|
+
{
|
|
18
|
+
"type": "github",
|
|
19
|
+
"url": "https://github.com/sponsors/cyanheads"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"type": "buy_me_a_coffee",
|
|
23
|
+
"url": "https://www.buymeacoffee.com/cyanheads"
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"keywords": [
|
|
27
|
+
"jats",
|
|
28
|
+
"tei",
|
|
29
|
+
"grobid",
|
|
30
|
+
"latexml",
|
|
31
|
+
"arxiv",
|
|
32
|
+
"pubmed-central",
|
|
33
|
+
"europe-pmc",
|
|
34
|
+
"scholarly-communication",
|
|
35
|
+
"scientific-papers",
|
|
36
|
+
"full-text",
|
|
37
|
+
"pdf",
|
|
38
|
+
"pdf-to-markdown",
|
|
39
|
+
"html-to-markdown",
|
|
40
|
+
"markdown",
|
|
41
|
+
"parser",
|
|
42
|
+
"llm",
|
|
43
|
+
"rag",
|
|
44
|
+
"typescript",
|
|
45
|
+
"bun",
|
|
46
|
+
"cyanheads"
|
|
47
|
+
],
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=22.0.0"
|
|
50
|
+
},
|
|
51
|
+
"packageManager": "bun@1.4.2",
|
|
52
|
+
"sideEffects": false,
|
|
53
|
+
"exports": {
|
|
54
|
+
".": {
|
|
55
|
+
"types": "./dist/index.d.ts",
|
|
56
|
+
"import": "./dist/index.js",
|
|
57
|
+
"default": "./dist/index.js"
|
|
58
|
+
},
|
|
59
|
+
"./jats": {
|
|
60
|
+
"types": "./dist/formats/jats/index.d.ts",
|
|
61
|
+
"import": "./dist/formats/jats/index.js",
|
|
62
|
+
"default": "./dist/formats/jats/index.js"
|
|
63
|
+
},
|
|
64
|
+
"./tei": {
|
|
65
|
+
"types": "./dist/formats/tei/index.d.ts",
|
|
66
|
+
"import": "./dist/formats/tei/index.js",
|
|
67
|
+
"default": "./dist/formats/tei/index.js"
|
|
68
|
+
},
|
|
69
|
+
"./latexml": {
|
|
70
|
+
"types": "./dist/formats/latexml/index.d.ts",
|
|
71
|
+
"import": "./dist/formats/latexml/index.js",
|
|
72
|
+
"default": "./dist/formats/latexml/index.js"
|
|
73
|
+
},
|
|
74
|
+
"./html": {
|
|
75
|
+
"types": "./dist/formats/html/index.d.ts",
|
|
76
|
+
"import": "./dist/formats/html/index.js",
|
|
77
|
+
"default": "./dist/formats/html/index.js"
|
|
78
|
+
},
|
|
79
|
+
"./pdf": {
|
|
80
|
+
"types": "./dist/formats/pdf/index.d.ts",
|
|
81
|
+
"import": "./dist/formats/pdf/index.js",
|
|
82
|
+
"default": "./dist/formats/pdf/index.js"
|
|
83
|
+
},
|
|
84
|
+
"./package.json": "./package.json"
|
|
85
|
+
},
|
|
86
|
+
"peerDependencies": {
|
|
87
|
+
"linkedom": ">=0.18.0",
|
|
88
|
+
"unpdf": ">=1.8.0"
|
|
89
|
+
},
|
|
90
|
+
"peerDependenciesMeta": {
|
|
91
|
+
"linkedom": {
|
|
92
|
+
"optional": true
|
|
93
|
+
},
|
|
94
|
+
"unpdf": {
|
|
95
|
+
"optional": true
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"files": ["dist/", "changelog/", "CHANGELOG.md"],
|
|
99
|
+
"scripts": {
|
|
100
|
+
"build": "tsc -p tsconfig.build.json",
|
|
101
|
+
"clean": "rm -rf dist .tsbuildinfo",
|
|
102
|
+
"rebuild": "bun run clean && bun run build",
|
|
103
|
+
"typecheck": "tsc --noEmit",
|
|
104
|
+
"lint": "biome check",
|
|
105
|
+
"format": "biome check --write .",
|
|
106
|
+
"test": "vitest run",
|
|
107
|
+
"test:corpus": "vitest run tests/corpus",
|
|
108
|
+
"corpus:snapshot": "SCHOLARLY_PARSE_UPDATE_SNAPSHOTS=1 vitest run tests/corpus",
|
|
109
|
+
"corpus:sample": "bun run scripts/corpus/sample.ts",
|
|
110
|
+
"corpus:agreement": "bun run scripts/corpus/agreement.ts",
|
|
111
|
+
"corpus:attribution": "bun run scripts/corpus/attribution.ts",
|
|
112
|
+
"changelog:build": "bun run scripts/build-changelog.ts",
|
|
113
|
+
"changelog:check": "bun run scripts/build-changelog.ts --check",
|
|
114
|
+
"tree": "bun run scripts/tree.ts",
|
|
115
|
+
"list-skills": "bun run scripts/list-skills.ts",
|
|
116
|
+
"devcheck": "bun run scripts/devcheck.ts",
|
|
117
|
+
"release:github": "bun run scripts/release-github.ts",
|
|
118
|
+
"prepublishOnly": "bun run devcheck"
|
|
119
|
+
},
|
|
120
|
+
"devDependencies": {
|
|
121
|
+
"@arethetypeswrong/cli": "^0.18.5",
|
|
122
|
+
"@biomejs/biome": "^2.5.14",
|
|
123
|
+
"@socketsecurity/bun-security-scanner": "^1.1.3",
|
|
124
|
+
"@types/bun": "^1.4.2",
|
|
125
|
+
"@types/node": "^26.6.2",
|
|
126
|
+
"ignore": "^7.0.10",
|
|
127
|
+
"linkedom": "^0.18.13",
|
|
128
|
+
"publint": "^0.3.24",
|
|
129
|
+
"typescript": "^7.0.2",
|
|
130
|
+
"unpdf": "^1.8.1",
|
|
131
|
+
"vitest": "^5.0.1",
|
|
132
|
+
"zod": "^4.6.5"
|
|
133
|
+
},
|
|
134
|
+
"dependencies": {
|
|
135
|
+
"fast-xml-parser": "^5.11.1"
|
|
136
|
+
}
|
|
137
|
+
}
|