Skip to content

Commit eefbcd9

Browse files
committed
fix: label back matter documents as “Appendix”
… so that TOC summaries appear as “Appendix (Appendixes A–C)” instead of “Appendix (Documents A–C)”
1 parent ec6d76d commit eefbcd9

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

modules/epub.xql

+14-4
Original file line numberDiff line numberDiff line change
@@ -704,15 +704,22 @@ declare function epub:frus-div-to-li($div as element(tei:div), $suppress-documen
704704
</li>
705705
(: show all divs with @xml:id :)
706706
else
707+
let $child-docs := $div/tei:div[@type eq "document"]
708+
let $labels := if ($div/ancestor::tei:back) then ("Appendix", "Appendixes") else ("Document", "Documents")
709+
let $label := if (count($child-docs) eq 1) then $labels[1] else $labels[2]
710+
return
707711
if ($options = 'mobi') then
708712
<blockquote xmlns="http://www.w3.org/1999/xhtml">
709713
<a href="{concat($div/@xml:id, '.html')}">{
710714
normalize-space(frus:head-sans-note($div))
711715
}</a>
712716
{
713-
if ($div[tei:div/@type eq 'document']) then
717+
if ($child-docs) then
714718
if ($suppress-documents) then
715-
concat(' (Documents ', $div/tei:div[@n][1]/@n, '-', $div/tei:div[@n][last()]/@n, ')')
719+
if (count($child-docs) gt 1) then
720+
concat(' (', $label, ' ', $child-docs[@n][1]/@n, '–', $child-docs[@n][last()]/@n, ')')
721+
else
722+
concat(' (', $label, ' ', $child-docs[@n][1]/@n, ')')
716723
else ()
717724
else
718725
()
@@ -728,9 +735,12 @@ declare function epub:frus-div-to-li($div as element(tei:div), $suppress-documen
728735
normalize-space(frus:head-sans-note($div))
729736
}</a>
730737
{
731-
if ($div[tei:div/@type eq 'document']) then
738+
if ($child-docs) then
732739
if ($suppress-documents) then
733-
concat(' (Documents ', $div/tei:div[@n][1]/@n, '-', $div/tei:div[@n][last()]/@n, ')')
740+
if (count($child-docs) gt 1) then
741+
concat(' (', $label, ' ', $child-docs[@n][1]/@n, '–', $child-docs[@n][last()]/@n, ')')
742+
else
743+
concat(' (', $label, ' ', $child-docs[@n][1]/@n, ')')
734744
else ()
735745
else
736746
()

0 commit comments

Comments
 (0)