Skip to content

Commit 94e120e

Browse files
committed
Combine consecutive marginal notes into one to avoid overlapping text.
1 parent 7a985d6 commit 94e120e

11 files changed

+111
-20
lines changed

merge-documents.xsl

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@
212212
<xsl:variable name="rendition" select="current-group()[1]"/>
213213
<xsl:for-each select="current-group()[position() != 1]">
214214
<xsl:if test=". != $rendition">
215-
<xsl:message terminate="no" expand-text="yes">WARNING: Inconsitent rendition: {@selector} {{ {.} }}</xsl:message>
215+
<xsl:message expand-text="yes">WARNING: Inconsitent rendition: {@selector} {{ {.} }}</xsl:message>
216216
</xsl:if>
217217
</xsl:for-each>
218218
</xsl:for-each-group>

modules/spellout.xsl

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
<xsl:sequence select="f:en-spell-out($integer-part) ||
158158
(if ($en-special-fractions($fractional-part)) then ' and ' || $en-special-fractions($fractional-part)
159159
else if (string-length($fractional-part) = 1) then ' and ' || f:en-spell-out(xs:integer($fractional-part)) || ' tenths'
160-
else if (string-length($fractional-part) = 2) then ' and ' || f:en-spell-out(xs:integer($fractional-part)) || ' hunderdths'
160+
else if (string-length($fractional-part) = 2) then ' and ' || f:en-spell-out(xs:integer($fractional-part)) || ' hundrerdths'
161161
else if (string-length($fractional-part) = 3) then ' and ' || f:en-spell-out(xs:integer($fractional-part)) || ' thousandths'
162162
else ' point ' || f:en-spell-out-digits($fractional-part))"/>
163163
</xsl:function>

modules/tables.xsl

+1-1
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@
359359
</xsl:template>
360360

361361

362-
<!-- Find relative postion of cell in table -->
362+
<!-- Find relative position of cell in table -->
363363
<xsl:template name="cell-pos-class">
364364
<xsl:context-item as="element(cell)" use="required"/>
365365

modules/utils.xsl

+1-1
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@
919919
<tr><td>Other </td><td>ccOther </td><td>Anything else.</td></tr>
920920
</table>
921921

922-
<p>The content of (embedded) notes will ignored, and if the element already has a <code>@rend</code> attribute with a relevant type, and empty string will be returned.</p>
922+
<p>The content of (embedded) notes will be ignored. If the element already has a <code>@rend</code> attribute with a relevant type, an empty string will be returned.</p>
923923
</xd:detail>
924924
</xd:doc>
925925

preprocess.xsl

+60-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<!DOCTYPE xsl:stylesheet>
22

33
<xsl:stylesheet version="3.0"
4-
xmlns="http://www.w3.org/1999/xhtml"
4+
xmlns:h="http://www.w3.org/1999/xhtml"
5+
xmlns:f="urn:stylesheet-functions"
56
xmlns:xd="http://www.pnp-software.com/XSLTdoc"
7+
xmlns:xs="http://www.w3.org/2001/XMLSchema"
68
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
7-
exclude-result-prefixes="xd">
9+
exclude-result-prefixes="f h xd">
810

911
<xsl:output indent="no" method="xml" encoding="utf-8"/>
1012

@@ -14,16 +16,16 @@
1416

1517
<xd:doc type="stylesheet">
1618
<xd:short>Stylesheet to preprocess TEI documents.</xd:short>
17-
<xd:detail><p>This stylesheet preprocesses TEI documents, so the final conversion to HTML
18-
can be handled more easily.</p>
19+
<xd:detail><h:p>This stylesheet preprocesses TEI documents, so the final conversion to HTML
20+
can be handled more easily.</h:p>
1921

20-
<p>The following aspects are handled:</p>
22+
<h:p>The following aspects are handled:</h:p>
2123

22-
<ul>
23-
<li>1. Strip the TEI namespace if present (see stripns.xsl).</li>
24-
<li>2. Normalize tables (see normalize-table.xsl).</li>
25-
<li>3. Remove superfluous attributes.</li>
26-
</ul>
24+
<h:ul>
25+
<h:li>1. Strip the TEI namespace if present (see stripns.xsl).</h:li>
26+
<h:li>2. Normalize tables (see normalize-table.xsl).</h:li>
27+
<h:li>3. Remove superfluous attributes.</h:li>
28+
</h:ul>
2729
</xd:detail>
2830
</xd:doc>
2931

@@ -43,6 +45,54 @@
4345
</xsl:template>
4446

4547

48+
<xsl:function name="f:is-margin-note" as="xs:boolean">
49+
<xsl:param name="note" as="element(note)"/>
50+
<xsl:sequence select="$note/@place = 'margin' or $note/@type = 'margin'"/>
51+
</xsl:function>
52+
53+
<!-- Consecutive marginal notes should be combined into a single marginal note. -->
54+
<xsl:template match="note[f:is-margin-note(.)]">
55+
<xsl:if test="not(preceding-sibling::node()[not(self::text()[normalize-space()=''])][1]/self::note[f:is-margin-note(.)])">
56+
<xsl:variable name="siblings" select="(., following-sibling::node())"/>
57+
<xsl:variable name="notes">
58+
<xsl:iterate select="$siblings">
59+
<xsl:choose>
60+
<xsl:when test="self::note[f:is-margin-note(.)]">
61+
<xsl:copy-of select="."/>
62+
</xsl:when>
63+
<xsl:when test="self::text() and normalize-space(.) = ''">
64+
<!-- Skip whitespace -->
65+
</xsl:when>
66+
<xsl:otherwise>
67+
<xsl:break/>
68+
</xsl:otherwise>
69+
</xsl:choose>
70+
</xsl:iterate>
71+
</xsl:variable>
72+
73+
<!-- Combine the notes, copy the attributes of the first in the sequence. -->
74+
<note>
75+
<xsl:for-each select="@*">
76+
<xsl:attribute name="{name(.)}" select="."/>
77+
</xsl:for-each>
78+
<xsl:for-each select="$notes/note">
79+
<xsl:if test="position() > 1">
80+
<lb>
81+
<xsl:if test="@id">
82+
<xsl:attribute name="id" select="@id"/>
83+
</xsl:if>
84+
<xsl:message>INFO: merged consecutive marginal notes.</xsl:message>
85+
</lb>
86+
</xsl:if>
87+
<xsl:apply-templates/>
88+
</xsl:for-each>
89+
</note>
90+
</xsl:if>
91+
</xsl:template>
92+
93+
<!-- Suppress individual notes that are merged -->
94+
<xsl:template match="note[f:is-margin-note(.)][preceding-sibling::node()[not(self::text()[normalize-space()=''])][1]/self::note[f:is-margin-note(.)]]" priority="1"/>
95+
4696
<!-- Two consecutive "phantom"-elements can be merged -->
4797

4898
<xsl:template match="ab[@type='phantom']" mode="#all">

sandbox/extract-segs.xsl

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<xd:doc type="stylesheet">
1212
<xd:short>Extract segments from a TEI document.</xd:short>
1313
<xd:detail>
14-
<p>This stylesheet extracts segments from an XHTML document.</p>
14+
<html:p>This stylesheet extracts segments from an XHTML document.</html:p>
1515
</xd:detail>
1616
<xd:author>Jeroen Hellingman</xd:author>
1717
<xd:copyright>2014, Jeroen Hellingman</xd:copyright>

sandbox/fb2tei.xsl

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
<publisher>
7272
<xsl:value-of select="fb2:publish-info/fb2:publisher"/>
7373
</publisher>
74-
<pubPlace></pubPlace>
74+
<pubPlace/>
7575
<idno type="isbn">
7676
<xsl:value-of select="fb2:publish-info/fb2:isbn"/>
7777
</idno>
@@ -357,7 +357,7 @@
357357
<xsl:when test="$contentType = 'image/jpeg'">.jpg</xsl:when>
358358
<xsl:when test="$contentType = 'image/png'">.png</xsl:when>
359359
<xsl:when test="$contentType = 'image/gif'">.gif</xsl:when>
360-
<xsl:otherwise></xsl:otherwise>
360+
<xsl:otherwise/>
361361
</xsl:choose>
362362
</xsl:variable>
363363

style/garamond.css

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ body {
44
line-height: 1.4;
55
}
66

7+
/* Disable unwanted feature of EB Garamond when using Latin. */
8+
:lang(la) {
9+
font-feature-settings: "locl" 0;
10+
}
11+
712
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .titlePage {
813
font-family: 'EB Garamond', serif;
914
}
@@ -26,3 +31,4 @@ h5, h6 {
2631
.hangqqq { text-indent: -0.68em; }
2732

2833
.grek, .cyrl { font-family: 'EB Garamond', serif; }
34+

xspec/copyright.xspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
</titleStmt>
6868
</x:param>
6969
</x:call>
70-
<x:expect label="will return the most resent death date extracted" select="1616"/>
70+
<x:expect label="will return the most recent death date extracted" select="1616"/>
7171
</x:scenario>
7272

7373
<x:scenario label="When finding the last relevant death-date">
@@ -79,7 +79,7 @@
7979
</titleStmt>
8080
</x:param>
8181
</x:call>
82-
<x:expect label="will return the most resent death date extracted" select="1924"/>
82+
<x:expect label="will return the most recent death date extracted" select="1924"/>
8383
</x:scenario>
8484

8585

xspec/preprocess.xspec

+35
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,41 @@
44
stylesheet="../preprocess.xsl"
55
version="3.0">
66

7+
<!-- combine marginal notes -->
8+
9+
<x:scenario label="When preprocessing a marginal note element">
10+
<x:context>
11+
<note type="margin">Test!</note>
12+
</x:context>
13+
<x:expect label="will result in a single note element">
14+
<note type="margin">Test!</note>
15+
</x:expect>
16+
</x:scenario>
17+
18+
<x:scenario label="When preprocessing two consecutive marginal note elements">
19+
<x:context>
20+
<note type="margin">Test1!</note>
21+
<note type="margin">Test2!</note>
22+
</x:context>
23+
<x:expect label="will result in a single note element">
24+
<note type="margin">Test1!<lb/>Test2!</note>
25+
</x:expect>
26+
</x:scenario>
27+
28+
<x:scenario label="When preprocessing two consecutive marginal note elements, followed by a paragraph and another marginal note.">
29+
<x:context>
30+
<note id="n1" type="margin">Test1!</note>
31+
<note id="n2" type="margin">Test2!</note>
32+
<p>Intermediate text.</p>
33+
<note id="n3" type="margin">Test3!</note>
34+
</x:context>
35+
<x:expect label="will result in a single note element for the first two, and a separate note for the third.">
36+
<note id="n1" type="margin">Test1!<lb id="n2"/>Test2!</note>
37+
<p>Intermediate text.</p>
38+
<note id="n3" type="margin">Test3!</note>
39+
</x:expect>
40+
</x:scenario>
41+
742
<!-- ab -->
843

944
<x:scenario label="When preprocessing an ab element">

xspec/spellout.xspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
<x:scenario label="When spelling-out a number">
1616
<x:call function="f:spell-out"><x:param select="'en'"/><x:param select="3.14"/></x:call>
17-
<x:expect label="will return 'three and fourteen hunderdths'" select="'three and fourteen hunderdths'"/>
17+
<x:expect label="will return 'three and fourteen hundredths'" select="'three and fourteen hundredths'"/>
1818
</x:scenario>
1919

2020
<!-- English -->

0 commit comments

Comments
 (0)