bindery-cli 0.60.0__tar.gz → 0.61.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.60.0 → bindery_cli-0.61.0}/PKG-INFO +2 -2
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/README.md +1 -1
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/patchnotes.md +57 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/pyproject.toml +1 -1
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/spec.md +6 -2
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/src/bindery/__init__.py +1 -1
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/src/bindery/cli.py +8 -4
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/src/bindery/epub.py +4 -1
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/src/bindery/transforms.py +14 -2
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/tests/test_epub.py +22 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/tests/test_transforms.py +47 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/uv.lock +1 -1
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/.github/FUNDING.yml +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/.github/workflows/ci.yml +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/.github/workflows/publish.yml +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/.gitignore +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/AGENTS.md +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/LICENSE +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/OBSERVE-RESEARCH.md +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/docs/screenshots/library-sweep.png +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/logo.svg +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/plugin/__init__.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/project.done +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/roadmap.md +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/run_tests.sh +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/scripts/FastSweep.java +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/scripts/build_plugin.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/scripts/fast_sweep.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/src/bindery/__main__.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/src/bindery/audit.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/src/bindery/library.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/src/bindery/observe.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/src/bindery/pagination.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/src/bindery/reserialize.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/src/bindery/validate.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/src/bindery/watermark.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/tests/test_audit.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/tests/test_cli.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/tests/test_comment_hyphens.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/tests/test_contamination.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/tests/test_cover_tocdrift.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/tests/test_flags_real_core.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/tests/test_flags_wiring.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/tests/test_help.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/tests/test_library.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/tests/test_matcher_hardening.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/tests/test_observe.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/tests/test_pagination.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/tests/test_plugin.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/tests/test_reserialize.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/tests/test_space_renames.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/tests/test_spine_guard.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/tests/test_validate.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/tests/test_version.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/tests/test_watermark.py +0 -0
- {bindery_cli-0.60.0 → bindery_cli-0.61.0}/tests/test_xml_hardening.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: bindery-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.61.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
|
|
@@ -57,7 +57,7 @@ Everything below is off until its flag is passed (or all at once via `--all`). T
|
|
|
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.
|
|
58
58
|
- **`--escape-unknown-entities`**: escape entity names that are not in the HTML5 table (`&foo;` becomes `&foo;`), which renders exactly as browsers already render an unknown entity. Documents whose DOCTYPE carries an internal subset are skipped wholesale, since a subset can declare custom entities.
|
|
59
59
|
- **`--fix-id-colons`**: translates illegal colons in `id="X:Y"` and their matching internal `#X:Y` fragment references to valid underscores. External URL fragments are left verbatim (they name positions in other documents), `data-id` values are never touched, and the NCX's `content src` fragments follow the rename so the table of contents never dangles against the ids it references.
|
|
60
|
-
- **`--fix-empty-body`**:
|
|
60
|
+
- **`--fix-empty-body`**: gives a strictly empty `<body></body>` one minimal paragraph (`<p> </p>`) to clear the "body incomplete" error. The numeric character reference needs no DTD and the wrapping `p` is the block element XHTML 1.1's body content model requires.
|
|
61
61
|
- **`--fix-missing-title`**: injects a `<title>Unknown</title>` fallback in the `<head>` if missing, handling both empty `<title/>` self-closing tags and entirely absent tags.
|
|
62
62
|
- **`--unwrap-block-in-inline`**: safely unwraps `<span>` tags that illegally contain a block-level element (e.g. `<div>` or `<p>`), leaving the block element intact.
|
|
63
63
|
- **`--strip-invalid-value`**: systematically strips invalid `value="..."` attributes from elements like `<div>`, `<span>`, `<p>`, etc.
|
|
@@ -30,7 +30,7 @@ Everything below is off until its flag is passed (or all at once via `--all`). T
|
|
|
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.
|
|
31
31
|
- **`--escape-unknown-entities`**: escape entity names that are not in the HTML5 table (`&foo;` becomes `&foo;`), which renders exactly as browsers already render an unknown entity. Documents whose DOCTYPE carries an internal subset are skipped wholesale, since a subset can declare custom entities.
|
|
32
32
|
- **`--fix-id-colons`**: translates illegal colons in `id="X:Y"` and their matching internal `#X:Y` fragment references to valid underscores. External URL fragments are left verbatim (they name positions in other documents), `data-id` values are never touched, and the NCX's `content src` fragments follow the rename so the table of contents never dangles against the ids it references.
|
|
33
|
-
- **`--fix-empty-body`**:
|
|
33
|
+
- **`--fix-empty-body`**: gives a strictly empty `<body></body>` one minimal paragraph (`<p> </p>`) to clear the "body incomplete" error. The numeric character reference needs no DTD and the wrapping `p` is the block element XHTML 1.1's body content model requires.
|
|
34
34
|
- **`--fix-missing-title`**: injects a `<title>Unknown</title>` fallback in the `<head>` if missing, handling both empty `<title/>` self-closing tags and entirely absent tags.
|
|
35
35
|
- **`--unwrap-block-in-inline`**: safely unwraps `<span>` tags that illegally contain a block-level element (e.g. `<div>` or `<p>`), leaving the block element intact.
|
|
36
36
|
- **`--strip-invalid-value`**: systematically strips invalid `value="..."` attributes from elements like `<div>`, `<span>`, `<p>`, etc.
|
|
@@ -1,5 +1,62 @@
|
|
|
1
1
|
# bindery-cli Patch Notes
|
|
2
2
|
|
|
3
|
+
## v0.61.0 (2026-11-02)
|
|
4
|
+
|
|
5
|
+
### Issue #25: fix-empty-body injects `<p> </p>`, not bare ` `
|
|
6
|
+
|
|
7
|
+
Space Prison (Calibre book #11556, the Pyramid 1960 scan-conversion rip)
|
|
8
|
+
surfaced the defect in a phase-3 sweep: the book's 205-byte shell page
|
|
9
|
+
(`OEBPS/text00001.html`, `<body></body>` under an XHTML 1.0 Strict
|
|
10
|
+
DOCTYPE) made `--fix-empty-body` flip its own `--all` candidate from a
|
|
11
|
+
clean decrease (`0f/6e/0w -> 0f/5e/0w` core) into a regression the gate
|
|
12
|
+
had to refuse (`0f/6e/0w -> 1f/4e/0w --all`), the delta exactly
|
|
13
|
+
`fix_empty_body:1` and the new count a FATAL RSC-016, "The entity nbsp
|
|
14
|
+
was referenced, but not declared".
|
|
15
|
+
|
|
16
|
+
The root cause has two halves, both verified against epubcheck 5.3 with
|
|
17
|
+
a minimal-EPUB matrix across XHTML 1.0 Strict / Transitional / XHTML
|
|
18
|
+
1.1 / no-DOCTYPE shapes on EPUB2 packages and plain `<!DOCTYPE html>`
|
|
19
|
+
on EPUB3:
|
|
20
|
+
|
|
21
|
+
- epubcheck validates EPUB2 content docs against the XHTML 1.1 DTD and
|
|
22
|
+
resolves named entities only from DTDs it carries locally (the XHTML
|
|
23
|
+
1.1 one). ` ` is not one of XML's five predefined entities, so
|
|
24
|
+
under every DOCTYPE epubcheck does not resolve locally -- XHTML 1.0
|
|
25
|
+
Strict and Transitional, and no DOCTYPE at all -- the injection was
|
|
26
|
+
an undeclared-entity parse fatal. EPUB3 is no refuge: XHTML content
|
|
27
|
+
documents are validated as XML there too, and ` ` is fatal
|
|
28
|
+
under every DOCTYPE shape tested.
|
|
29
|
+
- The XHTML 1.1 body content model is block elements only, so bare
|
|
30
|
+
character data (named or numeric) never satisfied it anywhere: the
|
|
31
|
+
error the fix was named for ("element body incomplete") never
|
|
32
|
+
cleared. The old injection therefore never once applied under
|
|
33
|
+
epubcheck 5.x -- every run was either a fatal-regression reject or
|
|
34
|
+
an equal-noop -- which is why hardening it breaks no user: there was
|
|
35
|
+
no working behavior to preserve, only a dead flag whose only live
|
|
36
|
+
behavior was flipping candidates into rejects.
|
|
37
|
+
|
|
38
|
+
The injection is now the exact literal `<p> </p>`. The numeric
|
|
39
|
+
character reference needs no DTD in any validation path, and the
|
|
40
|
+
wrapping `<p>` is the block element the content model demands; the
|
|
41
|
+
matrix shows it clearing "body incomplete" on every EPUB2 DOCTYPE
|
|
42
|
+
shape with zero fatals and zero new errors, while on EPUB3 books
|
|
43
|
+
(where an empty body raises nothing) the gate answers equal and
|
|
44
|
+
nothing applies. The gate now accepts the fixture honestly:
|
|
45
|
+
`0f/6e/0w -> 0f/4e/0w` (body incomplete and the NCX playOrder error
|
|
46
|
+
both fixed; the book's four pre-existing error-nits stay), applied
|
|
47
|
+
under `--all`.
|
|
48
|
+
|
|
49
|
+
The flag's name, selection rule, opt-in status, and count key are
|
|
50
|
+
unchanged; only the injected bytes differ. `--fix-empty-body` and the
|
|
51
|
+
plugin's default pass never overlapped (the plugin runs the default
|
|
52
|
+
pass only), so the Bindery Repair zip in this release just carries the
|
|
53
|
+
updated transform. Tests: `TestFixEmptyBody` (test_transforms.py) pins
|
|
54
|
+
the literal, the no-named-entity invariant, whitespace/attribute/case
|
|
55
|
+
shapes, and untouched non-empty bodies; test_epub.py carries the
|
|
56
|
+
issue #25 regression shape (a Strict-DOCTYPE shell doc whose candidate
|
|
57
|
+
must show the numeric-in-block injection and never ` `). Suite:
|
|
58
|
+
832 tests.
|
|
59
|
+
|
|
3
60
|
## v0.60.0 (2026-11-01)
|
|
4
61
|
|
|
5
62
|
### Issue #24: the oracle budget also scales on archive entry count
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "bindery-cli"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.61.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 = [
|
|
@@ -150,8 +150,12 @@ byte-for-byte. The normal gate applies.
|
|
|
150
150
|
Twenty-six repairs go past well-formedness and therefore require their own flag; none is ever
|
|
151
151
|
part of the default pipeline:
|
|
152
152
|
|
|
153
|
-
- **`--fix-empty-body`**:
|
|
154
|
-
incomplete").
|
|
153
|
+
- **`--fix-empty-body`**: `<p> </p>` inside a strictly empty `<body></body>` ("body
|
|
154
|
+
incomplete"). The numeric character reference needs no DTD and the wrapping `p` is the
|
|
155
|
+
block element XHTML 1.1's body content model demands (issue #25: the ` ` this fix
|
|
156
|
+
originally injected was an undeclared-entity parse fatal under every DOCTYPE epubcheck
|
|
157
|
+
does not resolve locally, and bare character data never satisfied the content model).
|
|
158
|
+
Adds visible content, hence opt-in like `--add-img-alt`.
|
|
155
159
|
- **`--fix-missing-title`**: inject `<title>Unknown</title>` when the head has no usable
|
|
156
160
|
title.
|
|
157
161
|
- **`--fix-id-colons`**: illegal colons in `id="X:Y"` and their matching internal
|
|
@@ -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.61.0"
|
|
15
15
|
__version__ = VERSION
|
|
16
16
|
|
|
17
17
|
from .epub import RepairReport, repair_epub # noqa: E402
|
|
@@ -1668,10 +1668,14 @@ _REPAIR_FLAG_TABLE: dict[str, list[tuple[str, str, str]]] = {
|
|
|
1668
1668
|
"structural repairs: markup and nesting": [
|
|
1669
1669
|
(
|
|
1670
1670
|
"fix_empty_body",
|
|
1671
|
-
"
|
|
1672
|
-
"
|
|
1673
|
-
"incomplete' error).
|
|
1674
|
-
"
|
|
1671
|
+
"fill a strictly empty <body></body> with <p> </p>",
|
|
1672
|
+
"inject <p> </p> inside a strictly empty <body></body> (the "
|
|
1673
|
+
"'body incomplete' error). The numeric character reference needs "
|
|
1674
|
+
"no DTD (a named is an undeclared-entity parse fatal under "
|
|
1675
|
+
"every DOCTYPE epubcheck does not resolve locally) and the "
|
|
1676
|
+
"wrapping p is the block element XHTML 1.1's body content model "
|
|
1677
|
+
"demands, which bare text never satisfied. Adds visible content "
|
|
1678
|
+
"the author never wrote; hence opt-in.",
|
|
1675
1679
|
),
|
|
1676
1680
|
(
|
|
1677
1681
|
"fix_missing_title",
|
|
@@ -1994,7 +1994,10 @@ def repair_epub(
|
|
|
1994
1994
|
With `strip_watermarks`, remove known producer watermarks (e.g. OceanofPDF).
|
|
1995
1995
|
|
|
1996
1996
|
The structural repairs are all opt-in, never part of the core pass:
|
|
1997
|
-
with `empty_body`,
|
|
1997
|
+
with `empty_body`, inject the exact literal `<p> </p>` into a strictly
|
|
1998
|
+
empty <body> (the numeric reference needs no DTD and the wrapping p is
|
|
1999
|
+
the block epubcheck's XHTML 1.1 body content model demands — issue #25);
|
|
2000
|
+
with `missing_title`,
|
|
1998
2001
|
inject a <title>Unknown</title> fallback; with `id_colons`, translate illegal
|
|
1999
2002
|
colons in id attributes and their #fragment references; with `block_in_inline`,
|
|
2000
2003
|
unwrap a <span> that illegally wraps a block element; with `invalid_value`, strip
|
|
@@ -631,7 +631,19 @@ def unwrap_illegal_tags(
|
|
|
631
631
|
|
|
632
632
|
@_outside_protected
|
|
633
633
|
def fix_empty_body(s: str) -> tuple[str, int]:
|
|
634
|
-
"""
|
|
634
|
+
"""Give a strictly empty `<body></body>` one minimal paragraph, the exact
|
|
635
|
+
literal `<p> </p>` ("body incomplete").
|
|
636
|
+
|
|
637
|
+
That literal, not the bare ` ` this fix shipped with (issue #25):
|
|
638
|
+
epubcheck validates EPUB2 content docs against the
|
|
639
|
+
with (issue #25): epubcheck validates EPUB2 content docs against the
|
|
640
|
+
XHTML 1.1 DTD, whose body content model is block elements only, so bare
|
|
641
|
+
character data never cleared the error, and ` ` is not one of XML's
|
|
642
|
+
five predefined entities, so under every DOCTYPE whose DTD epubcheck does
|
|
643
|
+
not load locally the injection was itself a parse-fatal RSC-016 ("The
|
|
644
|
+
entity "nbsp" was referenced, but not declared"). The numeric
|
|
645
|
+
character reference needs no DTD at all, and the wrapping `<p>` is the
|
|
646
|
+
block the content model demands.
|
|
635
647
|
|
|
636
648
|
Opt-in (--fix-empty-body): this ADDS visible content the author never wrote,
|
|
637
649
|
the same reason --add-img-alt is opt-in; it is never part of the core pass.
|
|
@@ -641,7 +653,7 @@ def fix_empty_body(s: str) -> tuple[str, int]:
|
|
|
641
653
|
def repl(m: re.Match) -> str:
|
|
642
654
|
nonlocal count
|
|
643
655
|
count += 1
|
|
644
|
-
return m.group(1) + "
|
|
656
|
+
return m.group(1) + "<p> </p>" + m.group(2)
|
|
645
657
|
|
|
646
658
|
s, n = re.subn(r"(<body[^>]*>\s*)(</body>)", repl, s, flags=re.IGNORECASE)
|
|
647
659
|
return s, n
|
|
@@ -1012,6 +1012,28 @@ class TestOptInStructuralRepairs(unittest.TestCase):
|
|
|
1012
1012
|
report = repair_epub(self.src, self.dst, RepairFlags(empty_body=True))
|
|
1013
1013
|
self.assertIn("fix_empty_body", report.fixes)
|
|
1014
1014
|
|
|
1015
|
+
def test_empty_body_injection_is_numeric_in_a_block(self):
|
|
1016
|
+
# issue #25 (Space Prison #11556): the shell doc declares XHTML 1.0
|
|
1017
|
+
# Strict, whose DTD epubcheck does not resolve locally, so the old
|
|
1018
|
+
# bare ` ` injection was an undeclared-entity parse fatal
|
|
1019
|
+
# (RSC-016) and the candidate died in the gate as a regression. The
|
|
1020
|
+
# injection must be the DTD-independent numeric reference inside the
|
|
1021
|
+
# block element XHTML 1.1's body content model demands.
|
|
1022
|
+
self._build(
|
|
1023
|
+
css="p { margin: 0 }",
|
|
1024
|
+
content=(
|
|
1025
|
+
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '
|
|
1026
|
+
'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
|
|
1027
|
+
'<html xmlns="http://www.w3.org/1999/xhtml">\r'
|
|
1028
|
+
"<head><title></title>\r</head>\r<body></body>\r</html>\r"
|
|
1029
|
+
),
|
|
1030
|
+
)
|
|
1031
|
+
repair_epub(self.src, self.dst, RepairFlags(empty_body=True))
|
|
1032
|
+
with zipfile.ZipFile(self.dst) as z:
|
|
1033
|
+
c = z.read("OEBPS/c1.xhtml").decode()
|
|
1034
|
+
self.assertIn("<body><p> </p></body>", c)
|
|
1035
|
+
self.assertNotIn(" ", c)
|
|
1036
|
+
|
|
1015
1037
|
|
|
1016
1038
|
class TestPruneMissingResources(unittest.TestCase):
|
|
1017
1039
|
"""--prune-missing-resources: references to files the archive does not
|
|
@@ -550,6 +550,53 @@ class TestStructuralRepairsAreOptIn(unittest.TestCase):
|
|
|
550
550
|
self.assertGreaterEqual(n, 1)
|
|
551
551
|
|
|
552
552
|
|
|
553
|
+
class TestFixEmptyBody(unittest.TestCase):
|
|
554
|
+
"""The injection is `<p> </p>` (issue #25): epubcheck validates EPUB2
|
|
555
|
+
content docs against the XHTML 1.1 DTD, whose body content model is block
|
|
556
|
+
elements only, so the bare ` ` this fix shipped with never cleared
|
|
557
|
+
the error and was itself an undeclared-entity parse fatal (RSC-016) under
|
|
558
|
+
every DOCTYPE epubcheck does not resolve locally."""
|
|
559
|
+
|
|
560
|
+
def test_injects_numeric_entity_in_a_block(self):
|
|
561
|
+
out, n = fix_empty_body("<html><body></body></html>")
|
|
562
|
+
self.assertEqual(n, 1)
|
|
563
|
+
self.assertEqual(out, "<html><body><p> </p></body></html>")
|
|
564
|
+
|
|
565
|
+
def test_never_emits_the_named_entity(self):
|
|
566
|
+
# the issue #25 regression class: is not one of XML's five
|
|
567
|
+
# predefined entities, so it is a parse fatal under a DOCTYPE whose
|
|
568
|
+
# DTD declares no HTML entity set
|
|
569
|
+
out, _ = fix_empty_body("<body></body>")
|
|
570
|
+
self.assertNotIn(" ", out)
|
|
571
|
+
|
|
572
|
+
def test_whitespace_only_body_fires(self):
|
|
573
|
+
out, n = fix_empty_body("<body>\r</body>")
|
|
574
|
+
self.assertEqual(n, 1)
|
|
575
|
+
self.assertEqual(out, "<body>\r<p> </p></body>")
|
|
576
|
+
|
|
577
|
+
def test_body_attributes_and_leading_space_survive(self):
|
|
578
|
+
out, n = fix_empty_body('<body class="chapter">\n</body>')
|
|
579
|
+
self.assertEqual(n, 1)
|
|
580
|
+
self.assertEqual(out, '<body class="chapter">\n<p> </p></body>')
|
|
581
|
+
|
|
582
|
+
def test_case_insensitive_match(self):
|
|
583
|
+
out, n = fix_empty_body("<BODY></BODY>")
|
|
584
|
+
self.assertEqual(n, 1)
|
|
585
|
+
self.assertEqual(out, "<BODY><p> </p></BODY>")
|
|
586
|
+
|
|
587
|
+
def test_non_empty_body_untouched(self):
|
|
588
|
+
for body in ("<body><p>x</p></body>", '<body><img src="a.png"/></body>'):
|
|
589
|
+
with self.subTest(body=body):
|
|
590
|
+
out, n = fix_empty_body(body)
|
|
591
|
+
self.assertEqual((out, n), (body, 0))
|
|
592
|
+
|
|
593
|
+
def test_multiple_empty_bodies_count_individually(self):
|
|
594
|
+
# malformed (one body per document), but the count must stay honest
|
|
595
|
+
out, n = fix_empty_body("<body></body><body></body>")
|
|
596
|
+
self.assertEqual(n, 2)
|
|
597
|
+
self.assertEqual(out.count("<p> </p>"), 2)
|
|
598
|
+
|
|
599
|
+
|
|
553
600
|
class TestFixNcxPlayorder(unittest.TestCase):
|
|
554
601
|
def test_resequences_navpoint_attributes(self):
|
|
555
602
|
ncx = (
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|