Skip to content

Fix: fill <span class="title"> placeholder in header/footer templates - #7

Open
mahdyarief wants to merge 1 commit into
amitdevx:mainfrom
mahdyarief:fix/header-title-placeholder
Open

mahdyarief wants to merge 1 commit into
amitdevx:mainfrom
mahdyarief:fix/header-title-placeholder

Conversation

@mahdyarief

Copy link
Copy Markdown

Summary

  • Chromium's print header/footer only auto-fills .pageNumber, .totalPages, and .date. A custom header/footer that relied on a <span class="title"></span> placeholder therefore rendered an empty title.
  • Manually fill that placeholder with the resolved document title (priority: frontmatter title > --title > filename).
  • The title is HTML-escaped so a hostile/accidental title cannot break the header markup.
  • Logic extracted to src/utils/header-template.ts and covered by tests/contract/header-title.test.ts.

Test plan

  • tests/contract/header-title.test.ts (6 cases: fill, page-number coexistence, footer, HTML-escape, undefined passthrough, no-placeholder passthrough)
  • Full suite green: 175 passed / 9 skipped on this branch

🤖 Generated with Claude Code

Chromium's print header/footer only auto-fills .pageNumber, .totalPages,
and .date. A custom header that relies on a <span class="title"></span>
placeholder therefore renders an empty title. Manually fill it with the
resolved document title (frontmatter > --title > filename).

The title is HTML-escaped so a hostile or accidental title cannot break
the header markup. Extracted into src/utils/header-template.ts and covered
by tests/contract/header-title.test.ts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant