-
Notifications
You must be signed in to change notification settings - Fork 757
Description
The string() function in GCPM allows a string, previously set by string-set, to be included in the page margin content. Exactly which element to take the string value from is determined by the second parameter, of which the value "start" is defined as follows:
If the element is the first element on the page, the value of the first assignment is used. Otherwise the entry value is used. The entry value may be empty if the element hasn’t yet appeared.
The definition of "first element on the page" is what I think needs clarifying. To clarify the intention of this function, take a look at the titus.xml example from Prince, which has the following (edited for clarity) CSS:
@page {
@top-center {
content: "Titus " string(chapterx, start) ":" string(versex, start) " - " string(chapterx, last) ":" string(versex, last);
}
}
span {
counter-increment: verse;
string-set: versex counter(verse);
}Here's a screenshot:
The paragraph numbered 15 (beginning "Everything", at the end of the first page) continues onto the start of the second page. This means the following paragraph (numbered 16) is not the first element on the page - it's preceded by content from another element - so the value of string(versex, start) is 15, not 16.
So far, so good. However, if you reformat the example in a single column you get this:
The page opens with verse 15, but the verse is listed as 14 in the margin. The reason this is happening is that the XML looks roughly like this:
<p>
<span></span>Everything is pure... (verse 15)
</p>
<p>
<span></span>Such people claim... (verse 16)The first element on the page is the p - the block container surrounding the inline span. Because of this, verse 15 is not considered the "first element on the page", and the entry alue (14) is used.
I think the results from Prince arguably match the specification in this case, but I don't think the specification is correct. I think the desired value in both examples is "15".
I've been working through this for a while now to try and find a way to rephrase this test to get that result, and it's surprisingly complicated. I think there are two practical definitions of "the first element on the page".
-
The first element that is opened on the page - any text content continued from the previous page is ignored. This definition would give "15" as the start value in the first example (the first element opened on the page is the second
p) and "14" as the start value in the second example (the first element opened is the firstp). -
The first element that is opened on the page, provided it's not preceded by any content continued from the previous page. This definition would give "15" as the start value in the first example, and "14" in the second example.
Neither of those give the correct result. We need something that will work in all of these:
<p style="string-set:versex counter(verse)"><span>Everything...
<p style="string-set:versex bad"><span style="string-set:versex counter(verse)">Everything...
<p><span style="string-set:versex counter(verse)">Everything...
<p><span style="string-set:versex counter(verse)"></span>Everything...I think the definition for how the "start" value is found needs to be changed to not reference the "first element on the page".
If the first item of content on the page was not continued from the previous page, then use the closest assignment on the page that precedes that content in document order. Otherwise the entry value is used.
This seems to give the correct result in all the above variations.

