Skip to content

Conversation

@sanoakr
Copy link
Contributor

@sanoakr sanoakr commented Dec 7, 2025

Overview

Implement page number reset functionality with automatic integration into the table of contents. This feature allows documents to reset their page numbering at specific points while maintaining correct references in the TOC.

Changes

This PR includes 3 commits:

  1. Add page-number reset support (b0cdc097d)

    • Introduce .resetpagenumber command for resetting page numbers at any point
    • Implement reset marker detection and logical page number computation
    • Support for paged and slide-based documents
  2. Scoped page margins with reset demo (2062400a3)

    • Add page margin handling for reset scenarios
    • Create demo document showcasing reset functionality
  3. Display reset-aware page numbers in table of contents (6a4343167)

    • Inject reset-aware page numbers into TOC entries at runtime
    • Add TypeScript runtime handler for TOC page number injection
    • Add Kotlin renderer hook for TOC identification
    • Fix SCSS layout to display section numbers, titles, and page numbers on a single line
    • Add comprehensive tests for TOC page numbering with resets

Testing

  • All existing tests pass
  • New tests verify TOC page numbers respect reset markers
  • Demo document (mock/pagenum.qd) demonstrates the feature

Type

  • Feature: New page number reset functionality
  • Enhancement: TOC integration with reset-aware numbering

- Added .resetpagenumber command plus runtime support so page counters
and TOC can honor per-section numbering resets; introduced
PageNumberReset AST node, HTML markers, paged/slides JS logic, and
tests.
- Added mock doc pagenum.qd to demonstrate page numbering (margin
footer, explicit page breaks, reset scenario) and fixed line endings so
manual tests align with CLI behavior.
- Added unique identifiers to PageMarginContentInitializer, updated the
HTML renderer to emit data-margin-* metadata plus paired
.page-margin-switch markers, and expanded the mock demo so each page
shows a distinct footer alongside .resetpagenumber.
- Switched the page margins handler to track initializers in a Map, read
per-page switches, and apply only the active initializer per margin
slot; rewrote the Vitest specs to use a recording handler that asserts
both collection and application.
- Add `updateTableOfContentsPageNumbers()` method in TypeScript runtime
to inject
  reset-aware page numbers into TOC links
- Add `data-role="table-of-contents"` attribute to TOC nav element in
Kotlin renderer
  for runtime hook identification
- Update SCSS layout: make TOC list items flexbox containers with
`flex-wrap: wrap`
  to ensure section numbers, titles, and page numbers display on a
single line
- Add tests verifying TOC page numbers respect reset markers in paged
documents
- Update demo document with `.tableofcontents` and `.resetpagenumber`
markers
Add resetCounter() method to PageMarginContentInitializer and call it
in @BeforeTest setUp() for PageMarginsTest and PersistentHeadingTest.

Update expected margin IDs in assertions to start from 1 after reset.

Fixes test failures during clean builds caused by global counter state
persisting across test executions.
@iamgio
Copy link
Owner

iamgio commented Dec 9, 2025

Hey @sanoakr, I tested it and seems nice!

I'm just confused about your second commit: what do you mean by scoped page margins? From what I see it's not closely related to the main feature; if that's true I'd rather have them split into smaller PRs to review more carefully

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.

2 participants