@effortlessmotion/pdf-to-md 0.1.5 → 0.1.7
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/README.md +15 -56
- package/dist/cjs/cli/audit.js +2 -2
- package/dist/cjs/cli/audit.js.map +1 -1
- package/dist/cjs/cli/types.d.cts +3 -1
- package/dist/cjs/cli/types.d.ts +3 -1
- package/dist/cjs/cli/types.js.map +1 -1
- package/dist/cjs/cli.d.cts +0 -1
- package/dist/cjs/cli.d.ts +0 -1
- package/dist/cjs/cli.js +11 -91
- package/dist/cjs/cli.js.map +1 -1
- package/dist/esm/cli/audit.js +2 -2
- package/dist/esm/cli/audit.js.map +1 -1
- package/dist/esm/cli/types.d.ts +3 -1
- package/dist/esm/cli/types.js.map +1 -1
- package/dist/esm/cli.d.ts +0 -1
- package/dist/esm/cli.js +7 -32
- package/dist/esm/cli.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -6,16 +6,13 @@
|
|
|
6
6
|
> misread your document, you get the measured knobs, the detectors that point at exactly what to
|
|
7
7
|
> distrust, and the raw analysis to converge on a lossless conversion yourself.
|
|
8
8
|
|
|
9
|
-
Pure TypeScript, runs anywhere `npm install` works. No system dependencies, no cloud calls: the
|
|
10
|
-
OCR engine ([tesseract.js](https://www.npmjs.com/package/tesseract.js)) and its recognition model
|
|
11
|
-
install with the package and run fully offline.
|
|
9
|
+
Pure TypeScript, runs anywhere `npm install` works. No system dependencies, no cloud calls: the OCR engine ([tesseract.js](https://www.npmjs.com/package/tesseract.js)) and its recognition model install with the package and run fully offline.
|
|
12
10
|
|
|
13
11
|
```bash
|
|
14
12
|
npm install pdf-to-md
|
|
15
13
|
```
|
|
16
14
|
|
|
17
|
-
Requires Node >=22.13.0 — below that, the OCR path silently finds no words instead of
|
|
18
|
-
erroring (see Development for the measured reason).
|
|
15
|
+
Requires Node >=22.13.0 — below that, the OCR path silently finds no words instead of erroring (see Development for the measured reason).
|
|
19
16
|
|
|
20
17
|
## CLI
|
|
21
18
|
|
|
@@ -31,11 +28,7 @@ pdf-to-md audit <words.jsonl> <file.md> severity-1 check: every recogni
|
|
|
31
28
|
pdf-to-md --help | --version
|
|
32
29
|
```
|
|
33
30
|
|
|
34
|
-
Everyday flags: `--ocr`, `--no-ocr`, `--pages N[-M]`, `--stdout`, `--json` (QA report),
|
|
35
|
-
`--format md|txt|raw` (default `md`; `raw` = the full `Analysis` as JSON, report included; `txt` =
|
|
36
|
-
reading-order plain text — line-granular on the text path with no paragraph reflow, block-granular
|
|
37
|
-
on the OCR path), `--debug-words=FILE` (severity-1 audit input, see below), `--dpi=N`
|
|
38
|
-
(OCR render resolution). Usage errors exit 2; runtime errors exit 1.
|
|
31
|
+
Everyday flags: `--ocr`, `--no-ocr`, `--pages N[-M]`, `--stdout`, `--json` (QA report), `--format md|txt|raw` (default `md`; `raw` = the full `Analysis` as JSON, report included; `txt` = reading-order plain text — line-granular on the text path with no paragraph reflow, block-granular on the OCR path), `--debug-words=FILE` (severity-1 audit input, see below), `--dpi=N` (OCR render resolution). Usage errors, runtime errors, and audit loss all exit non-zero.
|
|
39
32
|
|
|
40
33
|
## Library
|
|
41
34
|
|
|
@@ -45,19 +38,9 @@ import { pdfToMarkdown } from 'pdf-to-md';
|
|
|
45
38
|
const { markdown, report, warnings } = await pdfToMarkdown('book.pdf');
|
|
46
39
|
```
|
|
47
40
|
|
|
48
|
-
`pdfToMarkdown` is the headline API: text layer first, falling back to OCR on its own when the
|
|
49
|
-
pages are images of text. For explicit control over which path runs (hybrid pages — a real text
|
|
50
|
-
layer plus a large embedded image — are a class the tool itself flags, and reading both requires
|
|
51
|
-
naming the path), the engine-agnostic word-input seam, and the `analyze`/`toMarkdown`/`toText`
|
|
52
|
-
raw-analysis API described below, every exported function and option is documented at its
|
|
53
|
-
declaration — `extractText`, `extractOcr`, `analyze`, `toMarkdown`, `toText`, `auditWords`,
|
|
54
|
-
`DEFAULT_TUNING`, and the rest — visible in editor hover and in the [API Docs](https://kmalakoff.github.io/pdf-to-md/).
|
|
55
|
-
TSDoc is the source of truth for per-option prose; this file stays a map, not a mirror.
|
|
41
|
+
`pdfToMarkdown` is the headline API: text layer first, falling back to OCR on its own when the pages are images of text. For explicit control over which path runs (hybrid pages — a real text layer plus a large embedded image — are a class the tool itself flags, and reading both requires naming the path), the engine-agnostic word-input seam, and the `analyze`/`toMarkdown`/`toText` raw-analysis API described below, every exported function and option is documented at its declaration — `extractText`, `extractOcr`, `analyze`, `toMarkdown`, `toText`, `auditWords`, `DEFAULT_TUNING`, and the rest — visible in editor hover and in the [API Docs](https://kmalakoff.github.io/pdf-to-md/). TSDoc is the source of truth for per-option prose; this file stays a map, not a mirror.
|
|
56
42
|
|
|
57
|
-
All library functions throw a typed `PdfToMdError` (`code: 'PDF_OPEN' | 'PAGE_RANGE' |
|
|
58
|
-
'PAGE_RENDER' | 'OCR_PAGE_FAILED' | 'WORDS_INPUT' | 'ANALYSIS_INPUT'`) and never write to
|
|
59
|
-
stdout/stderr or exit the process; warnings are returned data (plus an `onWarning` callback for
|
|
60
|
-
streaming them).
|
|
43
|
+
All library functions throw a typed `PdfToMdError` (`code: 'PDF_OPEN' | 'PAGE_RANGE' | 'PAGE_RENDER' | 'OCR_PAGE_FAILED' | 'WORDS_INPUT' | 'ANALYSIS_INPUT'`) and never write to stdout/stderr or exit the process; warnings are returned data (plus an `onWarning` callback for streaming them).
|
|
61
44
|
|
|
62
45
|
## Design contract
|
|
63
46
|
|
|
@@ -67,7 +50,7 @@ What this tool promises about errors, in severity order — each with the instru
|
|
|
67
50
|
heading, or a visible `> [floats]` aside. **Enforced by:** `--debug-words=FILE` dumps every
|
|
68
51
|
recognized word as clean JSON lines (`{page, text, x, y, w, h, confidence?}`); the shipped
|
|
69
52
|
`auditWords()` (or `pdf-to-md audit words.jsonl out.md`) checks the dump against the markdown
|
|
70
|
-
and exits
|
|
53
|
+
and exits non-zero on any loss (`MISSING > 0`) — a first-class part of the product, usable as a CI
|
|
71
54
|
gate, not a path into the source tree.
|
|
72
55
|
2. **Invisible corruption is minimized and made detectable.** Right-words-wrong-order failures
|
|
73
56
|
(column braiding, mid-sentence splits) are what the geometry works hardest to prevent; a second
|
|
@@ -83,26 +66,15 @@ What this tool promises about errors, in severity order — each with the instru
|
|
|
83
66
|
enough (`^> \[(floats|review: [^\]]+)\] (.*)$`) for a downstream agent to find and handle
|
|
84
67
|
without guessing — surfaced in `--json` as `report.floats` / `report.reviewBlocks`.
|
|
85
68
|
|
|
86
|
-
The QA report (`--json`) exists to make 2 and 3 reviewable: per-page stats flag suspect pages, and
|
|
87
|
-
`pdf-to-md render` shows you the page as printed — the only real ground truth.
|
|
69
|
+
The QA report (`--json`) exists to make 2 and 3 reviewable: per-page stats flag suspect pages, and `pdf-to-md render` shows you the page as printed — the only real ground truth.
|
|
88
70
|
|
|
89
|
-
**Why there's no `--floats=drop`:** an earlier version offered one, filtering `> [floats]` lines
|
|
90
|
-
out of the output. Measured against a real 100-page document, floats held real sentence tails on
|
|
91
|
-
pages 29, 48, and 94 — "drop" invited exactly the silent loss rule 1 forbids, so the knob was cut.
|
|
92
|
-
Filtering them back out downstream is one line (`^> \[floats\]`) a caller can write when floats
|
|
93
|
-
truly are noise for their document; the tool won't make that call for you.
|
|
71
|
+
**Why there's no `--floats=drop`:** an earlier version offered one, filtering `> [floats]` lines out of the output. Measured against a real 100-page document, floats held real sentence tails on pages 29, 48, and 94 — "drop" invited exactly the silent loss rule 1 forbids, so the knob was cut. Filtering them back out downstream is one line (`^> \[floats\]`) a caller can write when floats truly are noise for their document; the tool won't make that call for you.
|
|
94
72
|
|
|
95
|
-
**`closedHyphens` as a cross-check, not a target:** the text path's `report.closedHyphens` counts
|
|
96
|
-
line-final hyphens closed against a dictionary (e.g. "creat-" + "ive" → "creative"). It exists to
|
|
97
|
-
explain the auditor's `strict_deficits` count, not to be optimized directly: a strict deficit is
|
|
98
|
-
usually a hyphen-rejoin firing (a word split across two lines, correctly closed into one), not lost
|
|
99
|
-
text — `MISSING` is the loss signal, and `closedHyphens` is what explains the difference.
|
|
73
|
+
**`closedHyphens` as a cross-check, not a target:** the text path's `report.closedHyphens` counts line-final hyphens closed against a dictionary (e.g. "creat-" + "ive" → "creative"). It exists to explain the auditor's `strict_deficits` count, not to be optimized directly: a strict deficit is usually a hyphen-rejoin firing (a word split across two lines, correctly closed into one), not lost text — `MISSING` is the loss signal, and `closedHyphens` is what explains the difference.
|
|
100
74
|
|
|
101
75
|
## Tuning
|
|
102
76
|
|
|
103
|
-
OCR-path heuristics run on constants measured against real documents — the derivation for each
|
|
104
|
-
lives beside its value in `src/geometry.ts`'s `DEFAULT_TUNING` (the canonical source; typedoc
|
|
105
|
-
renders it). Override per run instead of editing source:
|
|
77
|
+
OCR-path heuristics run on constants measured against real documents — the derivation for each lives beside its value in `src/geometry.ts`'s `DEFAULT_TUNING` (the canonical source; typedoc renders it). Override per run instead of editing source:
|
|
106
78
|
|
|
107
79
|
| flag | controls | default |
|
|
108
80
|
|---|---|---|
|
|
@@ -117,15 +89,9 @@ renders it). Override per run instead of editing source:
|
|
|
117
89
|
| `--line-height-ratio` | same-line boxes with a larger height ratio don't merge | `2.4` |
|
|
118
90
|
| `--dpi` | OCR page-render resolution; raise for tiny print or chart/label pages, `>~400` measured worse on ordinary prose pages (`test/unit/sparse-retry.test.ts`) | `288` |
|
|
119
91
|
|
|
120
|
-
**Hybrid pages:** raising `--dpi` fixes chart/label corruption but can make scattered numerals on
|
|
121
|
-
the same page WORSE, not better (measured: a chart page's numerals recognized at `288` dpi, then
|
|
122
|
-
none at `600`, while the page's own text layer already had them all) — `--dpi` is a chart-LABEL
|
|
123
|
-
fix, not a scattered-numeral fix. For hybrid pages, compare (or merge, via `analyze()`) the
|
|
124
|
-
text-layer and OCR readings rather than trusting one dpi setting to fix everything on the page.
|
|
92
|
+
**Hybrid pages:** raising `--dpi` fixes chart/label corruption but can make scattered numerals on the same page WORSE, not better (measured: a chart page's numerals recognized at `288` dpi, then none at `600`, while the page's own text layer already had them all) — `--dpi` is a chart-LABEL fix, not a scattered-numeral fix. For hybrid pages, compare (or merge, via `analyze()`) the text-layer and OCR readings rather than trusting one dpi setting to fix everything on the page.
|
|
125
93
|
|
|
126
|
-
Typical loop: run with `--json`, find suspect pages in `pageStats`, `pdf-to-md render` them, then
|
|
127
|
-
re-extract just those pages with `--pages` and an adjusted flag — or use `--format=raw` to get the
|
|
128
|
-
full `Analysis` (words + blocks + report) and converge programmatically.
|
|
94
|
+
Typical loop: run with `--json`, find suspect pages in `pageStats`, `pdf-to-md render` them, then re-extract just those pages with `--pages` and an adjusted flag — or use `--format=raw` to get the full `Analysis` (words + blocks + report) and converge programmatically.
|
|
129
95
|
|
|
130
96
|
## For AI agents
|
|
131
97
|
|
|
@@ -133,9 +99,7 @@ full `Analysis` (words + blocks + report) and converge programmatically.
|
|
|
133
99
|
npx skills add kmalakoff/pdf-to-md # -g for global, -a claude-code to target
|
|
134
100
|
```
|
|
135
101
|
|
|
136
|
-
One skill: `pdf-to-md` for driving the QA loop above (reading `pageStats`, rendering pages as
|
|
137
|
-
ground truth, targeted re-extraction, the severity-1 audit, and the `> [floats]` / `> [review:
|
|
138
|
-
...]` markers) instead of trusting the first conversion.
|
|
102
|
+
One skill: `pdf-to-md` for driving the QA loop above (reading `pageStats`, rendering pages as ground truth, targeted re-extraction, the severity-1 audit, and the `> [floats]` / `> [review: ...]` markers) instead of trusting the first conversion.
|
|
139
103
|
|
|
140
104
|
## Development
|
|
141
105
|
|
|
@@ -147,11 +111,6 @@ npm test # synthetic fixtures (ground truth by construction), a fetched
|
|
|
147
111
|
npm run prepublishOnly # tsds validate: build + biome + depcheck + docs
|
|
148
112
|
```
|
|
149
113
|
|
|
150
|
-
Source is TypeScript; the published package ships a built `dist/` (dual CJS + ESM via `tsds
|
|
151
|
-
build`) because Node's native type-stripping refuses to run `.ts` files once they're under
|
|
152
|
-
`node_modules`. Tests still run directly against source; the CLI test helper spawns the built
|
|
153
|
-
`bin/cli.js`, which is why a build has to happen first.
|
|
114
|
+
Source is TypeScript; the published package ships a built `dist/` (dual CJS + ESM via `tsds build`) because Node's native type-stripping refuses to run `.ts` files once they're under `node_modules`. Tests still run directly against source; the CLI test helper spawns the built `bin/cli.js`, which is why a build has to happen first.
|
|
154
115
|
|
|
155
|
-
`engines.node` is `>=22.13.0`, measured (not assumed): `pdfjs-dist`'s CJS build needs Node's
|
|
156
|
-
stable synchronous `require(esm)`, and its rendering path uses a V8 `ArrayBuffer` API missing
|
|
157
|
-
before Node 22. Don't lower this floor without re-running that measurement.
|
|
116
|
+
`engines.node` is `>=22.13.0`, measured (not assumed): `pdfjs-dist`'s CJS build needs Node's stable synchronous `require(esm)`, and its rendering path uses a V8 `ArrayBuffer` API missing before Node 22. Don't lower this floor without re-running that measurement.
|
package/dist/cjs/cli/audit.js
CHANGED
|
@@ -217,8 +217,8 @@ var audit = function audit(ctx) {
|
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
// MISSING>0 is the severity-1 fail signal: a recognized word this markdown
|
|
220
|
-
// lost. Exit
|
|
221
|
-
if (result.missing > 0) process.exitCode =
|
|
220
|
+
// lost. Exit with the CLI's error code so the subcommand is usable as a CI gate; strict_deficits from hyphen-join repairs are reported but not failures.
|
|
221
|
+
if (result.missing > 0) process.exitCode = ctx.errorCode;
|
|
222
222
|
return [
|
|
223
223
|
2
|
|
224
224
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/formats/pdf-to-md/src/cli/audit.ts"],"sourcesContent":["// audit command — the severity-1 audit instrument (README's \"Design\n// contract\") as a first-class subcommand. Thin wrapper over src/audit.ts's auditWords (the library returns data, only the CLI prints and exits).\nimport { auditWords } from '../audit.ts';\nimport type { Command } from './types.ts';\n\nconst USAGE = 'usage: pdf-to-md audit <words.jsonl> <file.md>';\n\nconst audit: Command = async (ctx) => {\n if (ctx.rest.includes('-h') || ctx.rest.includes('--help')) {\n console.log(USAGE);\n return;\n }\n const [wordsPath, mdPath] = ctx.rest;\n if (!wordsPath || !mdPath) ctx.usageError(USAGE);\n\n const result = auditWords(wordsPath, mdPath);\n for (const line of result.lines) console.log(line);\n\n // MISSING>0 is the severity-1 fail signal: a recognized word this markdown\n // lost. Exit
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/formats/pdf-to-md/src/cli/audit.ts"],"sourcesContent":["// audit command — the severity-1 audit instrument (README's \"Design\n// contract\") as a first-class subcommand. Thin wrapper over src/audit.ts's auditWords (the library returns data, only the CLI prints and exits).\nimport { auditWords } from '../audit.ts';\nimport type { Command } from './types.ts';\n\nconst USAGE = 'usage: pdf-to-md audit <words.jsonl> <file.md>';\n\nconst audit: Command = async (ctx) => {\n if (ctx.rest.includes('-h') || ctx.rest.includes('--help')) {\n console.log(USAGE);\n return;\n }\n const [wordsPath, mdPath] = ctx.rest;\n if (!wordsPath || !mdPath) ctx.usageError(USAGE);\n\n const result = auditWords(wordsPath, mdPath);\n for (const line of result.lines) console.log(line);\n\n // MISSING>0 is the severity-1 fail signal: a recognized word this markdown\n // lost. Exit with the CLI's error code so the subcommand is usable as a CI gate; strict_deficits from hyphen-join repairs are reported but not failures.\n if (result.missing > 0) process.exitCode = ctx.errorCode;\n};\n\nexport default audit;\n"],"names":["USAGE","audit","ctx","wordsPath","mdPath","result","line","rest","includes","console","log","usageError","auditWords","lines","missing","process","exitCode","errorCode"],"mappings":"AAAA,oEAAoE;AACpE,iJAAiJ;;;;;+BAsBjJ;;;eAAA;;;uBArB2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG3B,IAAMA,QAAQ;AAEd,IAAMC,QAAiB,eAAOC;;YAKAA,WAArBC,WAAWC,QAGZC,QACD,2BAAA,mBAAA,gBAAA,WAAA,OAAMC;;YARX,IAAIJ,IAAIK,IAAI,CAACC,QAAQ,CAAC,SAASN,IAAIK,IAAI,CAACC,QAAQ,CAAC,WAAW;gBAC1DC,QAAQC,GAAG,CAACV;gBACZ;;;YACF;YAC4BE,6BAAAA,IAAIK,IAAI,MAA7BJ,YAAqBD,cAAVE,SAAUF;YAC5B,IAAI,CAACC,aAAa,CAACC,QAAQF,IAAIS,UAAU,CAACX;YAEpCK,SAASO,IAAAA,mBAAU,EAACT,WAAWC;YAChC,kCAAA,2BAAA;;gBAAL,IAAK,YAAcC,OAAOQ,KAAK,uBAA1B,6BAAA,QAAA,yBAAA;oBAAMP,OAAN;oBAA4BG,QAAQC,GAAG,CAACJ;;;gBAAxC;gBAAA;;;yBAAA,6BAAA;wBAAA;;;wBAAA;8BAAA;;;;YAEL,2EAA2E;YAC3E,yJAAyJ;YACzJ,IAAID,OAAOS,OAAO,GAAG,GAAGC,QAAQC,QAAQ,GAAGd,IAAIe,SAAS;;;;;IAC1D;;IAEA,WAAehB"}
|
package/dist/cjs/cli/types.d.cts
CHANGED
|
@@ -3,7 +3,9 @@ export interface Ctx {
|
|
|
3
3
|
name: string;
|
|
4
4
|
/** argv after the command word */
|
|
5
5
|
rest: string[];
|
|
6
|
-
/**
|
|
6
|
+
/** the CLI's fixed non-zero exit code, for result signals like audit loss */
|
|
7
|
+
readonly errorCode: number;
|
|
8
|
+
/** print the message and exit with the CLI's error code, on every malformed-invocation path.
|
|
7
9
|
* Readonly property (not method) syntax: TS only applies never-return control-flow analysis to readonly property-typed function members. */
|
|
8
10
|
readonly usageError: (message: string) => never;
|
|
9
11
|
}
|
package/dist/cjs/cli/types.d.ts
CHANGED
|
@@ -3,7 +3,9 @@ export interface Ctx {
|
|
|
3
3
|
name: string;
|
|
4
4
|
/** argv after the command word */
|
|
5
5
|
rest: string[];
|
|
6
|
-
/**
|
|
6
|
+
/** the CLI's fixed non-zero exit code, for result signals like audit loss */
|
|
7
|
+
readonly errorCode: number;
|
|
8
|
+
/** print the message and exit with the CLI's error code, on every malformed-invocation path.
|
|
7
9
|
* Readonly property (not method) syntax: TS only applies never-return control-flow analysis to readonly property-typed function members. */
|
|
8
10
|
readonly usageError: (message: string) => never;
|
|
9
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/formats/pdf-to-md/src/cli/types.ts"],"sourcesContent":["// Handed to every command; the command word is peeled off in src/cli.ts and\n// each command owns its own parseArgs table over `rest` (our commands' flags are disjoint, so a shared table would let `render --para-gap=2` parse silently as a no-op).\nexport interface Ctx {\n /** binary name, for usage strings */\n name: string;\n /** argv after the command word */\n rest: string[];\n /** print the message and exit
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/formats/pdf-to-md/src/cli/types.ts"],"sourcesContent":["// Handed to every command; the command word is peeled off in src/cli.ts and\n// each command owns its own parseArgs table over `rest` (our commands' flags are disjoint, so a shared table would let `render --para-gap=2` parse silently as a no-op).\nexport interface Ctx {\n /** binary name, for usage strings */\n name: string;\n /** argv after the command word */\n rest: string[];\n /** the CLI's fixed non-zero exit code, for result signals like audit loss */\n readonly errorCode: number;\n /** print the message and exit with the CLI's error code, on every malformed-invocation path.\n * Readonly property (not method) syntax: TS only applies never-return control-flow analysis to readonly property-typed function members. */\n readonly usageError: (message: string) => never;\n}\n\nexport type Command = (ctx: Ctx) => Promise<void> | void;\n"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,yKAAyK"}
|
package/dist/cjs/cli.d.cts
CHANGED
package/dist/cjs/cli.d.ts
CHANGED
package/dist/cjs/cli.js
CHANGED
|
@@ -4,33 +4,17 @@
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
_export(exports, {
|
|
14
|
-
get // Thrown errors -> exit 1 with the message verbatim; usage errors exit 2.
|
|
15
|
-
default () {
|
|
7
|
+
Object.defineProperty(exports, // All failures exit ERROR_CODE: usage errors with the usage text, thrown errors with the message verbatim.
|
|
8
|
+
"default", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function() {
|
|
16
11
|
return cli;
|
|
17
|
-
},
|
|
18
|
-
get isBelowNodeFloor () {
|
|
19
|
-
return isBelowNodeFloor;
|
|
20
12
|
}
|
|
21
13
|
});
|
|
22
14
|
var _nodefs = require("node:fs");
|
|
23
15
|
var _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path"));
|
|
24
16
|
var _nodeurl = require("node:url");
|
|
25
17
|
var _indexts = require("./cli/index.js");
|
|
26
|
-
function _array_like_to_array(arr, len) {
|
|
27
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
28
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
29
|
-
return arr2;
|
|
30
|
-
}
|
|
31
|
-
function _array_with_holes(arr) {
|
|
32
|
-
if (Array.isArray(arr)) return arr;
|
|
33
|
-
}
|
|
34
18
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
35
19
|
try {
|
|
36
20
|
var info = gen[key](arg);
|
|
@@ -62,36 +46,6 @@ function _interop_require_default(obj) {
|
|
|
62
46
|
default: obj
|
|
63
47
|
};
|
|
64
48
|
}
|
|
65
|
-
function _iterable_to_array_limit(arr, i) {
|
|
66
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
67
|
-
if (_i == null) return;
|
|
68
|
-
var _arr = [];
|
|
69
|
-
var _n = true;
|
|
70
|
-
var _d = false;
|
|
71
|
-
var _s, _e;
|
|
72
|
-
try {
|
|
73
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
74
|
-
_arr.push(_s.value);
|
|
75
|
-
if (i && _arr.length === i) break;
|
|
76
|
-
}
|
|
77
|
-
} catch (err) {
|
|
78
|
-
_d = true;
|
|
79
|
-
_e = err;
|
|
80
|
-
} finally{
|
|
81
|
-
try {
|
|
82
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
83
|
-
} finally{
|
|
84
|
-
if (_d) throw _e;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return _arr;
|
|
88
|
-
}
|
|
89
|
-
function _non_iterable_rest() {
|
|
90
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
91
|
-
}
|
|
92
|
-
function _sliced_to_array(arr, i) {
|
|
93
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
94
|
-
}
|
|
95
49
|
function _ts_generator(thisArg, body) {
|
|
96
50
|
var f, y, t, _ = {
|
|
97
51
|
label: 0,
|
|
@@ -191,17 +145,10 @@ function _ts_generator(thisArg, body) {
|
|
|
191
145
|
};
|
|
192
146
|
}
|
|
193
147
|
}
|
|
194
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
195
|
-
if (!o) return;
|
|
196
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
197
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
198
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
199
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
200
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
201
|
-
}
|
|
202
148
|
// __dirname (CJS) or its ESM equivalent, then two fixed hops up to the
|
|
203
149
|
// package root. NOT `import.meta.resolve('pdf-to-md/package.json')` — Node's self-reference lookup throws ERR_MODULE_NOT_FOUND from a file this deep; a location-relative path is stable across both build targets.
|
|
204
150
|
var __dirname = _nodepath.default.dirname(typeof __filename !== 'undefined' ? __filename : (0, _nodeurl.fileURLToPath)(require("url").pathToFileURL(__filename).toString()));
|
|
151
|
+
var ERROR_CODE = 19;
|
|
205
152
|
function packageVersion() {
|
|
206
153
|
try {
|
|
207
154
|
var _pkg_version;
|
|
@@ -212,43 +159,15 @@ function packageVersion() {
|
|
|
212
159
|
return 'unknown';
|
|
213
160
|
}
|
|
214
161
|
}
|
|
215
|
-
function isBelowNodeFloor(version, floor) {
|
|
216
|
-
var parts = function parts(v) {
|
|
217
|
-
return v.replace(/^v/, '').replace(/^>=/, '').split('.').map(Number);
|
|
218
|
-
};
|
|
219
|
-
var v = parts(version);
|
|
220
|
-
var f = parts(floor);
|
|
221
|
-
if (v.length !== 3 || f.length !== 3 || v.some(Number.isNaN) || f.some(Number.isNaN)) return null;
|
|
222
|
-
var _v = _sliced_to_array(v, 3), rMaj = _v[0], rMin = _v[1], rPat = _v[2];
|
|
223
|
-
var _f = _sliced_to_array(f, 3), fMaj = _f[0], fMin = _f[1], fPat = _f[2];
|
|
224
|
-
return rMaj !== fMaj ? rMaj < fMaj : rMin !== fMin ? rMin < fMin : rPat < fPat;
|
|
225
|
-
}
|
|
226
|
-
// Reads engines.node from package.json (kept as the single source of truth,
|
|
227
|
-
// not hardcoded here) and returns it iff process.version is below it.
|
|
228
|
-
function belowNodeFloor() {
|
|
229
|
-
var version = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : process.version;
|
|
230
|
-
try {
|
|
231
|
-
var _pkg_engines;
|
|
232
|
-
var pkgPath = _nodepath.default.resolve(__dirname, '..', '..', 'package.json');
|
|
233
|
-
var pkg = JSON.parse((0, _nodefs.readFileSync)(pkgPath, 'utf8'));
|
|
234
|
-
var floor = (_pkg_engines = pkg.engines) === null || _pkg_engines === void 0 ? void 0 : _pkg_engines.node;
|
|
235
|
-
if (!floor) return null;
|
|
236
|
-
return isBelowNodeFloor(version, floor) ? floor.replace(/^>=/, '') : null;
|
|
237
|
-
} catch (unused) {
|
|
238
|
-
return null;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
162
|
function usage(name) {
|
|
242
163
|
return "usage: ".concat(name, " <file.pdf> [out.md] [flags...] convert a PDF to markdown\n") + " ".concat(name, " extract <file.pdf> [out.md] [flags...] (same, explicit)\n") + " ".concat(name, " render <file.pdf> <page>[-<page>] [--dpi|-d N (default 288)] [--out|-o DIR (default .)]\n") + " ".concat(name, " audit <words.jsonl> <file.md> severity-1 word-loss check\n") + " ".concat(name, " --version | --help\n") + '\n' + 'extract flags:\n' + ' --ocr force the OCR path (image-only/scanned pages)\n' + ' --no-ocr never fall back to OCR; keep sparse text output\n' + ' --pages N[-M] convert only these 1-based source pages\n' + ' --stdout write markdown to stdout instead of a file\n' + ' --json print the full QA report as JSON\n' + ' --page-markers emit a "### pN" heading per page\n' + ' --format md|txt|raw output format (default md; raw = Analysis JSON incl. the\n' + ' report; txt = reading-order plain text)\n' + ' --words-json=FILE OCR path from a recognized-word dump (offline replay)\n' + ' --debug-words=FILE dump every recognized word as JSON lines to FILE\n' + ' --dpi=N OCR render resolution (default 288; raise for tiny print or\n' + ' chart/label pages, >~400 measured worse on ordinary prose)\n' + '\n' + "extract tuning (measured defaults; see README's tuning table):\n" + ' --float-max-words=N --float-max-width=F --float-margin=F --para-gap=F\n' + ' --heading-scale=F --col-max-width=F --col-split=F --line-y-tol=F\n' + ' --line-height-ratio=F\n' + '\n' + 'examples:\n' + " ".concat(name, " book.pdf # text layer -> book.md (auto-OCR if scanned)\n") + " ".concat(name, " scan.pdf out.md --ocr --json # force OCR, print the QA report\n") + " ".concat(name, " book.pdf --pages 27-31 --stdout # re-extract a page range to stdout\n") + " ".concat(name, " render book.pdf 27 # render p27 to PNG for eyeballing (288 dpi)\n") + " ".concat(name, " audit words.jsonl book.md # check no recognized word was lost");
|
|
243
164
|
}
|
|
244
165
|
function cli(argv, name) {
|
|
245
166
|
return _async_to_generator(function() {
|
|
246
|
-
var
|
|
167
|
+
var ctx, load, err;
|
|
247
168
|
return _ts_generator(this, function(_state) {
|
|
248
169
|
switch(_state.label){
|
|
249
170
|
case 0:
|
|
250
|
-
floor = belowNodeFloor();
|
|
251
|
-
if (floor) console.error("".concat(name, ": Node ").concat(process.version, " is below the required >=").concat(floor, " — the OCR path can silently find no words instead of erroring; upgrade Node."));
|
|
252
171
|
if (argv[0] === '--version' || argv[0] === '-v') {
|
|
253
172
|
console.log(packageVersion());
|
|
254
173
|
return [
|
|
@@ -260,7 +179,7 @@ function cli(argv, name) {
|
|
|
260
179
|
// for --help is not.
|
|
261
180
|
if (argv.length === 0) {
|
|
262
181
|
console.error(usage(name));
|
|
263
|
-
process.exit(
|
|
182
|
+
process.exit(ERROR_CODE);
|
|
264
183
|
}
|
|
265
184
|
console.log("".concat(name, " v").concat(packageVersion()));
|
|
266
185
|
console.log('');
|
|
@@ -274,8 +193,9 @@ function cli(argv, name) {
|
|
|
274
193
|
rest: argv.slice(1),
|
|
275
194
|
usageError: function usageError(message) {
|
|
276
195
|
console.error(message);
|
|
277
|
-
process.exit(
|
|
278
|
-
}
|
|
196
|
+
process.exit(ERROR_CODE);
|
|
197
|
+
},
|
|
198
|
+
errorCode: ERROR_CODE
|
|
279
199
|
};
|
|
280
200
|
_state.label = 1;
|
|
281
201
|
case 1:
|
|
@@ -329,7 +249,7 @@ function cli(argv, name) {
|
|
|
329
249
|
case 8:
|
|
330
250
|
err = _state.sent();
|
|
331
251
|
console.error(err.message);
|
|
332
|
-
process.exit(
|
|
252
|
+
process.exit(ERROR_CODE);
|
|
333
253
|
return [
|
|
334
254
|
3,
|
|
335
255
|
9
|
package/dist/cjs/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/formats/pdf-to-md/src/cli.ts"],"sourcesContent":["// Parsing and dispatch only. Commands live in src/cli/, one file each,\n// lazy-loaded — nothing tree- or dependency-heavy may be imported at the top of this file (`render` must never load the OCR engine, `--version` must load almost nothing).\nimport { readFileSync } from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { COMMANDS } from './cli/index.ts';\nimport type { Ctx } from './cli/types.ts';\n\n// __dirname (CJS) or its ESM equivalent, then two fixed hops up to the\n// package root. NOT `import.meta.resolve('pdf-to-md/package.json')` — Node's self-reference lookup throws ERR_MODULE_NOT_FOUND from a file this deep; a location-relative path is stable across both build targets.\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : fileURLToPath(import.meta.url));\n\nfunction packageVersion(): string {\n try {\n const pkgPath = path.resolve(__dirname, '..', '..', 'package.json');\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as { version?: string };\n return pkg.version ?? 'unknown';\n } catch {\n return 'unknown';\n }\n}\n\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/formats/pdf-to-md/src/cli.ts"],"sourcesContent":["// Parsing and dispatch only. Commands live in src/cli/, one file each,\n// lazy-loaded — nothing tree- or dependency-heavy may be imported at the top of this file (`render` must never load the OCR engine, `--version` must load almost nothing).\nimport { readFileSync } from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { COMMANDS } from './cli/index.ts';\nimport type { Ctx } from './cli/types.ts';\n\n// __dirname (CJS) or its ESM equivalent, then two fixed hops up to the\n// package root. NOT `import.meta.resolve('pdf-to-md/package.json')` — Node's self-reference lookup throws ERR_MODULE_NOT_FOUND from a file this deep; a location-relative path is stable across both build targets.\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : fileURLToPath(import.meta.url));\nconst ERROR_CODE = 19;\n\nfunction packageVersion(): string {\n try {\n const pkgPath = path.resolve(__dirname, '..', '..', 'package.json');\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as { version?: string };\n return pkg.version ?? 'unknown';\n } catch {\n return 'unknown';\n }\n}\n\nfunction usage(name: string): string {\n return (\n `usage: ${name} <file.pdf> [out.md] [flags...] convert a PDF to markdown\\n` +\n ` ${name} extract <file.pdf> [out.md] [flags...] (same, explicit)\\n` +\n ` ${name} render <file.pdf> <page>[-<page>] [--dpi|-d N (default 288)] [--out|-o DIR (default .)]\\n` +\n ` ${name} audit <words.jsonl> <file.md> severity-1 word-loss check\\n` +\n ` ${name} --version | --help\\n` +\n '\\n' +\n 'extract flags:\\n' +\n ' --ocr force the OCR path (image-only/scanned pages)\\n' +\n ' --no-ocr never fall back to OCR; keep sparse text output\\n' +\n ' --pages N[-M] convert only these 1-based source pages\\n' +\n ' --stdout write markdown to stdout instead of a file\\n' +\n ' --json print the full QA report as JSON\\n' +\n ` --page-markers emit a \"### pN\" heading per page\\n` +\n ' --format md|txt|raw output format (default md; raw = Analysis JSON incl. the\\n' +\n ' report; txt = reading-order plain text)\\n' +\n ' --words-json=FILE OCR path from a recognized-word dump (offline replay)\\n' +\n ' --debug-words=FILE dump every recognized word as JSON lines to FILE\\n' +\n ' --dpi=N OCR render resolution (default 288; raise for tiny print or\\n' +\n ' chart/label pages, >~400 measured worse on ordinary prose)\\n' +\n '\\n' +\n `extract tuning (measured defaults; see README's tuning table):\\n` +\n ' --float-max-words=N --float-max-width=F --float-margin=F --para-gap=F\\n' +\n ' --heading-scale=F --col-max-width=F --col-split=F --line-y-tol=F\\n' +\n ' --line-height-ratio=F\\n' +\n '\\n' +\n 'examples:\\n' +\n ` ${name} book.pdf # text layer -> book.md (auto-OCR if scanned)\\n` +\n ` ${name} scan.pdf out.md --ocr --json # force OCR, print the QA report\\n` +\n ` ${name} book.pdf --pages 27-31 --stdout # re-extract a page range to stdout\\n` +\n ` ${name} render book.pdf 27 # render p27 to PNG for eyeballing (288 dpi)\\n` +\n ` ${name} audit words.jsonl book.md # check no recognized word was lost`\n );\n}\n\n// All failures exit ERROR_CODE: usage errors with the usage text, thrown errors with the message verbatim.\nexport default async function cli(argv: string[], name: string): Promise<void> {\n if (argv[0] === '--version' || argv[0] === '-v') {\n console.log(packageVersion());\n return;\n }\n if (argv.length === 0 || argv[0] === '--help' || argv[0] === '-h') {\n // No args is a usage ERROR (bare `pdf-to-md` can't do anything); asking\n // for --help is not.\n if (argv.length === 0) {\n console.error(usage(name));\n process.exit(ERROR_CODE);\n }\n console.log(`${name} v${packageVersion()}`);\n console.log('');\n console.log(usage(name));\n return;\n }\n\n const ctx: Ctx = {\n name,\n rest: argv.slice(1),\n usageError(message) {\n console.error(message);\n process.exit(ERROR_CODE);\n },\n errorCode: ERROR_CODE,\n };\n\n try {\n const load = COMMANDS[argv[0]];\n if (load) {\n await (await load()).default(ctx);\n } else {\n // Compat shim: `pdf-to-md file.pdf [...]` — any first word that isn't\n // a reserved command is extract's own first argument.\n ctx.rest = argv;\n await (await COMMANDS.extract()).default(ctx);\n }\n } catch (err) {\n console.error((err as Error).message);\n process.exit(ERROR_CODE);\n }\n}\n"],"names":["cli","__dirname","path","dirname","__filename","fileURLToPath","ERROR_CODE","packageVersion","pkg","pkgPath","resolve","JSON","parse","readFileSync","version","usage","name","argv","ctx","load","err","console","log","length","error","process","exit","rest","slice","usageError","message","errorCode","COMMANDS","default","extract"],"mappings":"AAAA,uEAAuE;AACvE,2KAA2K;;;;;+BA0D3K,2GAA2G;AAC3G;;;eAA8BA;;;sBA1DD;+DACZ;uBACa;uBACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGzB,uEAAuE;AACvE,oNAAoN;AACpN,IAAMC,YAAYC,iBAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcA,aAAaC,IAAAA,sBAAa,EAAC;AAC9F,IAAMC,aAAa;AAEnB,SAASC;IACP,IAAI;YAGKC;QAFP,IAAMC,UAAUP,iBAAI,CAACQ,OAAO,CAACT,WAAW,MAAM,MAAM;QACpD,IAAMO,MAAMG,KAAKC,KAAK,CAACC,IAAAA,oBAAY,EAACJ,SAAS;QAC7C,QAAOD,eAAAA,IAAIM,OAAO,cAAXN,0BAAAA,eAAe;IACxB,EAAE,eAAM;QACN,OAAO;IACT;AACF;AAEA,SAASO,MAAMC,IAAY;IACzB,OACE,AAAC,UAAc,OAALA,MAAK,wEACf,AAAC,UAAc,OAALA,MAAK,gEACf,AAAC,UAAc,OAALA,MAAK,gGACf,AAAC,UAAc,OAALA,MAAK,0EACf,AAAC,UAAc,OAALA,MAAK,2BACf,OACA,qBACA,2EACA,6EACA,qEACA,wEACA,8DACA,8DACA,sFACA,qEACA,mFACA,8EACA,yFACA,wFACA,OACA,qEACA,8EACA,yEACA,8BACA,OACA,gBACA,AAAC,KAAS,OAALA,MAAK,sFACV,AAAC,KAAS,OAALA,MAAK,yEACV,AAAC,KAAS,OAALA,MAAK,4EACV,AAAC,KAAS,OAALA,MAAK,qFACV,AAAC,KAAS,OAALA,MAAK;AAEd;AAGe,SAAehB,IAAIiB,IAAc,EAAED,IAAY;;YAkBtDE,KAWEC,MASCC;;;;oBArCT,IAAIH,IAAI,CAAC,EAAE,KAAK,eAAeA,IAAI,CAAC,EAAE,KAAK,MAAM;wBAC/CI,QAAQC,GAAG,CAACf;wBACZ;;;oBACF;oBACA,IAAIU,KAAKM,MAAM,KAAK,KAAKN,IAAI,CAAC,EAAE,KAAK,YAAYA,IAAI,CAAC,EAAE,KAAK,MAAM;wBACjE,wEAAwE;wBACxE,qBAAqB;wBACrB,IAAIA,KAAKM,MAAM,KAAK,GAAG;4BACrBF,QAAQG,KAAK,CAACT,MAAMC;4BACpBS,QAAQC,IAAI,CAACpB;wBACf;wBACAe,QAAQC,GAAG,CAAC,AAAC,GAAWf,OAATS,MAAK,MAAqB,OAAjBT;wBACxBc,QAAQC,GAAG,CAAC;wBACZD,QAAQC,GAAG,CAACP,MAAMC;wBAClB;;;oBACF;oBAEME,MAAW;wBACfF,MAAAA;wBACAW,MAAMV,KAAKW,KAAK,CAAC;wBACjBC,YAAAA,SAAAA,WAAWC,OAAO;4BAChBT,QAAQG,KAAK,CAACM;4BACdL,QAAQC,IAAI,CAACpB;wBACf;wBACAyB,WAAWzB;oBACb;;;;;;;;;oBAGQa,OAAOa,iBAAQ,CAACf,IAAI,CAAC,EAAE,CAAC;yBAC1BE,MAAAA;;;;oBACK;;wBAAMA;;;oBAAb;;wBAAO,cAAcc,OAAO,CAACf;;;oBAA7B;;;;;;oBAEA,sEAAsE;oBACtE,sDAAsD;oBACtDA,IAAIS,IAAI,GAAGV;oBACJ;;wBAAMe,iBAAQ,CAACE,OAAO;;;oBAA7B;;wBAAO,cAA0BD,OAAO,CAACf;;;oBAAzC;;;;;;;;oBAEKE;oBACPC,QAAQG,KAAK,CAAC,AAACJ,IAAcU,OAAO;oBACpCL,QAAQC,IAAI,CAACpB;;;;;;;;;;;IAEjB"}
|
package/dist/esm/cli/audit.js
CHANGED
|
@@ -12,7 +12,7 @@ const audit = async (ctx)=>{
|
|
|
12
12
|
const result = auditWords(wordsPath, mdPath);
|
|
13
13
|
for (const line of result.lines)console.log(line);
|
|
14
14
|
// MISSING>0 is the severity-1 fail signal: a recognized word this markdown
|
|
15
|
-
// lost. Exit
|
|
16
|
-
if (result.missing > 0) process.exitCode =
|
|
15
|
+
// lost. Exit with the CLI's error code so the subcommand is usable as a CI gate; strict_deficits from hyphen-join repairs are reported but not failures.
|
|
16
|
+
if (result.missing > 0) process.exitCode = ctx.errorCode;
|
|
17
17
|
};
|
|
18
18
|
export default audit;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/formats/pdf-to-md/src/cli/audit.ts"],"sourcesContent":["// audit command — the severity-1 audit instrument (README's \"Design\n// contract\") as a first-class subcommand. Thin wrapper over src/audit.ts's auditWords (the library returns data, only the CLI prints and exits).\nimport { auditWords } from '../audit.ts';\nimport type { Command } from './types.ts';\n\nconst USAGE = 'usage: pdf-to-md audit <words.jsonl> <file.md>';\n\nconst audit: Command = async (ctx) => {\n if (ctx.rest.includes('-h') || ctx.rest.includes('--help')) {\n console.log(USAGE);\n return;\n }\n const [wordsPath, mdPath] = ctx.rest;\n if (!wordsPath || !mdPath) ctx.usageError(USAGE);\n\n const result = auditWords(wordsPath, mdPath);\n for (const line of result.lines) console.log(line);\n\n // MISSING>0 is the severity-1 fail signal: a recognized word this markdown\n // lost. Exit
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/formats/pdf-to-md/src/cli/audit.ts"],"sourcesContent":["// audit command — the severity-1 audit instrument (README's \"Design\n// contract\") as a first-class subcommand. Thin wrapper over src/audit.ts's auditWords (the library returns data, only the CLI prints and exits).\nimport { auditWords } from '../audit.ts';\nimport type { Command } from './types.ts';\n\nconst USAGE = 'usage: pdf-to-md audit <words.jsonl> <file.md>';\n\nconst audit: Command = async (ctx) => {\n if (ctx.rest.includes('-h') || ctx.rest.includes('--help')) {\n console.log(USAGE);\n return;\n }\n const [wordsPath, mdPath] = ctx.rest;\n if (!wordsPath || !mdPath) ctx.usageError(USAGE);\n\n const result = auditWords(wordsPath, mdPath);\n for (const line of result.lines) console.log(line);\n\n // MISSING>0 is the severity-1 fail signal: a recognized word this markdown\n // lost. Exit with the CLI's error code so the subcommand is usable as a CI gate; strict_deficits from hyphen-join repairs are reported but not failures.\n if (result.missing > 0) process.exitCode = ctx.errorCode;\n};\n\nexport default audit;\n"],"names":["auditWords","USAGE","audit","ctx","rest","includes","console","log","wordsPath","mdPath","usageError","result","line","lines","missing","process","exitCode","errorCode"],"mappings":"AAAA,oEAAoE;AACpE,iJAAiJ;AACjJ,SAASA,UAAU,QAAQ,cAAc;AAGzC,MAAMC,QAAQ;AAEd,MAAMC,QAAiB,OAAOC;IAC5B,IAAIA,IAAIC,IAAI,CAACC,QAAQ,CAAC,SAASF,IAAIC,IAAI,CAACC,QAAQ,CAAC,WAAW;QAC1DC,QAAQC,GAAG,CAACN;QACZ;IACF;IACA,MAAM,CAACO,WAAWC,OAAO,GAAGN,IAAIC,IAAI;IACpC,IAAI,CAACI,aAAa,CAACC,QAAQN,IAAIO,UAAU,CAACT;IAE1C,MAAMU,SAASX,WAAWQ,WAAWC;IACrC,KAAK,MAAMG,QAAQD,OAAOE,KAAK,CAAEP,QAAQC,GAAG,CAACK;IAE7C,2EAA2E;IAC3E,yJAAyJ;IACzJ,IAAID,OAAOG,OAAO,GAAG,GAAGC,QAAQC,QAAQ,GAAGb,IAAIc,SAAS;AAC1D;AAEA,eAAef,MAAM"}
|
package/dist/esm/cli/types.d.ts
CHANGED
|
@@ -3,7 +3,9 @@ export interface Ctx {
|
|
|
3
3
|
name: string;
|
|
4
4
|
/** argv after the command word */
|
|
5
5
|
rest: string[];
|
|
6
|
-
/**
|
|
6
|
+
/** the CLI's fixed non-zero exit code, for result signals like audit loss */
|
|
7
|
+
readonly errorCode: number;
|
|
8
|
+
/** print the message and exit with the CLI's error code, on every malformed-invocation path.
|
|
7
9
|
* Readonly property (not method) syntax: TS only applies never-return control-flow analysis to readonly property-typed function members. */
|
|
8
10
|
readonly usageError: (message: string) => never;
|
|
9
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/formats/pdf-to-md/src/cli/types.ts"],"sourcesContent":["// Handed to every command; the command word is peeled off in src/cli.ts and\n// each command owns its own parseArgs table over `rest` (our commands' flags are disjoint, so a shared table would let `render --para-gap=2` parse silently as a no-op).\nexport interface Ctx {\n /** binary name, for usage strings */\n name: string;\n /** argv after the command word */\n rest: string[];\n /** print the message and exit
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/formats/pdf-to-md/src/cli/types.ts"],"sourcesContent":["// Handed to every command; the command word is peeled off in src/cli.ts and\n// each command owns its own parseArgs table over `rest` (our commands' flags are disjoint, so a shared table would let `render --para-gap=2` parse silently as a no-op).\nexport interface Ctx {\n /** binary name, for usage strings */\n name: string;\n /** argv after the command word */\n rest: string[];\n /** the CLI's fixed non-zero exit code, for result signals like audit loss */\n readonly errorCode: number;\n /** print the message and exit with the CLI's error code, on every malformed-invocation path.\n * Readonly property (not method) syntax: TS only applies never-return control-flow analysis to readonly property-typed function members. */\n readonly usageError: (message: string) => never;\n}\n\nexport type Command = (ctx: Ctx) => Promise<void> | void;\n"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,yKAAyK;AAazK,WAAyD"}
|
package/dist/esm/cli.d.ts
CHANGED
package/dist/esm/cli.js
CHANGED
|
@@ -7,6 +7,7 @@ import { COMMANDS } from './cli/index.js';
|
|
|
7
7
|
// __dirname (CJS) or its ESM equivalent, then two fixed hops up to the
|
|
8
8
|
// package root. NOT `import.meta.resolve('pdf-to-md/package.json')` — Node's self-reference lookup throws ERR_MODULE_NOT_FOUND from a file this deep; a location-relative path is stable across both build targets.
|
|
9
9
|
const __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : fileURLToPath(import.meta.url));
|
|
10
|
+
const ERROR_CODE = 19;
|
|
10
11
|
function packageVersion() {
|
|
11
12
|
try {
|
|
12
13
|
var _pkg_version;
|
|
@@ -17,38 +18,11 @@ function packageVersion() {
|
|
|
17
18
|
return 'unknown';
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
|
-
// Exported so the comparison is unit-testable without spawning a subprocess
|
|
21
|
-
// with a faked Node version. null means unparseable input, not "not below".
|
|
22
|
-
export function isBelowNodeFloor(version, floor) {
|
|
23
|
-
const parts = (v)=>v.replace(/^v/, '').replace(/^>=/, '').split('.').map(Number);
|
|
24
|
-
const v = parts(version);
|
|
25
|
-
const f = parts(floor);
|
|
26
|
-
if (v.length !== 3 || f.length !== 3 || v.some(Number.isNaN) || f.some(Number.isNaN)) return null;
|
|
27
|
-
const [rMaj, rMin, rPat] = v;
|
|
28
|
-
const [fMaj, fMin, fPat] = f;
|
|
29
|
-
return rMaj !== fMaj ? rMaj < fMaj : rMin !== fMin ? rMin < fMin : rPat < fPat;
|
|
30
|
-
}
|
|
31
|
-
// Reads engines.node from package.json (kept as the single source of truth,
|
|
32
|
-
// not hardcoded here) and returns it iff process.version is below it.
|
|
33
|
-
function belowNodeFloor(version = process.version) {
|
|
34
|
-
try {
|
|
35
|
-
var _pkg_engines;
|
|
36
|
-
const pkgPath = path.resolve(__dirname, '..', '..', 'package.json');
|
|
37
|
-
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
|
|
38
|
-
const floor = (_pkg_engines = pkg.engines) === null || _pkg_engines === void 0 ? void 0 : _pkg_engines.node;
|
|
39
|
-
if (!floor) return null;
|
|
40
|
-
return isBelowNodeFloor(version, floor) ? floor.replace(/^>=/, '') : null;
|
|
41
|
-
} catch {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
21
|
function usage(name) {
|
|
46
22
|
return `usage: ${name} <file.pdf> [out.md] [flags...] convert a PDF to markdown\n` + ` ${name} extract <file.pdf> [out.md] [flags...] (same, explicit)\n` + ` ${name} render <file.pdf> <page>[-<page>] [--dpi|-d N (default 288)] [--out|-o DIR (default .)]\n` + ` ${name} audit <words.jsonl> <file.md> severity-1 word-loss check\n` + ` ${name} --version | --help\n` + '\n' + 'extract flags:\n' + ' --ocr force the OCR path (image-only/scanned pages)\n' + ' --no-ocr never fall back to OCR; keep sparse text output\n' + ' --pages N[-M] convert only these 1-based source pages\n' + ' --stdout write markdown to stdout instead of a file\n' + ' --json print the full QA report as JSON\n' + ` --page-markers emit a "### pN" heading per page\n` + ' --format md|txt|raw output format (default md; raw = Analysis JSON incl. the\n' + ' report; txt = reading-order plain text)\n' + ' --words-json=FILE OCR path from a recognized-word dump (offline replay)\n' + ' --debug-words=FILE dump every recognized word as JSON lines to FILE\n' + ' --dpi=N OCR render resolution (default 288; raise for tiny print or\n' + ' chart/label pages, >~400 measured worse on ordinary prose)\n' + '\n' + `extract tuning (measured defaults; see README's tuning table):\n` + ' --float-max-words=N --float-max-width=F --float-margin=F --para-gap=F\n' + ' --heading-scale=F --col-max-width=F --col-split=F --line-y-tol=F\n' + ' --line-height-ratio=F\n' + '\n' + 'examples:\n' + ` ${name} book.pdf # text layer -> book.md (auto-OCR if scanned)\n` + ` ${name} scan.pdf out.md --ocr --json # force OCR, print the QA report\n` + ` ${name} book.pdf --pages 27-31 --stdout # re-extract a page range to stdout\n` + ` ${name} render book.pdf 27 # render p27 to PNG for eyeballing (288 dpi)\n` + ` ${name} audit words.jsonl book.md # check no recognized word was lost`;
|
|
47
23
|
}
|
|
48
|
-
//
|
|
24
|
+
// All failures exit ERROR_CODE: usage errors with the usage text, thrown errors with the message verbatim.
|
|
49
25
|
export default async function cli(argv, name) {
|
|
50
|
-
const floor = belowNodeFloor();
|
|
51
|
-
if (floor) console.error(`${name}: Node ${process.version} is below the required >=${floor} — the OCR path can silently find no words instead of erroring; upgrade Node.`);
|
|
52
26
|
if (argv[0] === '--version' || argv[0] === '-v') {
|
|
53
27
|
console.log(packageVersion());
|
|
54
28
|
return;
|
|
@@ -58,7 +32,7 @@ export default async function cli(argv, name) {
|
|
|
58
32
|
// for --help is not.
|
|
59
33
|
if (argv.length === 0) {
|
|
60
34
|
console.error(usage(name));
|
|
61
|
-
process.exit(
|
|
35
|
+
process.exit(ERROR_CODE);
|
|
62
36
|
}
|
|
63
37
|
console.log(`${name} v${packageVersion()}`);
|
|
64
38
|
console.log('');
|
|
@@ -70,8 +44,9 @@ export default async function cli(argv, name) {
|
|
|
70
44
|
rest: argv.slice(1),
|
|
71
45
|
usageError (message) {
|
|
72
46
|
console.error(message);
|
|
73
|
-
process.exit(
|
|
74
|
-
}
|
|
47
|
+
process.exit(ERROR_CODE);
|
|
48
|
+
},
|
|
49
|
+
errorCode: ERROR_CODE
|
|
75
50
|
};
|
|
76
51
|
try {
|
|
77
52
|
const load = COMMANDS[argv[0]];
|
|
@@ -85,6 +60,6 @@ export default async function cli(argv, name) {
|
|
|
85
60
|
}
|
|
86
61
|
} catch (err) {
|
|
87
62
|
console.error(err.message);
|
|
88
|
-
process.exit(
|
|
63
|
+
process.exit(ERROR_CODE);
|
|
89
64
|
}
|
|
90
65
|
}
|
package/dist/esm/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/formats/pdf-to-md/src/cli.ts"],"sourcesContent":["// Parsing and dispatch only. Commands live in src/cli/, one file each,\n// lazy-loaded — nothing tree- or dependency-heavy may be imported at the top of this file (`render` must never load the OCR engine, `--version` must load almost nothing).\nimport { readFileSync } from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { COMMANDS } from './cli/index.ts';\nimport type { Ctx } from './cli/types.ts';\n\n// __dirname (CJS) or its ESM equivalent, then two fixed hops up to the\n// package root. NOT `import.meta.resolve('pdf-to-md/package.json')` — Node's self-reference lookup throws ERR_MODULE_NOT_FOUND from a file this deep; a location-relative path is stable across both build targets.\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : fileURLToPath(import.meta.url));\n\nfunction packageVersion(): string {\n try {\n const pkgPath = path.resolve(__dirname, '..', '..', 'package.json');\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as { version?: string };\n return pkg.version ?? 'unknown';\n } catch {\n return 'unknown';\n }\n}\n\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/formats/pdf-to-md/src/cli.ts"],"sourcesContent":["// Parsing and dispatch only. Commands live in src/cli/, one file each,\n// lazy-loaded — nothing tree- or dependency-heavy may be imported at the top of this file (`render` must never load the OCR engine, `--version` must load almost nothing).\nimport { readFileSync } from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { COMMANDS } from './cli/index.ts';\nimport type { Ctx } from './cli/types.ts';\n\n// __dirname (CJS) or its ESM equivalent, then two fixed hops up to the\n// package root. NOT `import.meta.resolve('pdf-to-md/package.json')` — Node's self-reference lookup throws ERR_MODULE_NOT_FOUND from a file this deep; a location-relative path is stable across both build targets.\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : fileURLToPath(import.meta.url));\nconst ERROR_CODE = 19;\n\nfunction packageVersion(): string {\n try {\n const pkgPath = path.resolve(__dirname, '..', '..', 'package.json');\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as { version?: string };\n return pkg.version ?? 'unknown';\n } catch {\n return 'unknown';\n }\n}\n\nfunction usage(name: string): string {\n return (\n `usage: ${name} <file.pdf> [out.md] [flags...] convert a PDF to markdown\\n` +\n ` ${name} extract <file.pdf> [out.md] [flags...] (same, explicit)\\n` +\n ` ${name} render <file.pdf> <page>[-<page>] [--dpi|-d N (default 288)] [--out|-o DIR (default .)]\\n` +\n ` ${name} audit <words.jsonl> <file.md> severity-1 word-loss check\\n` +\n ` ${name} --version | --help\\n` +\n '\\n' +\n 'extract flags:\\n' +\n ' --ocr force the OCR path (image-only/scanned pages)\\n' +\n ' --no-ocr never fall back to OCR; keep sparse text output\\n' +\n ' --pages N[-M] convert only these 1-based source pages\\n' +\n ' --stdout write markdown to stdout instead of a file\\n' +\n ' --json print the full QA report as JSON\\n' +\n ` --page-markers emit a \"### pN\" heading per page\\n` +\n ' --format md|txt|raw output format (default md; raw = Analysis JSON incl. the\\n' +\n ' report; txt = reading-order plain text)\\n' +\n ' --words-json=FILE OCR path from a recognized-word dump (offline replay)\\n' +\n ' --debug-words=FILE dump every recognized word as JSON lines to FILE\\n' +\n ' --dpi=N OCR render resolution (default 288; raise for tiny print or\\n' +\n ' chart/label pages, >~400 measured worse on ordinary prose)\\n' +\n '\\n' +\n `extract tuning (measured defaults; see README's tuning table):\\n` +\n ' --float-max-words=N --float-max-width=F --float-margin=F --para-gap=F\\n' +\n ' --heading-scale=F --col-max-width=F --col-split=F --line-y-tol=F\\n' +\n ' --line-height-ratio=F\\n' +\n '\\n' +\n 'examples:\\n' +\n ` ${name} book.pdf # text layer -> book.md (auto-OCR if scanned)\\n` +\n ` ${name} scan.pdf out.md --ocr --json # force OCR, print the QA report\\n` +\n ` ${name} book.pdf --pages 27-31 --stdout # re-extract a page range to stdout\\n` +\n ` ${name} render book.pdf 27 # render p27 to PNG for eyeballing (288 dpi)\\n` +\n ` ${name} audit words.jsonl book.md # check no recognized word was lost`\n );\n}\n\n// All failures exit ERROR_CODE: usage errors with the usage text, thrown errors with the message verbatim.\nexport default async function cli(argv: string[], name: string): Promise<void> {\n if (argv[0] === '--version' || argv[0] === '-v') {\n console.log(packageVersion());\n return;\n }\n if (argv.length === 0 || argv[0] === '--help' || argv[0] === '-h') {\n // No args is a usage ERROR (bare `pdf-to-md` can't do anything); asking\n // for --help is not.\n if (argv.length === 0) {\n console.error(usage(name));\n process.exit(ERROR_CODE);\n }\n console.log(`${name} v${packageVersion()}`);\n console.log('');\n console.log(usage(name));\n return;\n }\n\n const ctx: Ctx = {\n name,\n rest: argv.slice(1),\n usageError(message) {\n console.error(message);\n process.exit(ERROR_CODE);\n },\n errorCode: ERROR_CODE,\n };\n\n try {\n const load = COMMANDS[argv[0]];\n if (load) {\n await (await load()).default(ctx);\n } else {\n // Compat shim: `pdf-to-md file.pdf [...]` — any first word that isn't\n // a reserved command is extract's own first argument.\n ctx.rest = argv;\n await (await COMMANDS.extract()).default(ctx);\n }\n } catch (err) {\n console.error((err as Error).message);\n process.exit(ERROR_CODE);\n }\n}\n"],"names":["readFileSync","path","fileURLToPath","COMMANDS","__dirname","dirname","__filename","url","ERROR_CODE","packageVersion","pkg","pkgPath","resolve","JSON","parse","version","usage","name","cli","argv","console","log","length","error","process","exit","ctx","rest","slice","usageError","message","errorCode","load","default","extract","err"],"mappings":"AAAA,uEAAuE;AACvE,2KAA2K;AAC3K,SAASA,YAAY,QAAQ,UAAU;AACvC,OAAOC,UAAU,YAAY;AAC7B,SAASC,aAAa,QAAQ,WAAW;AACzC,SAASC,QAAQ,QAAQ,iBAAiB;AAG1C,uEAAuE;AACvE,oNAAoN;AACpN,MAAMC,YAAYH,KAAKI,OAAO,CAAC,OAAOC,eAAe,cAAcA,aAAaJ,cAAc,YAAYK,GAAG;AAC7G,MAAMC,aAAa;AAEnB,SAASC;IACP,IAAI;YAGKC;QAFP,MAAMC,UAAUV,KAAKW,OAAO,CAACR,WAAW,MAAM,MAAM;QACpD,MAAMM,MAAMG,KAAKC,KAAK,CAACd,aAAaW,SAAS;QAC7C,QAAOD,eAAAA,IAAIK,OAAO,cAAXL,0BAAAA,eAAe;IACxB,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAEA,SAASM,MAAMC,IAAY;IACzB,OACE,CAAC,OAAO,EAAEA,KAAK,kEAAkE,CAAC,GAClF,CAAC,OAAO,EAAEA,KAAK,0DAA0D,CAAC,GAC1E,CAAC,OAAO,EAAEA,KAAK,0FAA0F,CAAC,GAC1G,CAAC,OAAO,EAAEA,KAAK,oEAAoE,CAAC,GACpF,CAAC,OAAO,EAAEA,KAAK,qBAAqB,CAAC,GACrC,OACA,qBACA,2EACA,6EACA,qEACA,wEACA,8DACA,CAAC,yDAAyD,CAAC,GAC3D,sFACA,qEACA,mFACA,8EACA,yFACA,wFACA,OACA,CAAC,gEAAgE,CAAC,GAClE,8EACA,yEACA,8BACA,OACA,gBACA,CAAC,EAAE,EAAEA,KAAK,gFAAgF,CAAC,GAC3F,CAAC,EAAE,EAAEA,KAAK,mEAAmE,CAAC,GAC9E,CAAC,EAAE,EAAEA,KAAK,sEAAsE,CAAC,GACjF,CAAC,EAAE,EAAEA,KAAK,+EAA+E,CAAC,GAC1F,CAAC,EAAE,EAAEA,KAAK,oEAAoE,CAAC;AAEnF;AAEA,2GAA2G;AAC3G,eAAe,eAAeC,IAAIC,IAAc,EAAEF,IAAY;IAC5D,IAAIE,IAAI,CAAC,EAAE,KAAK,eAAeA,IAAI,CAAC,EAAE,KAAK,MAAM;QAC/CC,QAAQC,GAAG,CAACZ;QACZ;IACF;IACA,IAAIU,KAAKG,MAAM,KAAK,KAAKH,IAAI,CAAC,EAAE,KAAK,YAAYA,IAAI,CAAC,EAAE,KAAK,MAAM;QACjE,wEAAwE;QACxE,qBAAqB;QACrB,IAAIA,KAAKG,MAAM,KAAK,GAAG;YACrBF,QAAQG,KAAK,CAACP,MAAMC;YACpBO,QAAQC,IAAI,CAACjB;QACf;QACAY,QAAQC,GAAG,CAAC,GAAGJ,KAAK,EAAE,EAAER,kBAAkB;QAC1CW,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAACL,MAAMC;QAClB;IACF;IAEA,MAAMS,MAAW;QACfT;QACAU,MAAMR,KAAKS,KAAK,CAAC;QACjBC,YAAWC,OAAO;YAChBV,QAAQG,KAAK,CAACO;YACdN,QAAQC,IAAI,CAACjB;QACf;QACAuB,WAAWvB;IACb;IAEA,IAAI;QACF,MAAMwB,OAAO7B,QAAQ,CAACgB,IAAI,CAAC,EAAE,CAAC;QAC9B,IAAIa,MAAM;YACR,MAAM,AAAC,CAAA,MAAMA,MAAK,EAAGC,OAAO,CAACP;QAC/B,OAAO;YACL,sEAAsE;YACtE,sDAAsD;YACtDA,IAAIC,IAAI,GAAGR;YACX,MAAM,AAAC,CAAA,MAAMhB,SAAS+B,OAAO,EAAC,EAAGD,OAAO,CAACP;QAC3C;IACF,EAAE,OAAOS,KAAK;QACZf,QAAQG,KAAK,CAAC,AAACY,IAAcL,OAAO;QACpCN,QAAQC,IAAI,CAACjB;IACf;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effortlessmotion/pdf-to-md",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Extract PDFs to structured markdown: text layer via pdf.js, OCR fallback for image-only pages, pure npm and cross-platform",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pdf",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"@types/mocha": "^10.0.10",
|
|
55
55
|
"@types/node": "^26.2.0",
|
|
56
56
|
"cr": "^0.1.0",
|
|
57
|
+
"fs-remove-compat": "^1.0.4",
|
|
57
58
|
"node-version-use": "^2.5.0",
|
|
58
59
|
"pdf-lib": "^1.17.1",
|
|
59
60
|
"ts-dev-stack": "^1.22.3",
|