epub2md/tests/test_styles.py
dschlueter a54fdda2fa feat: unsichtbare Zeichen im Fließtext entfernen (P6)
Nullbreiten-Zeichen (U+200B–U+200D, U+2060, U+FEFF) und weiche
Trennstriche (U+00AD) werden aus Fließtext, Alternativtexten und
Kapiteltiteln entfernt; Code bleibt unverändert. Im Mathebuch sind das
198 Zeichen (z. B. '1.​1'). Abschaltbar mit --keep-invisible-chars; die
Anzahl steht im Bericht unter text_cleanup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 02:15:35 +02:00

18 lines
869 B
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Typography and layout: invisible characters, CSS emphasis, scene breaks, boxes, styles, page markers."""
from conftest import Book, Doc
ZW, SHY = "​", "­"
def test_p6_invisible_characters_removed_outside_code(convert):
body = (f"<h1>Kapitel 1.{ZW}1</h1><p>Lese{SHY}rinnen und 1.{ZW}1 sowie{ZW}Wort.</p>"
f"<pre>a{ZW}b</pre><p><code>x{SHY}y</code></p>")
run = convert(Book(docs=[Doc("c.xhtml", body)]))
text = run.chapter("001")
assert "Leserinnen und 1.1 sowieWort." in text
assert "# Kapitel 1.1" in text and 'chapter_title: "Kapitel 1.1"' in text
assert f"a{ZW}b" in text and f"x{SHY}y" in text # code stays verbatim
assert run.report["text_cleanup"]["invisible_chars_removed"] == 4
kept = convert(Book(docs=[Doc("c.xhtml", body)]), "--keep-invisible-chars").chapter("001")
assert f"Lese{SHY}rinnen" in kept