bindery-cli 0.57.1__tar.gz → 0.58.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.57.1 → bindery_cli-0.58.0}/AGENTS.md +28 -4
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/PKG-INFO +1 -1
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/patchnotes.md +90 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/pyproject.toml +1 -1
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/roadmap.md +6 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/spec.md +37 -13
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/src/bindery/__init__.py +1 -1
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/src/bindery/cli.py +19 -6
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/src/bindery/epub.py +177 -18
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/src/bindery/transforms.py +65 -22
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/tests/test_epub.py +378 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/tests/test_spine_guard.py +5 -2
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/tests/test_transforms.py +62 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/uv.lock +1 -1
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/.github/FUNDING.yml +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/.github/workflows/ci.yml +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/.github/workflows/publish.yml +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/.gitignore +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/LICENSE +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/OBSERVE-RESEARCH.md +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/README.md +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/docs/screenshots/library-sweep.png +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/logo.svg +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/plugin/__init__.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/project.done +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/run_tests.sh +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/scripts/FastSweep.java +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/scripts/build_plugin.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/scripts/fast_sweep.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/src/bindery/__main__.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/src/bindery/audit.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/src/bindery/library.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/src/bindery/observe.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/src/bindery/pagination.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/src/bindery/reserialize.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/src/bindery/validate.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/src/bindery/watermark.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/tests/test_audit.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/tests/test_cli.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/tests/test_comment_hyphens.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/tests/test_contamination.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/tests/test_cover_tocdrift.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/tests/test_flags_real_core.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/tests/test_flags_wiring.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/tests/test_help.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/tests/test_library.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/tests/test_matcher_hardening.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/tests/test_observe.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/tests/test_pagination.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/tests/test_plugin.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/tests/test_reserialize.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/tests/test_space_renames.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/tests/test_validate.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/tests/test_version.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/tests/test_watermark.py +0 -0
- {bindery_cli-0.57.1 → bindery_cli-0.58.0}/tests/test_xml_hardening.py +0 -0
|
@@ -63,7 +63,25 @@ Born from the 2026 library audit (see the user memory `calibre-library-epubcheck
|
|
|
63
63
|
never percent-encoding (epubcheck decodes references before entry lookup,
|
|
64
64
|
verified against 5.3), ambiguous renames refused per entry (`space_rename_map`),
|
|
65
65
|
accepted under `no_worse` because PKG-010 sits on the warning axis the gate
|
|
66
|
-
does not measure.
|
|
66
|
+
does not measure. Since v0.58.0 (issue #19) the rewritten references
|
|
67
|
+
percent-encode `[`/`]` (raw brackets are RSC-020 "Illegal character in
|
|
68
|
+
path segment"; the encoded form decodes to the raw-spelled entry), and
|
|
69
|
+
BOTH halves rewrite only attributes inside real start tags and processing
|
|
70
|
+
instructions (`_START_TAG_OR_PI_RE`, comments/CDATA excluded): a book that
|
|
71
|
+
TEACHES HTML carries `href="..."` in display text, and the bare attribute
|
|
72
|
+
regex paired the phantom quote with the next real tag -- two RSC-016
|
|
73
|
+
parse fatals on Hacking: The Next Generation. `--strip-broken-anchors`
|
|
74
|
+
(v0.58.0, issue #21) also strips broken fragments from OPF guide
|
|
75
|
+
`<reference href>` (the guide is not a content document; its broken
|
|
76
|
+
fragment hid until the target's own links were fixed -- Fools Crow), and
|
|
77
|
+
the always-on playOrder pass re-runs after the NCX fragment strip so
|
|
78
|
+
collapsed navTargets cannot violate the same-target contract (Troubled
|
|
79
|
+
Man). The shared href resolver decodes the five predefined XML entities
|
|
80
|
+
and the OPF item/itemref/reference matchers accept a namespace prefix
|
|
81
|
+
(issue #20: `href="K&C.png"` names the entry `K&C.png`, and the
|
|
82
|
+
`<opf:item>` blindness made the census re-declare whole manifests while
|
|
83
|
+
the prune deleted live declarations on the raw-ampersand D&D books).
|
|
84
|
+
`--fix-unbound-prefix` (v0.51.0, issue #9, the Calibre
|
|
67
85
|
embed scar; element half v0.57.0, issue #22) binds a prefix the OPF
|
|
68
86
|
never declares in scope inline on the element that uses it: the
|
|
69
87
|
attribute half (`<dc:identifier id="ID1" ns0:scheme="calibre">`
|
|
@@ -90,7 +108,10 @@ Born from the 2026 library audit (see the user memory `calibre-library-epubcheck
|
|
|
90
108
|
file it meant is underdetermined); normal `gate`. `--fix-duplicate-ids`
|
|
91
109
|
(issue #14) is the content-doc half of the SVG duplicate-id rename:
|
|
92
110
|
same first-keeps-name rule, references resolve to the first definition
|
|
93
|
-
and are never rewritten;
|
|
111
|
+
and are never rewritten; since v0.58.0 (issue #21) commented-out and
|
|
112
|
+
CDATA-hidden tags do not count (counting them renamed the REAL
|
|
113
|
+
definition away from its name and dangled every fragment referencing
|
|
114
|
+
it); normal `gate`. The same lane's RSC-001 verdict:
|
|
94
115
|
95.3% of its mass is spine documents whose files exist under a
|
|
95
116
|
different spelling (the spine guard correctly refuses; the mass carrier
|
|
96
117
|
is `--encode-url-spaces` territory), so the prune's coverage boundary is
|
|
@@ -181,12 +202,15 @@ Born from the 2026 library audit (see the user memory `calibre-library-epubcheck
|
|
|
181
202
|
|
|
182
203
|
## Layout
|
|
183
204
|
|
|
184
|
-
- `src/bindery/transforms.py`: pure `str -> (str, int)` text transforms (including `strip_broken_tags`). Since v0.55.0 `fix_svg_dup_ids` and `fix_duplicate_ids` share `_rename_duplicate_ids` (first-keeps-name, `_2`/`_3` suffixes, references never rewritten); the SVG flag owns standalone `.svg` entries, the content-doc flag owns `.xhtml`/`.html`/`.htm`/`.xml`. Since v0.32.0: `strip_attrs_in_start_tags` anchors attribute edits on the quote-aware start-tag matcher, `_outside_protected` forwards arguments (context-carrying transforms can be decorated), `fix_id_colons` matches only the bare `id` attribute and only internal fragments (`fix_ncx_src_fragments` carries renames into the NCX), `fix_ncx_playorder` is anchored to `<navPoint>` start tags, and the css selector boundary covers namespaced and functional selector forms. HAZARD (the 0.41.0 spin): the quote-aware tag-prefix alternation (double-quoted | single-quoted | [^>]) OVERLAPS ([^>] matches quotes too), so a plain `*` re-partitions exponentially on failing candidates; every such greedy loop must carry the possessive `*+` (re 3.11+, the plugin's minimum Calibre). Since v0.42.0 the census is complete and pinned by tests/test_matcher_hardening.py: every greedy loop of this family is possessive (the three 0.41.1 rewrites plus _START_TAG_RE, _COVER_META_RE, _GUIDE_REF_RE, prune_dangling_edges' spine|item|itemref matcher, _ITEM_TAG_RE, _SPINE_ITEM_RE; possessive is byte-identical on success because the loop is always followed by a literal `>` the [^>] branch cannot consume), and the five LAZY siblings (_VOID_RE, the transforms <img> matcher, and epub's link/a/img matchers) use the disjoint catch-all `[^>"']` instead: mutually exclusive branches cannot re-partition, and an unterminated quote inside a tag now fails to match rather than pairing across markup. NEW tag matchers: quote-aware possessive for greedy loops, the disjoint catch-all for lazy ones, and the tempered-quote idiom (["'])((?:(?!\1).)*)\1 for attribute values. Since v0.37.0: `fix_ncx_playorder` strips quotes before its already-correct comparison (regex groups carry quote characters; comparing quoted values against bare numbers counted phantom fixes on every sequential NCX and rewrote single-quoted correct attributes to double quotes). Since v0.54.0 (the 2026-10-24 surgery): `fix_ncx_playorder` is CONTRACT-GATED -- it tokenizes navPoint/navTarget/pageTarget start tags plus their `<content src>` targets, returns unchanged when the NCX already satisfies epubcheck's playOrder contract (same target shares one value, distinct targets distinct values, values contiguous 1..K), and re-sequences by first-appearance target order only on a violation; the old unconditional 1..N renumbering rewrote valid TOCs into violations (211 of 579 firings gate-rejected, 17 real fixes, 347 no-ops). The same fix extends `_PROTECTED_RE` with the Calibre `/*<![CDATA[*/ ... /*]]>*/` wrapper as one protected unit (the bare CDATA alternative ends inside the closing `/*]]>`, which exposed the trailing `*/` to strip_prolog_junk's amputation: 111 phantom-fix rejections).
|
|
205
|
+
- `src/bindery/transforms.py`: pure `str -> (str, int)` text transforms (including `strip_broken_tags`). Since v0.55.0 `fix_svg_dup_ids` and `fix_duplicate_ids` share `_rename_duplicate_ids` (first-keeps-name, `_2`/`_3` suffixes, references never rewritten; since v0.58.0 comment/CDATA-hidden tags do not count -- counting them renamed the real definition away, issue #21); the SVG flag owns standalone `.svg` entries, the content-doc flag owns `.xhtml`/`.html`/`.htm`/`.xml`. Since v0.58.0 (issue #19) `encode_url_spaces` anchors on `_START_TAG_OR_PI_RE` (start tags plus xml-stylesheet-style processing instructions, prefix-disjoint branches, possessive loops) instead of the bare attribute regex: display text that TEACHES HTML carries `href="..."`, and the unanchored regex paired the phantom quote with the next real tag, encoding a space into the element name (two RSC-016 fatals on Hacking: The Next Generation); epub.py's `rewrite_space_renames` anchors on the same matcher (its PI branch is what keeps xml-stylesheet hrefs rewritten after the anchoring). Since v0.32.0: `strip_attrs_in_start_tags` anchors attribute edits on the quote-aware start-tag matcher, `_outside_protected` forwards arguments (context-carrying transforms can be decorated), `fix_id_colons` matches only the bare `id` attribute and only internal fragments (`fix_ncx_src_fragments` carries renames into the NCX), `fix_ncx_playorder` is anchored to `<navPoint>` start tags, and the css selector boundary covers namespaced and functional selector forms. HAZARD (the 0.41.0 spin): the quote-aware tag-prefix alternation (double-quoted | single-quoted | [^>]) OVERLAPS ([^>] matches quotes too), so a plain `*` re-partitions exponentially on failing candidates; every such greedy loop must carry the possessive `*+` (re 3.11+, the plugin's minimum Calibre). Since v0.42.0 the census is complete and pinned by tests/test_matcher_hardening.py: every greedy loop of this family is possessive (the three 0.41.1 rewrites plus _START_TAG_RE, _COVER_META_RE, _GUIDE_REF_RE, prune_dangling_edges' spine|item|itemref matcher, _ITEM_TAG_RE, _SPINE_ITEM_RE; possessive is byte-identical on success because the loop is always followed by a literal `>` the [^>] branch cannot consume), and the five LAZY siblings (_VOID_RE, the transforms <img> matcher, and epub's link/a/img matchers) use the disjoint catch-all `[^>"']` instead: mutually exclusive branches cannot re-partition, and an unterminated quote inside a tag now fails to match rather than pairing across markup. NEW tag matchers: quote-aware possessive for greedy loops, the disjoint catch-all for lazy ones, and the tempered-quote idiom (["'])((?:(?!\1).)*)\1 for attribute values. Since v0.37.0: `fix_ncx_playorder` strips quotes before its already-correct comparison (regex groups carry quote characters; comparing quoted values against bare numbers counted phantom fixes on every sequential NCX and rewrote single-quoted correct attributes to double quotes). Since v0.54.0 (the 2026-10-24 surgery): `fix_ncx_playorder` is CONTRACT-GATED -- it tokenizes navPoint/navTarget/pageTarget start tags plus their `<content src>` targets, returns unchanged when the NCX already satisfies epubcheck's playOrder contract (same target shares one value, distinct targets distinct values, values contiguous 1..K), and re-sequences by first-appearance target order only on a violation; the old unconditional 1..N renumbering rewrote valid TOCs into violations (211 of 579 firings gate-rejected, 17 real fixes, 347 no-ops). The same fix extends `_PROTECTED_RE` with the Calibre `/*<![CDATA[*/ ... /*]]>*/` wrapper as one protected unit (the bare CDATA alternative ends inside the closing `/*]]>`, which exposed the trailing `*/` to strip_prolog_junk's amputation: 111 phantom-fix rejections).
|
|
185
206
|
- `src/bindery/pagination.py`: the opt-in lossy page-number strip (runhead detection, page-layer decision, block-centric removal/merge, safety nets).
|
|
186
207
|
- `src/bindery/watermark.py`: the opt-in lossy watermark strip (anchored and anchorless signature removal).
|
|
187
208
|
- `src/bindery/reserialize.py`: structural repair via `html5lib`.
|
|
188
209
|
- `src/bindery/audit.py`: read-only body-text audits (`content`, `pagenumbers`, `emptytext`, `ocr`, `monolithic` since v0.21.0 with `--max-doc-chars N`, and `completeness` since v0.36.0) behind the `audit` subcommand (v0.15.0). Since v0.18.0 library mode resolves EPUB paths through `cquarry.get_format_path()` and can apply a tag to flagged books via `cquarry.write.WritableCalibreDB` (only with explicit `--tag`; the only sanctioned write path). Since v0.19.0 `audit --id BOOK_ID` audits a single library book through cquarry's single-entity `get_book()` fetch (no library-wide cache; supports `--tag`; incompatible with the directory argument; comma lists since v0.23.0). Since v0.22.0 every archive entry is fully read (CRC + decompression) before analysis (a damaged entry reports its own CORRUPT verdict instead of feeding emptytext) and manifest/NCX references to absent files classify as `convention` (bloated ToC, consecutive span) or `fragment` (broken span). Hazard: the scan loop reuses `tag` as its per-book display column, so the `--tag` argument is captured as `audit_tag` at function entry; do not collapse them again. Since v0.29.0 `audit --json FILE` writes per-file analyzer verdicts in the `library --json` shape (directory, library, and single-book modes; with `--id`, exactly one id; emptytext omitted from a record when the archive verdict owns the body-text story). Since v0.44.0 two more advisory analyzers ride the single pass: `cover` (the EPUB3 `properties~="cover-image"` slice of the ruled hybrid: dangling EPUB2 meta, EPUB3 declaration, cover-file presence) and `tocdrift` (the NCX navMap vs EPUB3 nav toc structural diff, fragments included; audit-only, ToC synthesis out of charter permanently); the loader now exposes the parsed OPF, the NCX text, and the nav HTML on `Book`. Since v0.50.0 a ninth analyzer, `contamination` (issue #8, the judge-and-import class, advisory by contract like completeness/cover/tocdrift, never moves the exit code): foreign-title template stamps (head `<title>` repeats or a volume/book marker with named words in front of it, judged against the OPF's own title/creator/publisher/series with a marker-stripped comparison; a part label whose marker leads never flags), fan-bundle ad signatures (jnovels, kokoro connect, zerobooks, a light-novel plug), and review-paste fingerprints (strong flags alone, weak needs corroboration) in the first five content docs; its corpus is spine PLUS `Book.extra_docs` (the archive's non-spine html, retained by the loader in archive order under a 64 MiB cap, because a broken manifest can leave the junk entirely off the spine: Hothouse). Since v0.50.0 `run_directory`/`run_single` dispatch analyzers through `_dir_dispatch` (one entry per ALL key; the old if/elif chain's `else` ran ocr for cover/tocdrift in those modes since v0.44.0) and `tests/test_contamination.py` pins the map's key set to ALL. Since v0.36.0 the completeness analyzer (Phase 15) reports the phase-1 spot-check per book: spine/prose-doc counts (prose = >= 400 visible chars), first/middle/last prose-doc opening/closing excerpts, trailing-ToC classification (`_trailing_toc`: short link lines dominate, no paragraph-length blocks), and the unreadable fraction. It is ADVISORY by contract (problem always False; ADVISORY on a trailing ToC or unreadable fraction >= 10%), never moves the exit code, and is skipped like emptytext when the archive verdict owns the book. Since v0.38.0 the archive verdict distinguishes font obfuscation from DRM (`OBFUSCATION_ALGOS`: IDPF 2008/embedding + both Adobe URIs; readable obfuscated entries are the benign OBFUSCATED advisory, an unreadable one is CORRUPT, and only non-obfuscation algorithms give ENCRYPTED). Since v0.43.0 untrusted metadata XML is parsed through `_safe_xml_parse` (DOCTYPE/ENTITY declarations refused before xml.etree sees them; the stdlib shape of defusedxml's entity protection) and single entries above `_MAX_ENTRY_BYTES` (32 MB) are refused before decompression; a refused metadata file returns the shell book. Since v0.40.0 the vir-tui console renderer loads through the module-level `_LazyUI` proxy (a plain `import vir_tui as ui` at module level would make 3.12/3.13 installs unimportable now that the stack is marker-gated; LOAD_GLOBAL never consults module `__getattr__`, so a proxy object is the lazy shape that works).
|
|
189
|
-
- `src/bindery/epub.py`: archive rewrite, NCX uid sync, RepairReport, mismatch detection, and the opt-in structural-repair plumbing (including the CSS precondition scan). Since v0.
|
|
210
|
+
- `src/bindery/epub.py`: archive rewrite, NCX uid sync, RepairReport, mismatch detection, and the opt-in structural-repair plumbing (including the CSS precondition scan). Since v0.58.0 (issue #18) the copy loop hands every `zout.writestr` a PRIVATE ZipInfo (`copy.copy(item)`, a fresh one on a rename) and the media-type `peek` catches `zipfile.BadZipFile` too. HAZARD: `writestr` STAMPS the ZipInfo it is handed with the DESTINATION offsets (header_offset, sizes land on it for the central directory); sharing the source's info repointed zin's own name lookups into the output file mid-loop, and one drifted probe killed whole books as "unreadable" -- 56 books "Bad magic number for file header" plus the "possible zip bomb" Development as Freedom (the drifted offset landed on a valid header whose data overlaps its neighbor), all one root cause. Since v0.58.0 (issue #21) `strip_broken_guide_fragments` gives the OPF guide the NCX fragment-strip's document-precision fallback, and the NCX branch re-runs `fix_ncx_playorder` after the anchor pass fires (the pre-strip sequence goes stale when fragments collapse onto their document). Since v0.58.0 (issue #20) `_resolve_href` decodes the five predefined XML entities plus numeric
|
|
211
|
+
character references before the fragment split (attribute text arrives
|
|
212
|
+
escaped; entries are raw; decoding first keeps the `#` inside `&`
|
|
213
|
+
from cutting the target), `_ITEM_TAG_RE`/`_SPINE_ITEM_RE`/`_GUIDE_REF_RE`/prune_dangling_edges' matcher accept an optional ns prefix (`<opf:item>`), and the renamed-reference spellings percent-encode `[`/`]` (`_encode_ref_path`). Since v0.52.0 (issue #10): `spine_dangles(src)` walks itemref -> manifest item -> archive entry through `_resolve_href`+`_norm_path` (None on an unreadable package: the veto needs evidence, never fires on a probe failure), and `prune_missing_manifest_items` derives its spine protection from the text it prunes (no snapshot parameter: fix_manifest_ids renames ids ahead of it, and the existence set it checks against must be the layout its hrefs are written in — `present_src` when space renames are active, matching the content-doc prune). Since v0.46.0 the opt-in selection is the `RepairFlags` dataclass (one field per flag, all off by default; the all-off instance IS the default pass): `repair_epub(src, dst, flags)` and `process_book(..., flags)` take one object instead of a ~25-kwarg signature, the EPUB2-targeted fixes' version gate swaps in a `dataclasses.replace` copy (never mutating the caller's instance), and the plugin's bare `repair_epub(src, dst)` call constructs exactly the all-off default pass. Since v0.55.0 (issue #16) the RSC-008 half lives beside the prune: `collect_undeclared_resources` (one whole-book census: content img/link, inline `<style>` url(), stylesheet url(), OPF guide refs) + `declare_missing_manifest_items` (sorted `bindery-dN` items before `</manifest>`, `_DECLARE_MEDIA_TYPES` blessed extensions only), gated and threaded through `RepairFlags.declare_missing`. Since v0.38.0/v0.39.0 (Phase 16): `generate_container` + the `--fix-container` gateway (insert after mimetype when missing, replace in-loop when stale; constant-epoch timestamp keeps bytes deterministic), `prune_dangling_edges` (prune_missing_manifest_items returns the pruned ids and the edges that pointed at them (spine@toc, media-overlay, fallback, EPUB2 cover meta) are rewritten so pruning cannot manufacture the regression the gate rejects), and `fix_manifest_media_types` (extension map + magic-byte confirmation via a `peek` callable over the open source zip; jpg/png/gif only), and `fix_cover_meta` (the ruling's deterministic half: dangling EPUB2 cover meta re-pointed from the guide's cover reference when exactly one manifest item carries that file, removed otherwise; accepted under no_worse like the lossy strips because cover wiring is invisible to epubcheck).
|
|
190
214
|
- `src/bindery/validate.py`: epubcheck wrapper, the `gate` (improvement) and `no_worse` (no-regression, for the lossy strips) acceptance bars. Since v0.55.0 (issue #15) the default oracle budget is size-scaled (`oracle_timeout_for`: 300s at or under 10 MB, +60s per started 10 MB above, 1800s cap), one subprocess retry follows a timed-out attempt (the daemon path's subprocess fallback is that attempt), and only a double timeout raises `OracleTimeout`, which the gate surfaces as `(epubcheck timeout)` instead of `(epubcheck failed)` (the sweep selectors catch it and keep the book a candidate).
|
|
191
215
|
- `src/bindery/library.py`: Calibre walk, atomic replace, backups, and native format installation. Since v0.19.0 `CalibreIdResolver` resolves the book id from `metadata.db` through cquarry (one lazy path→id map per run; since v0.20.0 the map comes from `CalibreDB.format_path_index()`, re-normalized with `resolve().lower()` for the resolver's symlinked-directory and case-insensitive matching); the `(id)` directory-name regex is only the no-catalog fallback. Since v0.24.0 `install_format()` places the repaired file atomically and updates the `data` row through `cquarry.write.WritableCalibreDB` (since v0.31.0 via `set_format`, cquarry 1.17's sanctioned remove+add in one transaction); the external `calibredb` CLI is gone. Since v0.32.0 a guessed id drives a row update only when metadata.db corroborates it (`_verify_guess`: books row exists, file in the book's own directory, catalogued `data.name` when a row exists); anything else saves in place and leaves the catalog untouched: never reintroduce directory-name guessing as the primary source: renamed/mismatched directories would replace the wrong book. Since 2026-09-15 `make_backup` takes the opt-in `--backup-keep N` ring: at most N backup files per book, the author original `.bak` never deleted, newest content at the highest name; default remains an unbounded rotation.
|
|
192
216
|
- `src/bindery/cli.py`: `repair` and `library` subcommands, including `--all` and `--install-to-calibre`; since v0.52.0 `process_book` carries the spine-resolution veto (issue #10) above every verdict path, promotions included: a candidate whose spine dangles more than the source's is `reject` with `(spine collapse)` appended to the summary, whatever the counts say. `repair --json` emits the library per-book record vocabulary (2026-09-15; since v0.45.0 every per-book record, the phase1 payload included, also carries the structured fix breakdown: the `fixes` dict plus `ncx_uid_synced`/`watermark_refusals` off the `Outcome`, and `_phase1_decisions` reads that data instead of substring-matching the rendered `summary`, which stays for human eyes; CalibreQuarry's lossy-consent mirror is the waiting consumer, floor `bindery>=0.45.0`); since v0.29.0 also the `run` verbs: `phase1` (pre-import vetting over loose files: the audit battery composed with one gated repair sweep; read-only until `--apply-lossy`, which IS the lossy-strip consent) and `phase3` (the scoped post-import apply step: `library --id --sweep --only all --apply --all --install-to-calibre` plus a pre/post summary; mechanically refuses unscoped sweeps with exit 2; since 2026-09-15 the summary sums applied/equal states only and carries rejected projections as `rejected_projection`). Plus `bindery doctor` (2026-09-15): the environment self-check that imports none of the VirInvictus stack, never raises, and always exits 0. The `observe` verb (v0.53.0) writes schema v2 artifacts since v0.55.0 (issue #13): `codes.messages` (renamed from the mislabeled `occurrences`) counts aggregated epubcheck JSON message entries, `codes.occurrences` now carries the true per-site scale (summed `locations`), a `counting` block states both scales in the artifact, and `--against` accepts v1 or v2 (the trend keys exist in both). Both run verbs take `--non-interactive` and surface open questions as `decisions_needed` in their JSON, never prompts. They drive the shipped `run_library` through the real parser, so no flag can drift between the verb and the subcommand it wraps. Since v0.46.0 `cli._flags_from_args(args)` is the one place the argparse names map onto `RepairFlags` fields (each `or --all`), shared by `run_library` and `run_repair`; the old per-verb ~25-kwarg blocks are gone. Since v0.47.1 the help is two-level (the --help-repairs reference is
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: bindery-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.58.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
|
|
@@ -1,5 +1,95 @@
|
|
|
1
1
|
# bindery-cli Patch Notes
|
|
2
2
|
|
|
3
|
+
## v0.58.0 (2026-10-26)
|
|
4
|
+
|
|
5
|
+
### Issues #18-#21: the structural dry run's four rejects, read to the root
|
|
6
|
+
|
|
7
|
+
The 2026-10-25 whole-library structural run filed four issues and applied
|
|
8
|
+
nothing; every fix here was bisected on the specimens first, and the
|
|
9
|
+
forensics each turned up a mechanism the issue text had only half of.
|
|
10
|
+
|
|
11
|
+
**Issue #18: one root cause under all 57 "unreadable" books.** The copy
|
|
12
|
+
loop handed the source's own `ZipInfo` objects to `zout.writestr`, and
|
|
13
|
+
`writestr` stamps the info it is given with the DESTINATION offsets
|
|
14
|
+
(`header_offset` and the sizes land on it for the central directory).
|
|
15
|
+
After an entry was copied, `zin`'s own name lookup for it pointed into
|
|
16
|
+
the output file; the media-type peek's by-name open (v0.56.0) then read
|
|
17
|
+
whatever bytes sat at the drifted offset. Fifty-six books died with "Bad
|
|
18
|
+
magic number for file header" and one (Development as Freedom) tripped
|
|
19
|
+
the read-side zip-bomb guard instead ("Overlapped entries ... possible
|
|
20
|
+
zip bomb"): same mutation, different landing spot, which is why the
|
|
21
|
+
issue's proposed disposition (a dedicated rebuild path for the bomb
|
|
22
|
+
book) is unnecessary. The write now always gets a private `ZipInfo` (a
|
|
23
|
+
shallow copy, so output bytes stay identical; a fresh one on renames, as
|
|
24
|
+
before), the stale-container replacement too, and the peek additionally
|
|
25
|
+
catches `zipfile.BadZipFile` per the issue's hardening ask (it subclasses
|
|
26
|
+
`Exception` directly, not `OSError`): one entry with a genuinely corrupt
|
|
27
|
+
local header is now a skipped probe, never an unreadable book. Both new
|
|
28
|
+
tests fail on the pre-fix code.
|
|
29
|
+
|
|
30
|
+
**Issue #19: the renames were only half of what the references needed.**
|
|
31
|
+
Five of the six rejects (Magic Bites, King Beyond the Gate, Lavondyss,
|
|
32
|
+
Sun Sword, Infinite Jest) share one mechanism: the renamed spellings
|
|
33
|
+
still carry `[` and `]`, epubcheck answers RSC-020 "Illegal character in
|
|
34
|
+
path segment" for a raw bracket in a URL path, and every rewritten
|
|
35
|
+
reference re-flagged -- Magic Bites went 25 -> 37 errors with the space
|
|
36
|
+
fix measured as PKG-010 18 -> 0. Renamed-reference spellings now
|
|
37
|
+
percent-encode the brackets (`%5B`/`%5D`); epubcheck decodes before
|
|
38
|
+
lookup, so the encoded form resolves to the raw-spelled entry, and the
|
|
39
|
+
same books now go 25 -> 6, 41 -> 7, 28 -> 3, 48 -> 2 and 108 -> 22
|
|
40
|
+
(RSC-020 85 -> 0 on Infinite Jest). The sixth reject (Hacking: The Next
|
|
41
|
+
Generation) was pure corruption: the book TEACHES HTML, its display text
|
|
42
|
+
carries `href="..."`, and the bare attribute regex paired the phantom
|
|
43
|
+
quote with the next real markup quote, encoding a space into the
|
|
44
|
+
following start tag's element name -- two RSC-016 parse fatals, and its
|
|
45
|
+
seven counted "fixes" were all phantom. Both the space encoder and the
|
|
46
|
+
rename rewrite now anchor on real start tags and processing instructions
|
|
47
|
+
(comments and CDATA excluded; the PI branch is what keeps
|
|
48
|
+
xml-stylesheet hrefs getting fixed), and the fatals are gone with zero
|
|
49
|
+
phantom edits. Both new tests fail pre-fix.
|
|
50
|
+
|
|
51
|
+
**Issue #20: hrefs are XML, entry names are not.** The prune+declare
|
|
52
|
+
clash on the four Designers & Dragons volumes: their file names carry
|
|
53
|
+
raw `&` while the manifest correctly spells `&`, and the href
|
|
54
|
+
resolver never decoded the entity, so the prune judged live declarations
|
|
55
|
+
absent (30 new RSC-008s alone), the census then re-declared the same
|
|
56
|
+
files from the raw-ampersand content references (30 OPF-074 duplicates
|
|
57
|
+
alone), and the two flags literally swapped the items inside one run
|
|
58
|
+
(net zero, by accident). `_resolve_href` now decodes the five predefined
|
|
59
|
+
entities and numeric character references before the fragment split
|
|
60
|
+
(attribute text arrives escaped; entry names are raw bytes; decoding
|
|
61
|
+
first is also what keeps the `#` inside `&` from cutting the
|
|
62
|
+
target), and the OPF item/itemref/reference matchers accept
|
|
63
|
+
an optional namespace prefix -- the second shape, where Sony-style
|
|
64
|
+
`<opf:item>` packages (Roadside Picnic, Twenty Love Poems, Zhuangzi)
|
|
65
|
+
made the census see an empty manifest and duplicate every declaration.
|
|
66
|
+
All seven books now probe as clean no-ops for both flags, and the
|
|
67
|
+
prefix-tolerant matching fixes a latent `--fix-manifest-ids` gap on the
|
|
68
|
+
same packages (a prefixed item's id used to be invisible to the rename
|
|
69
|
+
while its spine idref was not).
|
|
70
|
+
|
|
71
|
+
**Issue #21: three small deltas, three different mechanisms.** Troubled
|
|
72
|
+
Man and Fools Crow both died in the NCX after the anchor pass: the
|
|
73
|
+
always-on playOrder pass validates the contract BEFORE the fragment
|
|
74
|
+
strip runs, and stripped fragments collapse distinct navTargets onto
|
|
75
|
+
their documents, violating the same-target-shares-one-value rule the
|
|
76
|
+
pass had just verified. The pass now re-runs on the final navMap (it is
|
|
77
|
+
contract-gated, so a still-valid NCX re-runs as a no-op). Fools Crow's
|
|
78
|
+
second new error was the OPF guide: its `type="toc"` reference pointed
|
|
79
|
+
at a filepos fragment that never existed anywhere in the book, invisible
|
|
80
|
+
while the target carried its own broken links and surfaced once they
|
|
81
|
+
were fixed; `--strip-broken-anchors` now gives guide references the same
|
|
82
|
+
document-precision fallback the NCX half has (`guide_fragments_stripped`).
|
|
83
|
+
Fools Crow repairs 1e -> 0e, Troubled Man 2e -> 1e. Seven Principles was
|
|
84
|
+
the duplicate-id rename counting a commented-out copy of an id as a
|
|
85
|
+
second definition: epubcheck sees one definition, so renaming the REAL
|
|
86
|
+
one (the only one a reader resolves) dangled the index's cross-document
|
|
87
|
+
fragment. The shared rename now skips comment/CDATA-hidden tags
|
|
88
|
+
entirely; the book's phantom rename is gone, its 11 errors hold, and the
|
|
89
|
+
38 CSS-007 font normalizations still fire.
|
|
90
|
+
|
|
91
|
+
Suite: 809 tests.
|
|
92
|
+
|
|
3
93
|
## v0.57.1 (2026-10-25)
|
|
4
94
|
|
|
5
95
|
### The prefixed dtb:uid sync: the issue #22 specimen's last finding
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "bindery-cli"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.58.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 = [
|
|
@@ -51,6 +51,7 @@ The plugin vendors the core and never gates (the epubcheck latency ruling).
|
|
|
51
51
|
| 0.55 | The issue-batch release (issues #11-#16, the 2026-10-24 surgery's follow-ups): `--strip-epub3-attrs` extended with `role` + `aria-hidden` (the census killed the DOCTYPE-gate concern: epubcheck is profile-driven; #11), `--fix-duplicate-ids` for content docs (#14), `--declare-missing-items` for RSC-008 (#16, with the prune's RSC-001 boundary documented), the size-scaled epubcheck timeout with one retry and the distinct `OracleTimeout` (#15), observe schema v2 (`codes.messages` rename, true `codes.occurrences`, the `counting` block, v1 `--against` accepted; #13), the #12 content-model ruling (measured, not repaired: the wrap changes layout), and the #17 census lanes (RSC-012/OPF-029 dispositions on existing flags; OPF-030/CSS-007/RSC-004 recorded leave-measured with recipes) | v0.55.0 |
|
|
52
52
|
| 0.56 | The boxed recipes, built same-day on the follow-up call: `--fix-unique-identifier` (the OPF-030 recipe: wire the package's named id onto the first dc:identifier, refuses every ambiguous shape, and predicts the post-wiring uid so the NCX sync the broken wiring was masking fires in the same run -- eagle 2e -> 1e accept) and the CSS-007 font half inside `--fix-media-types` (font/* blessed on both package versions, magic confirmed, .eot never touched; accepted under no_worse because the gain sits on the INFO axis -- Brave New World 8 fonts normalized, CSS-007 cleared) | v0.56.0 |
|
|
53
53
|
| 0.57 | The embed scar's element half and the end of the silent equal (issue #22): `--fix-unbound-prefix` now binds an unbound ELEMENT prefix inline (the 9.7.0 writer self-declares xmlns:dc on every dc: element but one; rule 2 for a literal dc: element resolves to the DC namespace itself; Hackers 1f/1e -> 0f/1e with both binds in one run, and the half-repaired intermediate that read equal now repairs), and the masked-axis reclassification generalizes from the v0.51.0 NCX sync to every fired fix: a gate noop on a book that started and stayed fatal reads partial (the manual list) instead of a silent equal; the specimen's residual ncx:-prefixed dtb:uid gap shipped as the v0.57.1 patch (both matchers read a prefixed `<ncx:meta>` carrier; Hackers fully clean 0f/0e/0w) | v0.57.0-v0.57.1 |
|
|
54
|
+
| 0.58 | The structural dry run's four rejects (issues #18-#21), each bisected to the root on its specimens: the private-ZipInfo write contract (issue #18: writestr stamps the info it is handed with the DESTINATION offsets, one shared info repointed zin's own lookups into the output file -- all 57 "unreadable" books, the "possible zip bomb" included, were this one bug; the peek also catches BadZipFile per the issue), bracket-encoded renamed references plus the start-tag/PI anchor on both reference rewriters (issue #19: raw brackets are RSC-020 path-illegal -- IJ 108e -> 22e -- and the unanchored regex corrupted display text that teaches HTML -- Hacking's two RSC-016 fatals), the entity-decoding href resolver and prefix-tolerant OPF matchers (issue #20: `&` hrefs vs raw-`&` entries made prune and declare swap the same items on the D&D four, and `<opf:item>` blindness duplicated whole manifests on the Sony three), and the three #21 mechanisms (guide-fragment strip, the post-anchor playOrder re-run, the comment-blind duplicate-id rename) | v0.58.0 |
|
|
54
55
|
|
|
55
56
|
## Open work
|
|
56
57
|
|
|
@@ -62,6 +63,11 @@ The plugin vendors the core and never gates (the epubcheck latency ruling).
|
|
|
62
63
|
gate refuses a book that is otherwise repaired. Needs the same
|
|
63
64
|
entry-and-reference coordination as the space renames, with the
|
|
64
65
|
decode-before-lookup epubcheck rule verified per character class.
|
|
66
|
+
*(Narrowed v0.58.0: renamed references now percent-encode `[`/`]`
|
|
67
|
+
(issue #19), so a book whose bracket-named entries carry spaces
|
|
68
|
+
repairs cleanly. The no-rename shape remains: entries with brackets
|
|
69
|
+
but no spaces never enter the rename map, and the flag stays a
|
|
70
|
+
no-op on such books.)*
|
|
65
71
|
- [ ] **Obfuscation-aware encryption.xml repair**: prune stale obfuscation entries
|
|
66
72
|
when font magic bytes prove the fonts are decrypted in place; drop
|
|
67
73
|
encryption.xml when only obfuscation entries remain and fonts verify. NEVER
|
|
@@ -207,8 +207,14 @@ every EPUB3 book in an `--all` sweep taking exactly that damage).
|
|
|
207
207
|
alt text when they carry one, dropped otherwise), and orphaned non-spine OPF manifest
|
|
208
208
|
`<item>` declarations. Spine documents are never pruned: a missing spine document is
|
|
209
209
|
a damaged fragment for the audit's spine-integrity check, never a silent drop. The
|
|
210
|
-
|
|
211
|
-
|
|
210
|
+
shared href resolver (v0.58.0, issue #20) decodes the five predefined XML entities
|
|
211
|
+
and numeric character references before the fragment split (an attribute value arrives escaped: `href="K&C.png"` names
|
|
212
|
+
the entry `K&C.png`, and reading the escaped spelling as a path pruned live
|
|
213
|
+
declarations on the raw-ampersand books) and the OPF matchers accept a namespace
|
|
214
|
+
prefix (`<opf:item>` declares exactly what `<item>` does; a prefix-blind census
|
|
215
|
+
re-declared whole manifests). The manifest existence check resolves the href the way
|
|
216
|
+
the resolver does (unquoted, normalized) and compares it against the layout the OPF
|
|
217
|
+
text is written in: when
|
|
212
218
|
`--encode-url-spaces` is renaming entries, the prune runs ahead of the reference
|
|
213
219
|
rewrite and reads pre-rename hrefs, so it checks against the pre-rename archive
|
|
214
220
|
(a raw-space href judged against renamed spellings is how live spine documents came
|
|
@@ -237,14 +243,20 @@ every EPUB3 book in an `--all` sweep taking exactly that damage).
|
|
|
237
243
|
- **`--strip-broken-anchors`**: strip `href` attributes that cannot resolve, keeping
|
|
238
244
|
the anchor text byte-for-byte. A `#fragment` the target document does not define
|
|
239
245
|
(RSC-020 "fragment identifier not defined", RSC-012 "points to the wrong element") is
|
|
240
|
-
removed from the anchor; NCX `<content src="doc#frag"/>`
|
|
241
|
-
|
|
242
|
-
re-pointed at a guessed sibling document,
|
|
243
|
-
anchors after a converter re-split) may
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
246
|
+
removed from the anchor; NCX `<content src="doc#frag"/>` and OPF guide
|
|
247
|
+
`<reference href="doc#frag">` fall back to the document target, keeping navigation at
|
|
248
|
+
document precision: the fragment is never re-pointed at a guessed sibling document,
|
|
249
|
+
because a drifted id (Mobipocket `filepos` anchors after a converter re-split) may
|
|
250
|
+
exist nowhere. The guide half (v0.58.0) exists because the guide is not a content
|
|
251
|
+
document: its broken fragment hid while the target carried its own broken links and
|
|
252
|
+
surfaced only once the pass fixed them (issue #21, Fools Crow). When the NCX
|
|
253
|
+
fragments strip, the always-on playOrder pass re-runs on the final navMap: distinct
|
|
254
|
+
fragments that collapsed onto one document would otherwise violate the
|
|
255
|
+
same-target-shares-one-value contract the pass had just validated (issue #21,
|
|
256
|
+
Troubled Man). A target wholly absent from the archive is left for the
|
|
257
|
+
spine-integrity report. href values carrying a scheme no reader resolves
|
|
258
|
+
(`kindle:embed:`, `file:`, ...) are stripped under the same flag; the resolvable set
|
|
259
|
+
is fixed (`http`, `https`, `mailto`) and extends only with a named finding.
|
|
248
260
|
- **`--encode-url-spaces`**: repairs raw-space URLs two ways. The reference half
|
|
249
261
|
percent-encodes raw spaces in `src`/`href` attribute values across the package
|
|
250
262
|
(OPF manifest, NCX `content src`, content documents): a URL with a literal space is
|
|
@@ -257,8 +269,16 @@ every EPUB3 book in an `--all` sweep taking exactly that damage).
|
|
|
257
269
|
against epubcheck 5.3). Ambiguous renames (a target that already exists, two names
|
|
258
270
|
converging, a duplicated entry name) are refused per entry, and a book with any
|
|
259
271
|
non-UTF-8 document refuses all of its renames (those entries pass through
|
|
260
|
-
byte-for-byte with no chance to rewrite their references).
|
|
261
|
-
|
|
272
|
+
byte-for-byte with no chance to rewrite their references). '[' and ']' in a renamed
|
|
273
|
+
spelling are percent-encoded in the rewritten reference (v0.58.0, issue #19): a raw
|
|
274
|
+
bracket is not a legal URL character (RSC-020 "Illegal character in path segment"),
|
|
275
|
+
and epubcheck decodes before lookup, so the encoded form resolves to the raw-spelled
|
|
276
|
+
entry. Both halves rewrite only attributes inside real start tags and processing
|
|
277
|
+
instructions, never comments, CDATA, or text: a book that teaches HTML carries
|
|
278
|
+
`href="a b.htm"` in its display text, and a bare attribute regex pairs the phantom
|
|
279
|
+
quote with the next real markup quote, corrupting that tag (issue #19, two RSC-016
|
|
280
|
+
parse fatals on a web-exploitation handbook). Scope stays fixed to the space
|
|
281
|
+
character: extend only with a named epubcheck finding.
|
|
262
282
|
|
|
263
283
|
- **`--fix-container`**: generate `META-INF/container.xml` at the located OPF when the
|
|
264
284
|
container is missing, unparseable, or names a file the archive does not contain. This is the
|
|
@@ -326,7 +346,11 @@ leftovers whose failing OPF is a stale non-rootfile are unreachable by construct
|
|
|
326
346
|
anyway, and first-match is what readers actually did (the rule the SVG fix
|
|
327
347
|
proved). The later duplicates gain `_2`, `_3`, ... and lose whatever invalid
|
|
328
348
|
double-styling the second definition carried; the book keeps the styling it could
|
|
329
|
-
render deterministically.
|
|
349
|
+
render deterministically. Commented-out and CDATA-hidden tags do not count
|
|
350
|
+
(v0.58.0, issue #21): they are invisible to epubcheck's parser and to every reader,
|
|
351
|
+
and counting them renamed the REAL definition away from its name, dangling every
|
|
352
|
+
fragment that referenced it (an index link to an id present once in markup and once
|
|
353
|
+
in a comment).
|
|
330
354
|
- **`--fix-cdata-terminator`**: complete a truncated CDATA-terminator comment in an
|
|
331
355
|
inline `<style>` block: `/*]]>` becomes `/*]]>*/` (a comment-wrapped CDATA block
|
|
332
356
|
whose closing `*/` the converter dropped; epubcheck's CSS parser reads the dangling
|
|
@@ -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.58.0"
|
|
15
15
|
__version__ = VERSION
|
|
16
16
|
|
|
17
17
|
from .epub import RepairReport, repair_epub # noqa: E402
|
|
@@ -1793,9 +1793,12 @@ _REPAIR_FLAG_TABLE: dict[str, list[tuple[str, str, str]]] = {
|
|
|
1793
1793
|
"strip hrefs that cannot resolve; anchor text always preserved",
|
|
1794
1794
|
"strip href attributes that cannot resolve, keeping the anchor text "
|
|
1795
1795
|
"byte-for-byte: a #fragment the target document does not define "
|
|
1796
|
-
"(RSC-020/RSC-012; NCX navTargets
|
|
1797
|
-
"
|
|
1798
|
-
"(kindle:, file:)."
|
|
1796
|
+
"(RSC-020/RSC-012; NCX navTargets and OPF guide references keep the "
|
|
1797
|
+
"document target, so navigation survives) and unresolvable URI "
|
|
1798
|
+
"schemes (kindle:, file:). When the NCX fragments strip, the "
|
|
1799
|
+
"always-on playOrder pass re-runs on the final navMap so collapsing "
|
|
1800
|
+
"two fragments onto one document cannot leave the same-target-"
|
|
1801
|
+
"shares-one-value contract violated.",
|
|
1799
1802
|
),
|
|
1800
1803
|
(
|
|
1801
1804
|
"encode_url_spaces",
|
|
@@ -1805,8 +1808,14 @@ _REPAIR_FLAG_TABLE: dict[str, list[tuple[str, str, str]]] = {
|
|
|
1805
1808
|
"not a valid URL, RSC-020), and rename the archive entries whose "
|
|
1806
1809
|
"names carry raw spaces to their underscore spellings, rewriting "
|
|
1807
1810
|
"every reference to them (underscore, never percent-encoding: "
|
|
1808
|
-
"epubcheck decodes references before entry lookup
|
|
1809
|
-
"
|
|
1811
|
+
"epubcheck decodes references before entry lookup; '[' and ']' in "
|
|
1812
|
+
"a renamed spelling are percent-encoded in the rewritten reference, "
|
|
1813
|
+
"since epubcheck rejects them raw in a URL path). Both halves "
|
|
1814
|
+
"rewrite only attributes inside real start tags and processing "
|
|
1815
|
+
"instructions: a book that displays HTML in its prose carries "
|
|
1816
|
+
'href="..." in its text, and a bare attribute regex corrupts the '
|
|
1817
|
+
"next real tag. Accepted under the no-worse bar: the rename half's "
|
|
1818
|
+
"gain sits on the warning axis.",
|
|
1810
1819
|
),
|
|
1811
1820
|
(
|
|
1812
1821
|
"fix_svg_dup_ids",
|
|
@@ -1830,7 +1839,11 @@ _REPAIR_FLAG_TABLE: dict[str, list[tuple[str, str, str]]] = {
|
|
|
1830
1839
|
"its name, later ones gain _2/_3, and no reference is rewritten "
|
|
1831
1840
|
"because href='#x' anchors, CSS '#x' selectors, and cross-document "
|
|
1832
1841
|
"fragment references all resolve to the first definition exactly "
|
|
1833
|
-
"as readers resolved them before.
|
|
1842
|
+
"as readers resolved them before. Commented-out and CDATA-hidden "
|
|
1843
|
+
"tags do not count as duplicates: they are invisible to epubcheck "
|
|
1844
|
+
"and to every reader, and counting them renamed the real "
|
|
1845
|
+
"definition away from its name (issue #21, Seven Principles). "
|
|
1846
|
+
"The later duplicates lose "
|
|
1834
1847
|
"whatever invalid double-styling the second definition carried.",
|
|
1835
1848
|
),
|
|
1836
1849
|
],
|