chunkmd, mdscrub: the chapter a converted book is actually divided by

Two things between a converted EPUB and its chapter titles.

The heading level taken as the chapter map was the shallowest present. Pandoc
writes the book's title as the only `#` and every real chapter as a `##`, so
the shallowest level had one heading in it and the whole book came back as a
single chapter. The dividing level is now the shallowest one used more than
once — a level used once is a title.

And an empty bracketed span survived the heading cleaner, because the pattern
wanted at least one character between the brackets. Pandoc writes an anchor
as exactly that: `## []{#link2H_INTR} Introduction`.

Gibbon's first volume, converted from the Project Gutenberg EPUB: 2 distinct
chapter titles before, 61 after, and none of them carrying an element id.
This commit is contained in:
funkpower
2026-09-21 07:30:55 -04:00
parent 8b3c1a0236
commit cfa86f778f
6 changed files with 778 additions and 6 deletions
+16
View File
@@ -0,0 +1,16 @@
# Standalone so that `cargo run` here does not need the workspace above it.
[workspace]
[package]
name = "catena-example"
version = "0.0.0"
edition = "2024"
rust-version = "1.85"
publish = false
[dependencies]
booksniff = { path = "../../crates/booksniff" }
chunkmd = { path = "../../crates/chunkmd" }
citefind = { path = "../../crates/citefind" }
corpus-core = { path = "../../crates/corpus-core" }
mdscrub = { path = "../../crates/mdscrub" }