diff --git a/epub2md/html_converter.py b/epub2md/html_converter.py index ce84500..f10b89f 100644 --- a/epub2md/html_converter.py +++ b/epub2md/html_converter.py @@ -116,6 +116,9 @@ def escape_line_starts(text: str) -> str: token = m.group(2) pos = m.start(2) + (len(token) - 1 if token[0].isdigit() else 0) line = line[:pos] + "\\" + line[pos:] + elif re.fullmatch(r"\s*(-+|=+)\s*", line): # thematic break / setext underline + pos = len(line) - len(line.lstrip()) + line = line[:pos] + "\\" + line[pos:] out.append(line) return "\n".join(out) diff --git a/tests/test_qa_regressions.py b/tests/test_qa_regressions.py index b79ed17..439e22d 100644 --- a/tests/test_qa_regressions.py +++ b/tests/test_qa_regressions.py @@ -109,6 +109,15 @@ def test_multiple_blank_lines_inside_code_are_kept(convert): assert "\n\n\n" not in text.replace(code, "") # outside code blank lines are still normalized +def test_dash_and_equals_lines_stay_text(convert): + """QA2-08: a paragraph '---' became a thematic break, '===' after a line break a setext heading.""" + body = "
---
Zeile
===
Text
-----
Text.
")])