You need to keep a counter for the chapter numbers, basically a variable holding a number to which you add 1 each time you encounter a new chapter and then replace the "local" number at the chapter level with the value of this variable for each heading.

BTW number incrementing in Lua is very old school: var = var + 1.


Den fre 11 jan. 2019 13:57 skrev Axel Rauschmayer <rauschma-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:

I haven't looked at this in detail, but I would have
thought you could have extracted what you needed from
the `numbering` part of a Sec, which is just
a list of integers, e.g. 2, 4, 2.

If your top level header is parts, then the first
number is the part, the second the chapter, the
third the section.  Then it's just a matter of
converting the part to a roman numeral when the
other numbers are absent, and otherwise ignoring
the part and concatenating the other numbers
with '.' between...

The problem is that part numbers don’t affect chapter numbers:
  • I. Part 1
    • Chapter 1
    • Chapter 2
  • II. Part 2
    • Chapter 3
    • Chapter 4
The first part of my filter numbers Headers properly (to be used with HTML and parts):
  • Visit Headers via a filter.
  • Per Header:
    • Update a counter (with one integer per content entity): depending on the level of the Header, while correctly handling part numbers.
    • Prefix the Header’s content with the properly formatted counter.
Given that I already track Headers and their numbers:
  • I just additionally keep a mapping from chapter IDs to a list of the chapter’s Headers.
  • For the chapter TOC, I transform this list to nested bullet lists, in a second pass.

--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm.
To post to this group, send email to pandoc-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/6e119a06-0158-452e-84e3-b248a4efd4a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhDkztkE%2Bk35A4r4XuZJFoy9ivEm3%3D48YHkbdfNJbMYhrA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.