Skip to content

Whitespace-only bookmark title renders as a blank row in --list, inconsistent with the written filename #6

Description

@adisakshya

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

  1. Build a PDF with an outline bookmark titled " " (three spaces) alongside a normal chapter.
  2. python split_book.py that.pdf --level 1 --list — the row for that entry shows a blank title.
  3. 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

  • A whitespace-only bookmark title displays consistently (e.g. as Untitled) in both --list output and the written filename.
  • Regression test added.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions