quarkdown icon indicating copy to clipboard operation
quarkdown copied to clipboard

[Enhancement] Scope .totalpages to last .resetpagenumber via document|section argument

Open nudopnu opened this issue 4 months ago • 3 comments

Before submitting

  • [x] I am using the latest version of Quarkdown.
  • [x] I have checked the wiki to confirm this feature doesn't already exist.
  • [x] I have searched existing issues for duplicates.

Description

I would want .totalpages to also be affected by .resetpagenumber. Consider this scenario where I don't want a numbering on the title page:

.doctype {paged}

.center 
    #! Title Page
.pagebreak

# First content page
.pagemargin {bottomcenter}
    .currentpage / .totalpages
.resetpagenumber

# Second content page

# Third content page

I want the page numbering to range from 1/3 to 3/3. Instead it ranges from 1/4 to 3/4.

Proposed syntax or behavior

A relatively easy and backwards-compatible fix would be to allow .totalpages to have an optional argument being one of document | section with document being the default.

  • document will act as the .totalpages-command just as before
  • section will be the number of pages starting from either the last .resetpagenumber-command (considering the start argument there) or the document start

Additional context

This would actually also mimic the behaviour of Microsoft Word, which uses {NUMPAGES} for the total page count of the whole document and {SECTIONPAGES} for the total page count only within the current section.

I am using quakdown version 2.3.1.

nudopnu avatar Jul 14 '26 21:07 nudopnu

Makes sense, thanks. This falls a bit down there in my priority queue, so I'm marking it as ready to pick up by others.

iamgio avatar Jul 15 '26 01:07 iamgio

Hi @iamgio, I'd like to work on this enhancement if it's still available.

My plan is to add an optional document | section argument to .totalpages, keeping document as the default for backward compatibility. The section mode would count pages starting from the most recent .resetpagenumber (respecting its start argument) or from the beginning of the document if none exists.

Please let me know if this approach aligns with your expectations. Thanks!

yuvrajsingh2428 avatar Jul 15 '26 10:07 yuvrajsingh2428

Sounds good @yuvrajsingh2428. The main tweak would be on the runtime's PagedLikeQuarkdownDocument and page-numbers.ts's updateTotatalPageNumbers. Note that Quarkdown resolves page numbers on the runtime/browser side, not at compile-time.

iamgio avatar Jul 15 '26 14:07 iamgio