yhatt/marp

Page number with total

yutayamamoto opened this issue · 2 comments

Hi, it would be great if it has a feature to display page number with total page number.

I'm now doing it manually, (when it has say, 40 pages)

<!-- page_number: true -->

<style>
.slide_page::after {
  content: "/40";  
}
</style>

Thanks!

yhatt commented

We don't intend to update current Marp for this, but it might be valuable for Marp Next.

Currently, our new Marpit framework supports styling page number, but disallows customize content even if using !important. It will be commented out automatically to avoid wrong use case. However, I think this suggestion might become a mind changer.

An idea for using the number of slides is using data attribute or CSS variables.

/* [NOT WORKING] Planned CSS for Marpit framework */
section::after {
  /* Default */
  /* content: attr(data-marpit-pagination); */

  /* Data attribute (require injecting within Marpit conversion) */
  content: attr(data-marpit-pagination) "/" attr(data-marpit-total);

  /* CSS variables (require injecting within Marpit conversion) */
  content: attr(data-marpit-pagination) "/" var(--marpit-total);
}
yhatt commented

A just shipped out Marpit v1.3.0, the base framework of Marp Next tools, can use the total page number.
https://marpit.marp.app/theme-css?id=customize-content