bindery-cli 0.46.1__tar.gz → 0.47.0__tar.gz
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.
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/CLAUDE.md +19 -4
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/PKG-INFO +8 -3
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/README.md +7 -2
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/patchnotes.md +67 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/pyproject.toml +1 -1
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/roadmap.md +1 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/spec.md +54 -7
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/src/bindery/__init__.py +1 -1
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/src/bindery/audit.py +37 -2
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/src/bindery/cli.py +46 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/src/bindery/epub.py +130 -10
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/src/bindery/transforms.py +246 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/tests/test_audit.py +97 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/tests/test_epub.py +50 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/tests/test_flags_real_core.py +76 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/tests/test_flags_wiring.py +5 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/tests/test_transforms.py +234 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/tests/test_version.py +35 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/uv.lock +2 -2
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/.github/FUNDING.yml +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/.github/workflows/ci.yml +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/.github/workflows/publish.yml +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/.gitignore +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/AGENTS.md +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/LICENSE +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/docs/screenshots/library-sweep.png +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/logo.svg +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/plugin/__init__.py +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/project.done +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/run_tests.sh +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/scripts/FastSweep.java +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/scripts/build_plugin.py +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/scripts/fast_sweep.py +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/src/bindery/__main__.py +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/src/bindery/library.py +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/src/bindery/pagination.py +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/src/bindery/reserialize.py +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/src/bindery/validate.py +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/src/bindery/watermark.py +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/tests/test_cli.py +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/tests/test_comment_hyphens.py +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/tests/test_cover_tocdrift.py +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/tests/test_library.py +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/tests/test_matcher_hardening.py +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/tests/test_pagination.py +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/tests/test_plugin.py +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/tests/test_reserialize.py +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/tests/test_space_renames.py +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/tests/test_validate.py +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/tests/test_watermark.py +0 -0
- {bindery_cli-0.46.1 → bindery_cli-0.47.0}/tests/test_xml_hardening.py +0 -0
|
@@ -30,15 +30,27 @@ Born from the 2026 library audit (see the user memory `calibre-library-epubcheck
|
|
|
30
30
|
`xmlns`, bare `&`, named entities, void self-closing), the NCX pipeline, and the
|
|
31
31
|
mimetype fix (added/normalized/first-stored, epub.py's archive rewrite); every core
|
|
32
32
|
fix must render identically to the author's intent: never add, remove, or reorder
|
|
33
|
-
visible content. The canonical opt-in inventory lives in spec.md:
|
|
33
|
+
visible content. The canonical opt-in inventory lives in spec.md: twenty-one structural
|
|
34
34
|
repairs, four lossy strips, four safe opt-ins, plus `--reserialize`.
|
|
35
35
|
* **Structural repairs** (`--fix-empty-body`, `--fix-missing-title`, `--fix-id-colons`,
|
|
36
36
|
`--fix-page-map`, `--strip-epub3-attrs`, `--downgrade-epub3-tags`,
|
|
37
37
|
`--unwrap-block-in-inline`, `--strip-invalid-value`, `--unwrap-illegal-tags`,
|
|
38
38
|
`--prune-missing-resources`, `--strip-broken-anchors`, `--encode-url-spaces`,
|
|
39
39
|
`--fix-container`, `--fix-media-types`, `--fix-cover`,
|
|
40
|
-
`--fix-comment-double-hyphen
|
|
41
|
-
|
|
40
|
+
`--fix-comment-double-hyphen`, `--fix-svg-dup-ids`, `--fix-cdata-terminator`,
|
|
41
|
+
`--fix-misnested-inline`, `--fix-stray-close`, `--fix-unterminated-attr`;
|
|
42
|
+
transforms.py, threaded through epub.py). The v0.47.0 five (the 2026-10-06
|
|
43
|
+
issue batch): `--fix-svg-dup-ids` renames duplicate glyph ids inside
|
|
44
|
+
standalone `.svg` entries (first keeps its name, references resolve to the
|
|
45
|
+
first definition so they are never rewritten); `--fix-cdata-terminator`
|
|
46
|
+
completes a truncated `/*]]>` CDATA-terminator comment inside inline
|
|
47
|
+
`<style>` blocks (CSS-008); `--fix-misnested-inline` normalizes the
|
|
48
|
+
Mobipocket drop-cap mis-nest `<i><b>X</i></b>` (punctuation between the
|
|
49
|
+
reversed closers survives outside both spans; a letter run is refused);
|
|
50
|
+
`--fix-stray-close` removes an end tag with no open start frame (a merely
|
|
51
|
+
mis-nested pair is never touched); `--fix-unterminated-attr` closes an
|
|
52
|
+
attribute value open to the tag's own `>` (bare-word values, no quote
|
|
53
|
+
before the next `<`); all normal `gate`. `--fix-comment-double-hyphen` (v0.46.0, the RSC-016 fatal)
|
|
42
54
|
replaces `--` inside XML comments with an en-dash: comment bodies only (text
|
|
43
55
|
nodes and CDATA never touched, the one deliberate exception to the
|
|
44
56
|
never-rewrite-comments invariant), in content documents, the NCX, and the OPF
|
|
@@ -71,7 +83,10 @@ Born from the 2026 library audit (see the user memory `calibre-library-epubcheck
|
|
|
71
83
|
in `RepairReport.watermark_refusals`, and surfaced as a `manual_watermark_repair`
|
|
72
84
|
decision by `run phase1` on both the read-only and apply paths. `--strip-stub-docs`
|
|
73
85
|
(2026-09-15) mirrors emptytext's placeholder signals: identical short text across
|
|
74
|
-
>= 3 spine docs and >= 30% of the spine; the
|
|
86
|
+
>= 3 spine docs and >= 30% of the spine; since v0.47.0 the pool is the `<body>`
|
|
87
|
+
span and image-carrier pages (empty body text, an `<img>` present) are exempt, so
|
|
88
|
+
identical head `<title>`s can never weld illustrated divider pages into a fake
|
|
89
|
+
stub class (the Great Change misfire); the whole-spine-stubs book is refused
|
|
75
90
|
(EMPTY, re-source), and the drop cascades to archive entries, manifest, spine,
|
|
76
91
|
NCX navPoints, and nav toc entries.
|
|
77
92
|
Do not let any NEW fix touch content without its own flag; if a candidate repair cannot
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: bindery-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.47.0
|
|
4
4
|
Summary: Audit EPUB body text and repair broken EPUBs with deterministic, epubcheck-gated fixes; atomic in-place replacement in a Calibre library.
|
|
5
5
|
Project-URL: Homepage, https://github.com/VirInvictus/bindery-cli
|
|
6
6
|
Project-URL: Repository, https://github.com/VirInvictus/bindery-cli
|
|
@@ -51,7 +51,7 @@ bindery-cli makes accidentally broken markup well-formed again. It does not rewr
|
|
|
51
51
|
|
|
52
52
|
Everything below is off until its flag is passed (or all at once via `--all`). They go further than well-formedness (altering structure or adding minimal content), so they never run by default:
|
|
53
53
|
|
|
54
|
-
- **`--fix-ids`**: rewrite ids that are not valid XML names (start with a digit, contain a colon) in the OPF manifest, updating every reference to them (spine, fallback, media-overlay, the EPUB 2 cover meta), and in the NCX (where old conversions stamp navPoint ids from UUIDs). Touches the OPF, so it is off by default; the dc: metadata is never altered.
|
|
54
|
+
- **`--fix-ids`**: rewrite ids that are not valid XML names (start with a digit, contain a colon, or carry any character outside the XML NameChar set, like the apostrophes calibre copies from filenames) in the OPF manifest, updating every reference to them (spine, fallback, media-overlay, the EPUB 2 cover meta), and in the NCX (where old conversions stamp navPoint ids from UUIDs). Touches the OPF, so it is off by default; the dc: metadata is never altered.
|
|
55
55
|
- **`--add-img-alt`**: add `alt=""` to `<img>` elements missing the required attribute. Renders identically, but it adds markup the author never wrote, and an empty alt tells a screen reader the image is decorative; hence opt-in.
|
|
56
56
|
- **`--reserialize`**: rebuild content documents that are still malformed by re-parsing them with html5lib and re-emitting XHTML, closing unclosed `<p>`/`<div>`/`<span>`/`<blockquote>` that the regex transforms cannot. Runs only on documents that are not already well-formed, so good files are untouched.
|
|
57
57
|
- **`--strip-bad-attrs`**: drop attributes that are invalid XML (a name starting with a digit, or a namespaced name whose prefix is never declared, like Office VML `v:shapes`). Surgical and a no-op on well-formed files.
|
|
@@ -72,6 +72,11 @@ Everything below is off until its flag is passed (or all at once via `--all`). T
|
|
|
72
72
|
- **`--fix-media-types`**: normalizes wrong manifest media-type declarations (OPF-029, e.g. a jpg stamped `image/png` by an aggregator). Attribute-only and quote-preserving; it fires only when the file's magic bytes confirm the extension, so a misnamed-but-consistent file (a PNG renamed .jpg) is never made worse.
|
|
73
73
|
- **`--fix-cover`**: repairs dangling EPUB2 cover wiring. A `<meta name="cover">` whose content names no manifest item is re-pointed when the OPF guide's own cover reference names an existing item, and removed when nothing identifies it; EPUB3 `properties="cover-image"` is deliberately audit-only (guessing which image is the cover is not deterministic). Cover wiring is invisible to epubcheck, so cover-only repairs are accepted under the same no-worse bar the lossy strips use.
|
|
74
74
|
- **`--fix-comment-double-hyphen`**: replaces `--` sequences inside XML comments with en-dashes. `--` is illegal inside an XML comment (epubcheck fatal RSC-016: the book opens in lenient readers but never passes epubcheck). The edit stays inside the comment bodies: text nodes and CDATA sections are never touched, and each comment's terminator is left intact.
|
|
75
|
+
- **`--fix-svg-dup-ids`**: renames duplicate `id` values inside standalone `.svg` entries (old calibre SVG page renders repeat glyph ids within one document; the intake wave that found this carried 445 to 1,339 'Duplicate "glNNNN"' errors per book). The first occurrence keeps its name, later ones gain `_2`/`_3`, and internal references are deliberately untouched: they already resolve to the first definition under every reader's first-match lookup.
|
|
76
|
+
- **`--fix-cdata-terminator`**: completes a truncated CDATA-terminator comment in an inline `<style>` block (`/*]]>` becomes `/*]]>*/`). A comment-wrapped CDATA block whose closing `*/` the converter dropped leaves the CSS parser inside an unterminated comment: one CSS-008 'Premature end of file' per affected document. Only the malformed-terminator token class is rewritten; invalid CSS stays unfixed, and stylesheet files are not touched.
|
|
77
|
+
- **`--fix-misnested-inline`**: rewrites the Mobipocket drop-cap mis-nest `<i><b>X</i></b>` to `<i><b>X</b></i>` (em/strong variants and either tag order). Only the both-open-then-reversed-close shape is touched; a punctuation run caught between the reversed closers (`<i><b>xile</i>,</b>`) survives outside both spans, and a letter run there is refused (which span keeps the letters has no deterministic answer).
|
|
78
|
+
- **`--fix-stray-close`**: removes an end tag whose element has no open start tag anywhere above it (the stray extra `</div>` on a shell page, which cascades into 'body must be terminated by the matching end-tag'). Merely mis-nested pairs are never touched: a close is removed only when nothing by that name is open.
|
|
79
|
+
- **`--fix-unterminated-attr`**: closes an attribute value left open to the tag's own `>` (`<p class="footnote>` becomes `<p class="footnote">`). The parser swallows prose into the value until the next quote and dies on the first `<` it meets. Guards keep it off legal `>`-bearing values: bare-word values only, and no quote may close before the next `<`.
|
|
75
80
|
|
|
76
81
|
|
|
77
82
|
Four opt-in fixes are **lossy** and stand apart from the semantics-preserving rest:
|
|
@@ -79,7 +84,7 @@ Four opt-in fixes are **lossy** and stand apart from the semantics-preserving re
|
|
|
79
84
|
- **`--strip-pagination`**: remove print page numbers and running headers that a PDF/OCR conversion baked into the body text as literal paragraphs (so they reflow into the middle of a sentence: "where the hay cart **16** was taking him"). It removes only that injected furniture, never the author's prose: where a number split a sentence it rejoins the two paragraphs (closing up a word split like `compli-` / `mentary`), and it preserves roman chapter numbers, page-list nav anchors, and years. A roman numeral counts as a page number only when it is well-formed and under 100, so ordinary words (`mid`, `mix`, `civil`) are never mistaken for pages. A book is only treated as paginated when it has both a dense run of arabic numbers and several confident mid-sentence interrupts, so a merely chapter-numbered book is left alone. Three safety nets guard every edit (character conservation, tag balance, and an epubcheck no-regression check); any failure leaves the document untouched.
|
|
80
85
|
- **`--strip-broken-tags`**: remove leaked HTML closing tags missing their open brackets (e.g. `</p>`) that render as raw text.
|
|
81
86
|
- **`--strip-watermarks`**: remove known producer and distributor watermarks (e.g. OceanofPDF, ABC Amber LIT Converter) and stray marker files. It locates the stamp and deletes the outermost wrapper whose entire visible text is the watermark, ensuring prose that merely mentions the URL is preserved. An inline stamp link is deleted only when it holds nothing but the stamp; a match too large to be safe (an unclosed stamp anchor that swallowed prose) is refused and reported for manual repair rather than deleted.
|
|
82
|
-
- **`--strip-stub-docs`**: drop spine documents whose entire visible text is one identical short placeholder repeated across the spine: the Bookmate-style export whose chapters are all the same "content unavailable" notice, passing epubcheck because the placeholder is valid XHTML. The drop cascades (archive entries, manifest items, spine order, NCX navPoints, nav toc entries), so the book opens straight into its real chapters. The identity rule is deliberately conservative (same text, at least 3 docs, at least 30% of the spine, each doc short but not blank) and a book whose *every* spine doc is the stub is refused outright: that book is empty and needs a re-source, never a repair.
|
|
87
|
+
- **`--strip-stub-docs`**: drop spine documents whose entire visible body text is one identical short placeholder repeated across the spine: the Bookmate-style export whose chapters are all the same "content unavailable" notice, passing epubcheck because the placeholder is valid XHTML. The drop cascades (archive entries, manifest items, spine order, NCX navPoints, nav toc entries), so the book opens straight into its real chapters. The identity rule is deliberately conservative (same body text, at least 3 docs, at least 30% of the spine, each doc short but not blank; the pool is the `<body>` span, and image-carrier pages with no body text are exempt, so illustrated part-divider pages are never candidates) and a book whose *every* spine doc is the stub is refused outright: that book is empty and needs a re-source, never a repair.
|
|
83
88
|
|
|
84
89
|
All lossy edits are invisible to epubcheck, so they are accepted when the result is *no worse* rather than measurably better.
|
|
85
90
|
|
|
@@ -24,7 +24,7 @@ bindery-cli makes accidentally broken markup well-formed again. It does not rewr
|
|
|
24
24
|
|
|
25
25
|
Everything below is off until its flag is passed (or all at once via `--all`). They go further than well-formedness (altering structure or adding minimal content), so they never run by default:
|
|
26
26
|
|
|
27
|
-
- **`--fix-ids`**: rewrite ids that are not valid XML names (start with a digit, contain a colon) in the OPF manifest, updating every reference to them (spine, fallback, media-overlay, the EPUB 2 cover meta), and in the NCX (where old conversions stamp navPoint ids from UUIDs). Touches the OPF, so it is off by default; the dc: metadata is never altered.
|
|
27
|
+
- **`--fix-ids`**: rewrite ids that are not valid XML names (start with a digit, contain a colon, or carry any character outside the XML NameChar set, like the apostrophes calibre copies from filenames) in the OPF manifest, updating every reference to them (spine, fallback, media-overlay, the EPUB 2 cover meta), and in the NCX (where old conversions stamp navPoint ids from UUIDs). Touches the OPF, so it is off by default; the dc: metadata is never altered.
|
|
28
28
|
- **`--add-img-alt`**: add `alt=""` to `<img>` elements missing the required attribute. Renders identically, but it adds markup the author never wrote, and an empty alt tells a screen reader the image is decorative; hence opt-in.
|
|
29
29
|
- **`--reserialize`**: rebuild content documents that are still malformed by re-parsing them with html5lib and re-emitting XHTML, closing unclosed `<p>`/`<div>`/`<span>`/`<blockquote>` that the regex transforms cannot. Runs only on documents that are not already well-formed, so good files are untouched.
|
|
30
30
|
- **`--strip-bad-attrs`**: drop attributes that are invalid XML (a name starting with a digit, or a namespaced name whose prefix is never declared, like Office VML `v:shapes`). Surgical and a no-op on well-formed files.
|
|
@@ -45,6 +45,11 @@ Everything below is off until its flag is passed (or all at once via `--all`). T
|
|
|
45
45
|
- **`--fix-media-types`**: normalizes wrong manifest media-type declarations (OPF-029, e.g. a jpg stamped `image/png` by an aggregator). Attribute-only and quote-preserving; it fires only when the file's magic bytes confirm the extension, so a misnamed-but-consistent file (a PNG renamed .jpg) is never made worse.
|
|
46
46
|
- **`--fix-cover`**: repairs dangling EPUB2 cover wiring. A `<meta name="cover">` whose content names no manifest item is re-pointed when the OPF guide's own cover reference names an existing item, and removed when nothing identifies it; EPUB3 `properties="cover-image"` is deliberately audit-only (guessing which image is the cover is not deterministic). Cover wiring is invisible to epubcheck, so cover-only repairs are accepted under the same no-worse bar the lossy strips use.
|
|
47
47
|
- **`--fix-comment-double-hyphen`**: replaces `--` sequences inside XML comments with en-dashes. `--` is illegal inside an XML comment (epubcheck fatal RSC-016: the book opens in lenient readers but never passes epubcheck). The edit stays inside the comment bodies: text nodes and CDATA sections are never touched, and each comment's terminator is left intact.
|
|
48
|
+
- **`--fix-svg-dup-ids`**: renames duplicate `id` values inside standalone `.svg` entries (old calibre SVG page renders repeat glyph ids within one document; the intake wave that found this carried 445 to 1,339 'Duplicate "glNNNN"' errors per book). The first occurrence keeps its name, later ones gain `_2`/`_3`, and internal references are deliberately untouched: they already resolve to the first definition under every reader's first-match lookup.
|
|
49
|
+
- **`--fix-cdata-terminator`**: completes a truncated CDATA-terminator comment in an inline `<style>` block (`/*]]>` becomes `/*]]>*/`). A comment-wrapped CDATA block whose closing `*/` the converter dropped leaves the CSS parser inside an unterminated comment: one CSS-008 'Premature end of file' per affected document. Only the malformed-terminator token class is rewritten; invalid CSS stays unfixed, and stylesheet files are not touched.
|
|
50
|
+
- **`--fix-misnested-inline`**: rewrites the Mobipocket drop-cap mis-nest `<i><b>X</i></b>` to `<i><b>X</b></i>` (em/strong variants and either tag order). Only the both-open-then-reversed-close shape is touched; a punctuation run caught between the reversed closers (`<i><b>xile</i>,</b>`) survives outside both spans, and a letter run there is refused (which span keeps the letters has no deterministic answer).
|
|
51
|
+
- **`--fix-stray-close`**: removes an end tag whose element has no open start tag anywhere above it (the stray extra `</div>` on a shell page, which cascades into 'body must be terminated by the matching end-tag'). Merely mis-nested pairs are never touched: a close is removed only when nothing by that name is open.
|
|
52
|
+
- **`--fix-unterminated-attr`**: closes an attribute value left open to the tag's own `>` (`<p class="footnote>` becomes `<p class="footnote">`). The parser swallows prose into the value until the next quote and dies on the first `<` it meets. Guards keep it off legal `>`-bearing values: bare-word values only, and no quote may close before the next `<`.
|
|
48
53
|
|
|
49
54
|
|
|
50
55
|
Four opt-in fixes are **lossy** and stand apart from the semantics-preserving rest:
|
|
@@ -52,7 +57,7 @@ Four opt-in fixes are **lossy** and stand apart from the semantics-preserving re
|
|
|
52
57
|
- **`--strip-pagination`**: remove print page numbers and running headers that a PDF/OCR conversion baked into the body text as literal paragraphs (so they reflow into the middle of a sentence: "where the hay cart **16** was taking him"). It removes only that injected furniture, never the author's prose: where a number split a sentence it rejoins the two paragraphs (closing up a word split like `compli-` / `mentary`), and it preserves roman chapter numbers, page-list nav anchors, and years. A roman numeral counts as a page number only when it is well-formed and under 100, so ordinary words (`mid`, `mix`, `civil`) are never mistaken for pages. A book is only treated as paginated when it has both a dense run of arabic numbers and several confident mid-sentence interrupts, so a merely chapter-numbered book is left alone. Three safety nets guard every edit (character conservation, tag balance, and an epubcheck no-regression check); any failure leaves the document untouched.
|
|
53
58
|
- **`--strip-broken-tags`**: remove leaked HTML closing tags missing their open brackets (e.g. `</p>`) that render as raw text.
|
|
54
59
|
- **`--strip-watermarks`**: remove known producer and distributor watermarks (e.g. OceanofPDF, ABC Amber LIT Converter) and stray marker files. It locates the stamp and deletes the outermost wrapper whose entire visible text is the watermark, ensuring prose that merely mentions the URL is preserved. An inline stamp link is deleted only when it holds nothing but the stamp; a match too large to be safe (an unclosed stamp anchor that swallowed prose) is refused and reported for manual repair rather than deleted.
|
|
55
|
-
- **`--strip-stub-docs`**: drop spine documents whose entire visible text is one identical short placeholder repeated across the spine: the Bookmate-style export whose chapters are all the same "content unavailable" notice, passing epubcheck because the placeholder is valid XHTML. The drop cascades (archive entries, manifest items, spine order, NCX navPoints, nav toc entries), so the book opens straight into its real chapters. The identity rule is deliberately conservative (same text, at least 3 docs, at least 30% of the spine, each doc short but not blank) and a book whose *every* spine doc is the stub is refused outright: that book is empty and needs a re-source, never a repair.
|
|
60
|
+
- **`--strip-stub-docs`**: drop spine documents whose entire visible body text is one identical short placeholder repeated across the spine: the Bookmate-style export whose chapters are all the same "content unavailable" notice, passing epubcheck because the placeholder is valid XHTML. The drop cascades (archive entries, manifest items, spine order, NCX navPoints, nav toc entries), so the book opens straight into its real chapters. The identity rule is deliberately conservative (same body text, at least 3 docs, at least 30% of the spine, each doc short but not blank; the pool is the `<body>` span, and image-carrier pages with no body text are exempt, so illustrated part-divider pages are never candidates) and a book whose *every* spine doc is the stub is refused outright: that book is empty and needs a re-source, never a repair.
|
|
56
61
|
|
|
57
62
|
All lossy edits are invisible to epubcheck, so they are accepted when the result is *no worse* rather than measurably better.
|
|
58
63
|
|
|
@@ -1,4 +1,71 @@
|
|
|
1
1
|
# bindery-cli Patch Notes
|
|
2
|
+
|
|
3
|
+
## v0.47.0 (2026-10-06)
|
|
4
|
+
|
|
5
|
+
### The intake-wave batch: five repair surfaces from five open issues
|
|
6
|
+
|
|
7
|
+
The 2026-10-05/06 acquisition wave filed five issues against real books; all
|
|
8
|
+
five land here. Two are classifier and validity corrections to existing
|
|
9
|
+
surfaces, three are new opt-in structural repairs, and each was verified
|
|
10
|
+
epubcheck-gated against its own fixture before shipping.
|
|
11
|
+
|
|
12
|
+
* The stub classifier pools BODY text and exempts image carriers (issue #1).
|
|
13
|
+
The four Kobo part-divider pages of the Great Change carry only a
|
|
14
|
+
full-bleed `<img>` each, and their identical head `<title>` welded them,
|
|
15
|
+
with the title page, into a fake five-doc stub class: emptytext answered
|
|
16
|
+
PARTIAL and `--strip-stub-docs` offered a strip that deleted real
|
|
17
|
+
illustrations (the apply-time gate caught the deletion, but the offer was
|
|
18
|
+
wrong). Both the analyzer and the repair twin now pool the `<body>` span,
|
|
19
|
+
and a doc with no body text that carries an image is furniture, never a
|
|
20
|
+
candidate; identical titles alone are never a stub class.
|
|
21
|
+
* `--fix-ids` sees every invalid character, not just colons and digit leads
|
|
22
|
+
(issue #3). The Lisey's Story OPF carries ids like
|
|
23
|
+
`Stephen_King_-_Lisey's_story22` (apostrophes copied from filenames),
|
|
24
|
+
which passed the original empty/colon/leading-char NCName check
|
|
25
|
+
wholesale, so a full `--all` sweep left the RSC-005 id errors standing
|
|
26
|
+
(epubcheck's message says "without colons"; the defect was never colons).
|
|
27
|
+
The check now enforces the XML NameChar set at every position, and the
|
|
28
|
+
rename sanitizes every invalid character to `_`, references in sync as
|
|
29
|
+
before. Fixture: 22 ids renamed, the OPF id error class cleared; the
|
|
30
|
+
errors that remain on that book are unrelated classes (deprecated body
|
|
31
|
+
attributes, stray GeoXML elements).
|
|
32
|
+
* `--fix-svg-dup-ids` (issue #2): old calibre 0.8.x SVG page renders repeat
|
|
33
|
+
glyph ids within one document. The first occurrence keeps its name, later
|
|
34
|
+
ones gain `_2`/`_3`, and references are deliberately untouched: they
|
|
35
|
+
resolve to the first definition under every reader's first-match lookup,
|
|
36
|
+
so first-keeps-id preserves exactly what rendered. Standalone `.svg`
|
|
37
|
+
entries only; content-document ids are styled and anchor-targeted and
|
|
38
|
+
stay out of scope. Fixture: 346 ids rewritten, 80 aggregated errors to
|
|
39
|
+
zero.
|
|
40
|
+
* `--fix-cdata-terminator` (issue #4): completes the truncated `/*]]>`
|
|
41
|
+
CDATA-terminator comment inside inline `<style>` blocks (the 2002-era
|
|
42
|
+
conversion lineage whose 19 content docs each died with CSS-008
|
|
43
|
+
"Premature end of file"; the aggregated gate saw one message). Only the
|
|
44
|
+
malformed-terminator token class: invalid CSS stays unfixed, stylesheet
|
|
45
|
+
files are not touched, and an intact closer (even space-separated) is
|
|
46
|
+
left alone.
|
|
47
|
+
* The markup-fatal trio (issue #5): `--fix-misnested-inline` normalizes the
|
|
48
|
+
Mobipocket drop-cap mis-nest `<i><b>X</i></b>` (em/strong variants and
|
|
49
|
+
either order; punctuation between the reversed closers survives outside
|
|
50
|
+
both spans; a letter run is refused as ambiguous),
|
|
51
|
+
`--fix-stray-close` removes an end tag whose element has no open start
|
|
52
|
+
frame (a merely mis-nested pair is never touched; script/style text is
|
|
53
|
+
skipped to its end tag and an unclosed comment stops the walk), and
|
|
54
|
+
`--fix-unterminated-attr` closes an
|
|
55
|
+
attribute value open to the tag's own `>` (`<p class="footnote>`;
|
|
56
|
+
bare-word values only, and only when no quote closes before the next
|
|
57
|
+
`<`). Life (Keith Richards): 3 fatals to zero, gate-accepted with the
|
|
58
|
+
unterminated-attr repair running before the tag-shape readers an open
|
|
59
|
+
value would otherwise lie to.
|
|
60
|
+
|
|
61
|
+
Tests: 615 (up from 575), including a real-core row per new flag, the
|
|
62
|
+
wiring-table pins for the five new dests, classifier regressions for both
|
|
63
|
+
sides of the stub fix, and a version-sync pin for uv.lock's root entry
|
|
64
|
+
(the pre-release audit found v0.46.1 shipped with the lock one patch
|
|
65
|
+
stale, a class the pyproject pin cannot see). The plugin ships the default pass only; it
|
|
66
|
+
vendors the changed modules byte-identically and CI byte-compiles it under
|
|
67
|
+
3.11 through 3.14.
|
|
68
|
+
|
|
2
69
|
## v0.46.1 (2026-10-02)
|
|
3
70
|
|
|
4
71
|
### The closing sweep: documentation truth after the 0.46 line
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "bindery-cli"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.47.0"
|
|
8
8
|
description = "Audit EPUB body text and repair broken EPUBs with deterministic, epubcheck-gated fixes; atomic in-place replacement in a Calibre library."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
classifiers = [
|
|
@@ -40,6 +40,7 @@ The plugin vendors the core and never gates (the epubcheck latency ruling).
|
|
|
40
40
|
| Waves 15 + blitz | The plugin PEP-758 HIGH + the 3.11-3.14 interpreter matrix, analyzer robustness, the per-matcher census (possessive bounding; cited by tests/test_matcher_hardening.py), stdlib XML hardening, FastDaemon v2 (reconcile-not-retire), `--strip-stub-docs`, `bindery doctor` + `repair --json`, `--encode-url-spaces` entry renames, the cover + tocdrift analyzers, the privacy/GitHub/docs/comment/hygiene batches, requires-python 3.12 with markers, the em-dash sweep | v0.40.0-v0.44.0 |
|
|
41
41
|
| 0.45 | Structured fix records (`fixes`, `ncx_uid_synced`, `watermark_refusals`) in every JSON payload; CalibreQuarry consumes them with the 0.45.0 floor | v0.45.0 |
|
|
42
42
|
| 0.46 | RSC-016 `--fix-comment-double-hyphen` (the last open repair class) and the RepairFlags dataclass | v0.46.0 |
|
|
43
|
+
| 0.47 | The intake-wave batch (five open issues): the stub classifier's body-pool + image-carrier exemption, the NCName-complete `--fix-ids`, and `--fix-svg-dup-ids`, `--fix-cdata-terminator`, `--fix-misnested-inline`, `--fix-stray-close`, `--fix-unterminated-attr` | v0.47.0 |
|
|
43
44
|
|
|
44
45
|
## Open work
|
|
45
46
|
|
|
@@ -13,13 +13,14 @@ restyle, re-compress, or restructure content, and it does not attempt to fix arb
|
|
|
13
13
|
schema (RSC-005) violations, which are usually harmless to readers and not safely
|
|
14
14
|
mechanizable.
|
|
15
15
|
|
|
16
|
-
The deliberate exceptions to "semantics-preserving" come in opt-in groups. The
|
|
16
|
+
The deliberate exceptions to "semantics-preserving" come in opt-in groups. The twenty-one
|
|
17
17
|
**structural repairs** (`--fix-empty-body`, `--fix-missing-title`, `--fix-id-colons`,
|
|
18
18
|
`--fix-page-map`, `--strip-epub3-attrs`, `--downgrade-epub3-tags`,
|
|
19
19
|
`--unwrap-block-in-inline`, `--strip-invalid-value`, `--unwrap-illegal-tags`,
|
|
20
20
|
`--prune-missing-resources`, `--strip-broken-anchors`, `--encode-url-spaces`,
|
|
21
|
-
`--fix-container`, `--fix-media-types`, `--fix-cover`,
|
|
22
|
-
`--fix-
|
|
21
|
+
`--fix-container`, `--fix-media-types`, `--fix-cover`, `--fix-comment-double-hyphen`,
|
|
22
|
+
`--fix-svg-dup-ids`, `--fix-cdata-terminator`, `--fix-misnested-inline`,
|
|
23
|
+
`--fix-stray-close`, `--fix-unterminated-attr`) alter
|
|
23
24
|
markup structure or fabricate minimal content; the four
|
|
24
25
|
**lossy modes** (`--strip-pagination`, `--strip-broken-tags`, `--strip-watermarks`,
|
|
25
26
|
`--strip-stub-docs`) remove
|
|
@@ -124,7 +125,7 @@ byte-for-byte. The normal gate applies.
|
|
|
124
125
|
|
|
125
126
|
### Opt-in: structural repairs
|
|
126
127
|
|
|
127
|
-
|
|
128
|
+
Twenty-one repairs go past well-formedness and therefore require their own flag; none is ever
|
|
128
129
|
part of the default pipeline:
|
|
129
130
|
|
|
130
131
|
- **`--fix-empty-body`**: ` ` inside a strictly empty `<body></body>` ("body
|
|
@@ -233,8 +234,54 @@ use, with the `partial` rule intact.
|
|
|
233
234
|
never touched, and each comment's `-->` terminator stays intact. An unclosed comment is a
|
|
234
235
|
different fatal class and is left alone. It applies to content documents, the NCX, and
|
|
235
236
|
the OPF alike, and every replaced sequence is counted.
|
|
236
|
-
|
|
237
|
-
|
|
237
|
+
- **`--fix-svg-dup-ids`**: rename duplicate `id` values inside standalone `.svg`
|
|
238
|
+
entries (old calibre 0.8.x SVG page renders repeat glyph ids within one document;
|
|
239
|
+
four books from one intake wave carried 445 to 1,339 'Duplicate "glNNNN"' RSC-005s
|
|
240
|
+
each). The first occurrence keeps its name; every later one gains `_2`, `_3`, ... in
|
|
241
|
+
document order (prefixed with `_` until the name is free). Internal
|
|
242
|
+
`xlink:href="#x"` / `url(#x)` references are deliberately never rewritten: they
|
|
243
|
+
already resolve to the first definition under every reader's first-match lookup, so
|
|
244
|
+
first-keeps-id preserves exactly what rendered. Scope is standalone `.svg` entries
|
|
245
|
+
only: content-document ids are styled by CSS selectors and targeted by anchors, and
|
|
246
|
+
renaming those needs a reference graph this repair does not build.
|
|
247
|
+
- **`--fix-cdata-terminator`**: complete a truncated CDATA-terminator comment in an
|
|
248
|
+
inline `<style>` block: `/*]]>` becomes `/*]]>*/` (a comment-wrapped CDATA block
|
|
249
|
+
whose closing `*/` the converter dropped; epubcheck's CSS parser reads the dangling
|
|
250
|
+
`/*` as an unterminated comment and answers CSS-008 'Premature end of file' once per
|
|
251
|
+
affected document, 19 identical errors on the 2002-era fixture). Deliberately narrow:
|
|
252
|
+
only the malformed-terminator token class, inside `<style>` blocks only; invalid CSS
|
|
253
|
+
properties and selectors stay unfixed (renderers degrade gracefully), stylesheet FILE
|
|
254
|
+
entries are not touched, and a closer that already sits intact (possibly after
|
|
255
|
+
whitespace) is left alone.
|
|
256
|
+
- **`--fix-misnested-inline`**: rewrite the Mobipocket drop-cap mis-nest
|
|
257
|
+
`<i><b>X</i></b>` to `<i><b>X</b></i>` (em/strong variants and either tag order
|
|
258
|
+
included). Only the both-open-then-reversed-close shape is rewritten: any match is
|
|
259
|
+
XML fatal, and swapping the closers is the unique well-formed form carrying the same
|
|
260
|
+
two spans over the same text. The Exile variant, where a short punctuation run sits
|
|
261
|
+
between the reversed closers (`<i><b>xile</i>,</b>`), is covered: the punctuation
|
|
262
|
+
survives outside both spans, byte-preserved. A letter run between the closers
|
|
263
|
+
(`<i><b>S</i>ome</b>`, where `<b>` spans `Some` and `<i>` only `S`) is refused: which
|
|
264
|
+
span keeps the letters has no deterministic answer. Same-tag pairs, attribute-bearing
|
|
265
|
+
starts, and markup crossing the run are untouched.
|
|
266
|
+
- **`--fix-stray-close`**: remove an end tag whose element has no open start tag
|
|
267
|
+
anywhere above it (the stray extra `</div>` on a shell page, which cascades into
|
|
268
|
+
'body must be terminated by the matching end-tag'). The rule is deliberately narrower
|
|
269
|
+
than a nesting repair: a close is removed only when NOTHING by that name is open, so
|
|
270
|
+
a merely mis-nested pair (`<div><span></div></span>`) is left exactly as written
|
|
271
|
+
(its `</span>` still has an open frame and is never misread as stray). Self-closed
|
|
272
|
+
and void starts open no frame; raw-text elements (`script`, `style`) are skipped to
|
|
273
|
+
their end tag so JS/CSS text is never read as markup; the walk stops at an unclosed
|
|
274
|
+
comment or CDATA opener, where the parser stops reading markup too.
|
|
275
|
+
- **`--fix-unterminated-attr`**: close an attribute value left open to the tag's own
|
|
276
|
+
`>` (`<p class="footnote>` -> `<p class="footnote">`; the parser swallows prose into
|
|
277
|
+
the value until the next quote, meets a `<`, and dies with the RSC-016 fatal "the
|
|
278
|
+
value of attribute ... must not contain the '<' character"). Three guards keep it off
|
|
279
|
+
legal `>`-bearing values: the value is one bare word, the `>` must be followed by no
|
|
280
|
+
quote before the next `<` (a real multi-line value closes quote-first), and only
|
|
281
|
+
double-quoted values are judged. It runs before the other tag-shape readers, which an
|
|
282
|
+
open value otherwise lies to.
|
|
283
|
+
|
|
284
|
+
Nineteen of the twenty-one are evaluated by the normal `gate`: unlike the lossy strips,
|
|
238
285
|
their benefit is visible to epubcheck (they clear errors), so a run with no measurable
|
|
239
286
|
improvement is a noop and nothing is applied. The two exceptions are `--fix-cover` and
|
|
240
287
|
`--encode-url-spaces`, whose gains sit on axes epubcheck does not measure (cover
|
|
@@ -267,7 +314,7 @@ Since this removes visible text from the reading experience, it is lossy by desi
|
|
|
267
314
|
Strips known producer and redistributor watermarks out of EPUBs (e.g. OceanofPDF.com, ABC Amber LIT Converter). The removal is a balanced-element surgery rather than regex slicing: it locates the stamp and deletes the outermost wrapper whose *entire visible text* is the watermark, ensuring prose that merely mentions the URL is preserved. Also drops known zero-byte marker files. Like other lossy operations, this is verified via `no_worse`.
|
|
268
315
|
|
|
269
316
|
### Opt-in, lossy: stub-document strip (`--strip-stub-docs`)
|
|
270
|
-
Drops spine documents whose entire visible text is one identical short placeholder repeated across the spine: the Bookmate/DRM-sample export whose chapters are all the same "content unavailable" notice, valid XHTML that epubcheck passes. The identity rule mirrors the emptytext analyzer's placeholder signals and is deliberately conservative: a candidate doc's visible text is 12-600 characters (short, not blank) and IDENTICAL to the text of at least two other spine docs, and the class covers at least 30% of the spine; only the single most common repeated class qualifies.
|
|
317
|
+
Drops spine documents whose entire visible BODY text is one identical short placeholder repeated across the spine: the Bookmate/DRM-sample export whose chapters are all the same "content unavailable" notice, valid XHTML that epubcheck passes. The identity rule mirrors the emptytext analyzer's placeholder signals and is deliberately conservative: a candidate doc's visible body text is 12-600 characters (short, not blank) and IDENTICAL to the text of at least two other spine docs, and the class covers at least 30% of the spine; only the single most common repeated class qualifies. The pool is the `<body>` span, not the whole document (whole document when a doc has none; a converter stamps the same head `<title>` on every shell page, which used to weld unrelated docs into a fake stub class), and an image-carrier page (empty body text, an `<img>`/`<image>` present) is exempt outright: those are illustrated part-divider pages, furniture the strip must never delete (the Great Change misfire, 2026-10-05).
|
|
271
318
|
|
|
272
319
|
The drop cascades fully: the placeholder archive entries, their manifest items and spine itemrefs (with every package edge rewritten), their NCX navPoints (the always-on playOrder resequencing heals the sequence afterward), and their nav toc `<li>` entries. Refusals, each reported as a no-op: no repeated class, the class under the fraction bar, and the class covering the whole spine (a book whose every spine doc is the same stub is EMPTY; it needs a re-source, never a repair). Accepted under the `no_worse` bar with the partial rule intact.
|
|
273
320
|
|
|
@@ -11,7 +11,7 @@ Calibre plugin built from this core.
|
|
|
11
11
|
Single source of truth for the version. pyproject.toml must match VERSION below.
|
|
12
12
|
"""
|
|
13
13
|
|
|
14
|
-
VERSION = "0.
|
|
14
|
+
VERSION = "0.47.0"
|
|
15
15
|
__version__ = VERSION
|
|
16
16
|
|
|
17
17
|
from .epub import RepairReport, repair_epub # noqa: E402
|
|
@@ -1224,6 +1224,28 @@ def _visible_chars(html: str) -> int:
|
|
|
1224
1224
|
return len(_visible_text(html))
|
|
1225
1225
|
|
|
1226
1226
|
|
|
1227
|
+
# Stub identity pools BODY text (the image-carrier fix, 2026-10-06): a
|
|
1228
|
+
# converter stamps the same head <title> on every shell page, so
|
|
1229
|
+
# whole-document text welded unrelated docs into a fake stub class (the Great
|
|
1230
|
+
# Change divider-page misfire, issue #1). An image-carrier rule (empty body
|
|
1231
|
+
# text, an <img>/<image> present) marks divider pages: furniture, never
|
|
1232
|
+
# stubs. Mirrored by epub._stub_body_text / epub._stub_is_image_carrier.
|
|
1233
|
+
_BODY_SPAN_RE = re.compile(r"<body\b[^>]*>(.*)</body>", re.IGNORECASE | re.DOTALL)
|
|
1234
|
+
_IMAGE_CARRIER_RE = re.compile(r"<(?:img|image)\b", re.IGNORECASE)
|
|
1235
|
+
|
|
1236
|
+
|
|
1237
|
+
def _body_visible_text(html: str) -> str:
|
|
1238
|
+
"""Visible text of the <body> span (whole document when there is none)."""
|
|
1239
|
+
m = _BODY_SPAN_RE.search(html)
|
|
1240
|
+
return _visible_text(m.group(1)) if m else _visible_text(html)
|
|
1241
|
+
|
|
1242
|
+
|
|
1243
|
+
def _is_image_carrier(html: str, body_text: str) -> bool:
|
|
1244
|
+
"""True for a doc with no body text that carries an image element: a
|
|
1245
|
+
divider page (furniture), never a stub."""
|
|
1246
|
+
return body_text == "" and bool(_IMAGE_CARRIER_RE.search(html))
|
|
1247
|
+
|
|
1248
|
+
|
|
1227
1249
|
def analyze_emptytext(book: Book) -> dict:
|
|
1228
1250
|
"""Count visible text across the (pre-read) spine and gather triage signals."""
|
|
1229
1251
|
texts = book.visible_texts()
|
|
@@ -1235,10 +1257,23 @@ def analyze_emptytext(book: Book) -> dict:
|
|
|
1235
1257
|
# short stub repeated across a large fraction of the spine (most chapters
|
|
1236
1258
|
# replaced by an identical "content unavailable" notice). Blank docs are
|
|
1237
1259
|
# excluded by PLACEHOLDER_STUB_MIN so well-made books full of small section
|
|
1238
|
-
# dividers (each with distinct text) do not trip it.
|
|
1260
|
+
# dividers (each with distinct text) do not trip it. The pool is the BODY
|
|
1261
|
+
# text, and image-carrier pages are excluded outright: the four Kobo
|
|
1262
|
+
# divider pages of the Great Change carry only a full-bleed <img>, and
|
|
1263
|
+
# their identical head <title> used to be the "stub" every one of them
|
|
1264
|
+
# matched (offering a --strip-stub-docs that deleted real illustrations).
|
|
1239
1265
|
sig = any(_PLACEHOLDER_SIG.search(t) for t in texts)
|
|
1266
|
+
body_texts = []
|
|
1267
|
+
carriers = []
|
|
1268
|
+
for d in book.spine:
|
|
1269
|
+
doc_html = book.docs.get(d, "")
|
|
1270
|
+
body = _body_visible_text(doc_html)
|
|
1271
|
+
body_texts.append(body)
|
|
1272
|
+
carriers.append(_is_image_carrier(doc_html, body))
|
|
1240
1273
|
stubs = Counter(
|
|
1241
|
-
t
|
|
1274
|
+
t
|
|
1275
|
+
for t, carrier in zip(body_texts, carriers, strict=True)
|
|
1276
|
+
if not carrier and PLACEHOLDER_STUB_MIN <= len(t) <= PLACEHOLDER_STUB_MAX
|
|
1242
1277
|
)
|
|
1243
1278
|
stub_n = stubs.most_common(1)[0][1] if stubs else 0
|
|
1244
1279
|
spine_n = max(1, len(book.spine))
|
|
@@ -96,6 +96,11 @@ def _flags_from_args(args: argparse.Namespace) -> RepairFlags:
|
|
|
96
96
|
fix_media_types=args.fix_media_types or all_,
|
|
97
97
|
fix_cover=args.fix_cover or all_,
|
|
98
98
|
comment_double_hyphens=args.fix_comment_double_hyphen or all_,
|
|
99
|
+
svg_dup_ids=args.fix_svg_dup_ids or all_,
|
|
100
|
+
cdata_terminator=args.fix_cdata_terminator or all_,
|
|
101
|
+
misnested_inline=args.fix_misnested_inline or all_,
|
|
102
|
+
stray_close=args.fix_stray_close or all_,
|
|
103
|
+
unterminated_attr=args.fix_unterminated_attr or all_,
|
|
99
104
|
)
|
|
100
105
|
|
|
101
106
|
|
|
@@ -1490,6 +1495,47 @@ def _add_repair_flags(p: argparse.ArgumentParser) -> None:
|
|
|
1490
1495
|
"`--` is not permitted within comments); comment bodies only, "
|
|
1491
1496
|
"CDATA never touched",
|
|
1492
1497
|
)
|
|
1498
|
+
p.add_argument(
|
|
1499
|
+
"--fix-svg-dup-ids",
|
|
1500
|
+
dest="fix_svg_dup_ids",
|
|
1501
|
+
action="store_true",
|
|
1502
|
+
help="rename duplicate id values inside standalone .svg entries "
|
|
1503
|
+
"(old calibre SVG page renders, RSC-005 'Duplicate \"glNNNN\"'): "
|
|
1504
|
+
"first occurrence keeps its name, later ones gain _2/_3; "
|
|
1505
|
+
"references need no rewrite (they resolve to the first definition)",
|
|
1506
|
+
)
|
|
1507
|
+
p.add_argument(
|
|
1508
|
+
"--fix-cdata-terminator",
|
|
1509
|
+
dest="fix_cdata_terminator",
|
|
1510
|
+
action="store_true",
|
|
1511
|
+
help="complete a truncated CDATA-terminator comment in an inline "
|
|
1512
|
+
"<style> block (/*]]> -> /*]]>*/; the CSS-008 'Premature end of "
|
|
1513
|
+
"file' class, one error per affected document)",
|
|
1514
|
+
)
|
|
1515
|
+
p.add_argument(
|
|
1516
|
+
"--fix-misnested-inline",
|
|
1517
|
+
dest="fix_misnested_inline",
|
|
1518
|
+
action="store_true",
|
|
1519
|
+
help="rewrite the drop-cap mis-nest <i><b>X</i></b> to "
|
|
1520
|
+
"<i><b>X</b></i> (em/strong variants, either tag order): the "
|
|
1521
|
+
"unique well-formed form of the same two spans",
|
|
1522
|
+
)
|
|
1523
|
+
p.add_argument(
|
|
1524
|
+
"--fix-stray-close",
|
|
1525
|
+
dest="fix_stray_close",
|
|
1526
|
+
action="store_true",
|
|
1527
|
+
help="remove an end tag whose element has no open start tag (the "
|
|
1528
|
+
"stray extra </div> that cascades into 'body must be terminated "
|
|
1529
|
+
"by the matching end-tag'); mis-nested-but-open pairs never touched",
|
|
1530
|
+
)
|
|
1531
|
+
p.add_argument(
|
|
1532
|
+
"--fix-unterminated-attr",
|
|
1533
|
+
dest="fix_unterminated_attr",
|
|
1534
|
+
action="store_true",
|
|
1535
|
+
help="close an attribute value left open to the tag's own '>' "
|
|
1536
|
+
'(<p class="footnote> -> <p class="footnote">; the RSC-016 '
|
|
1537
|
+
"'must not contain the < character' fatal)",
|
|
1538
|
+
)
|
|
1493
1539
|
p.add_argument(
|
|
1494
1540
|
"--strip-pagination",
|
|
1495
1541
|
action="store_true",
|