We use prince-script to show cross-references with page numbers like this:
Sometimes the target page's counter style is lower-roman, but this code will always show a decimal-style number. Is there a way that I could detect the counter style for a given target page?
I want to avoid having to use a different class (other than `.show-page-number`) in the source HTML when referring to lower-roman page numbers (or for other counter styles). Sometimes our editors can't know whether a target page is lower-roman.
I haven't yet been able to get to grips with the box-tracking API to see if I can use it to find the counter style somehow. And I'm not sure that would work anyway, at least not without a two-pass approach.
We have a defined set of classes that we apply to the body element to set the lower-roman counter style. So if I could get the classList for the body element of the target page, I could infer the counter style from it.
a.show-page-number::after {
content: prince-script(pagereference, counter(page), target-counter(attr(href), page));
}
Prince.addScriptFunc("pagereference", function (currentPage, targetPage) {
// if the target is on this page, return blank
if (currentPage === targetPage) {
return '';
}
// otherwise show a space and the page number in parentheses
return '\u00A0' + '(' + targetPage + ')';
});
Sometimes the target page's counter style is lower-roman, but this code will always show a decimal-style number. Is there a way that I could detect the counter style for a given target page?
I want to avoid having to use a different class (other than `.show-page-number`) in the source HTML when referring to lower-roman page numbers (or for other counter styles). Sometimes our editors can't know whether a target page is lower-roman.
I haven't yet been able to get to grips with the box-tracking API to see if I can use it to find the counter style somehow. And I'm not sure that would work anyway, at least not without a two-pass approach.
We have a defined set of classes that we apply to the body element to set the lower-roman counter style. So if I could get the classList for the body element of the target page, I could infer the counter style from it.