Context
split_book.py, print_plan() vs slugify() / _walk_outline().
Problem
_walk_outline only falls back a bookmark's title to "Untitled" when the title is empty (item.title if item.title else "Untitled"); a title that's present but whitespace-only (e.g. " ") passes that check untouched. print_plan then prints that title as-is, producing a blank-looking row in the --list preview table. Later, when the file is actually written, slugify() strips the whitespace down to nothing and falls back to "untitled" for the filename. So the on-screen plan (blank) and the actual output filename (..._untitled.pdf) disagree — confusing right at the point (--list) users are meant to be able to trust before committing to a real split.
Reproduction
- Build a PDF with an outline bookmark titled
" " (three spaces) alongside a normal chapter.
python split_book.py that.pdf --level 1 --list — the row for that entry shows a blank title.
python split_book.py that.pdf --level 1 (real run) — the written file is named ..._untitled.pdf.
Confirmed with a synthetic PDF.
Expected
The --list preview and the actual written filename should agree — e.g. treat a whitespace-only title the same as an empty one in _walk_outline (.strip() before the truthiness check), so the plan table also shows Untitled.
Actual
Preview shows a blank title; actual filename uses the untitled fallback. Cosmetic but confusing.
Acceptance criteria
Context
split_book.py,print_plan()vsslugify()/_walk_outline().Problem
_walk_outlineonly falls back a bookmark's title to"Untitled"when the title is empty (item.title if item.title else "Untitled"); a title that's present but whitespace-only (e.g." ") passes that check untouched.print_planthen prints that title as-is, producing a blank-looking row in the--listpreview table. Later, when the file is actually written,slugify()strips the whitespace down to nothing and falls back to"untitled"for the filename. So the on-screen plan (blank) and the actual output filename (..._untitled.pdf) disagree — confusing right at the point (--list) users are meant to be able to trust before committing to a real split.Reproduction
" "(three spaces) alongside a normal chapter.python split_book.py that.pdf --level 1 --list— the row for that entry shows a blank title.python split_book.py that.pdf --level 1(real run) — the written file is named..._untitled.pdf.Confirmed with a synthetic PDF.
Expected
The
--listpreview and the actual written filename should agree — e.g. treat a whitespace-only title the same as an empty one in_walk_outline(.strip()before the truthiness check), so the plan table also showsUntitled.Actual
Preview shows a blank title; actual filename uses the
untitledfallback. Cosmetic but confusing.Acceptance criteria
Untitled) in both--listoutput and the written filename.