Skip to content

make-pdf: --toc page-number cells are always empty (no target-counter rule in the print CSS) #2903

Closed

Description

@SamuelArtStudio

Summary

make-pdf --toc renders a table of contents with title text and dotted leaders, but
every page-number cell is empty. The leaders run into blank space. The skill
documents this flag as "Clickable TOC with page numbers", so the page-number half is
missing.

This is not #1689. That issue's root cause (TOC anchors pointing at ids no heading
carried) is fixed — see verification below. The anchors resolve now; the page numbers
still never appear, for a different reason.

Environment

  • gstack 1.87.4.0 (global install, ./setup --prefix)
  • macOS (arm64), printed through Aside 1.26.916.1741
  • 6-page document, --cover --toc, 7 headings

Verification that #1689 is fixed

Generated with --to html and inspected:

TOC anchor hrefs:      ['toc-0' ... 'toc-6']  (total 7)
heading ids in body:   ['toc-0' ... 'toc-6']  (total 7)
anchors that RESOLVE:   7 / 7
data-toc-target ids:    7, targets that RESOLVE: 7 / 7

Every anchor and every data-toc-target now resolves to a real heading id. #1990 did
its job.

The remaining bug

The same HTML shows:

toc-page spans:         7
  non-empty:            0
  sample raw:           ''
target-counter( usage:  NONE

buildTocBlock emits <span class="toc-page" data-toc-target="toc-N"></span> empty,
with the comment that "Page numbers are filled in by Paged.js". But nothing in the
print CSS ever asks Paged.js to fill them. There is no target-counter() declaration
anywhere in the generated stylesheet, so the spans stay empty through the entire print
run.

For completeness, the one rule that hides them:

.toc li .toc-page, .toc li .toc-dots { display: none; }

is inside @media screen and is correct — screen HTML has no pages. It is not the
cause; the print path simply has nothing to render.

Reproduce

printf '# One\n\nbody\n\n# Two\n\nbody\n' > /tmp/t.md
$P generate --toc /tmp/t.md /tmp/t.pdf
pdftotext -f 2 -l 2 /tmp/t.pdf -   # TOC page: titles present, no page numbers

Or inspect the HTML directly:

$P generate --toc /tmp/t.md /tmp/t.html --to html
grep -o 'target-counter([^)]*)' /tmp/t.html   # no output

Expected

Each .toc-page span resolves to the printed page number of its target heading, e.g.
via a Paged.js target-counter rule in the print stylesheet:

.toc-page::after { content: target-counter(attr(data-toc-target), page); }

(exact form depending on how the target id is threaded through).

Suggested follow-up

#1689 can probably be closed — its stated root cause is resolved, and a commenter has
already asked for that. This ticket covers the symptom that outlived the fix.

Activity

  1. capy-ai commented on Oct 3, 2026

    @capy-ai
    Contributor

    Fixed in v1.91.16.0 (#3014, ac20ef1): --toc prints real page numbers (print, read back, fill, verify) and TOC links survive empty headings and reused ids; tested on the fallback browser in CI. If you use Aside, please confirm on your machine since CI can't run it.

    Thanks for the report! If it still happens on v1.91.16.0 or later, reply here and we'll reopen.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions