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:
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.