fix(html-reader): stop pandoc from collapsing bold-lead-in lists into a paragraph

The book style writes a bold label then a list with no blank line between them:

    **触发分离的条件**:
    - 输入序列长度 > 某阈值

Strict CommonMark (pandoc default -f markdown) requires a blank line before a
list, so it folded every such list into a single <p>. Measured 640 occurrences
across 13 books — troubleshooting checklists and diagnostic steps shipped in the
offline HTML reader as run-on paragraphs, while GitBook, GitHub, and the PDF all
rendered them correctly. The source was fine; only this reader was wrong.

Fix is the additive pandoc extension markdown+lists_without_preceding_blankline,
verified on real book content through real pandoc: the three bullets that
previously joined into one <p> now produce <ul><li>, with no effect on ordinary
paragraphs or on tables (pipe_tables stays enabled).
This commit is contained in:
yeasy
2026-07-23 22:57:35 -07:00
parent 4175760d1b
commit 7391bf95ef
+1 -1
View File
@@ -218,7 +218,7 @@ def main():
tpl = "/tmp/_book_template.html"; out_tmp = "/tmp/_book_out.html"
with open(tmp_md, "w", encoding="utf-8") as f: f.write(combined)
with open(tpl, "w", encoding="utf-8") as f: f.write(TEMPLATE)
cmd = ["pandoc", "_combined_tmp.md", "-f", "markdown", "-t", "html5",
cmd = ["pandoc", "_combined_tmp.md", "-f", "markdown+lists_without_preceding_blankline", "-t", "html5",
"--standalone", "--embed-resources", "--mathml",
"--template", tpl, "--metadata", f"title={a.title}", "-o", out_tmp]
print(" running pandoc ...")