Skip to content

Commit

Permalink
RP XSL - catch further cases
Browse files Browse the repository at this point in the history
  • Loading branch information
fred-atherden committed Feb 4, 2025
1 parent 72797f1 commit be14a31
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/preprint-changes.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,7 @@
<!-- Include certain bolded text within xref when it immediately follows that xref
e.g. <xref>Fig 1</xref><bold>, right)</bold> to <xref>Fig 1, right</xref>)
bold handling in template 'bold-follow-xref-cleanup' -->
<xsl:variable name="panel-regex" select="'^,?\s?(left|right|top|bottom|inset|lower|upper|middle)(\s(and\s)?(left|right|top|bottom|inset|lower|upper|middle))?(\s?panels?)?[;\),]?[\s\.]?$'"/>
<xsl:variable name="panel-regex" select="'^,?\s?(left|right|top|bottom|inset|lower|upper|middle)(\s(and\s)?(left|right|top|bottom|inset|lower|upper|middle))?(\s?panels?)?[;\),]?[\s\.]?$|^(\s?([,&amp;–\-]|and))*\s?[\p{L}](,?\s?[\p{L}]|\-\s?[\p{L}])?[;\),]?[\s\.]?$'"/>
<xsl:template xml:id="fix-truncated-xrefs" match="xref[following-sibling::node()[1][name()='bold']]">
<xsl:variable name="bold-text" select="following-sibling::node()[1]"/>
<xsl:copy>
Expand All @@ -1401,6 +1401,9 @@
<!-- Cleanup unnecessary bold elements that appear directly after xrefs -->
<xsl:template xml:id="bold-follow-xref-cleanup" match="bold[preceding-sibling::node()[1][name()='xref']]">
<xsl:choose>
<xsl:when test="matches(lower-case(.),'^\s?(and|&amp;|[,;\)])\s?\.?$')">
<xsl:apply-templates select="text()|comment()|processing-instruction()"/>
</xsl:when>
<xsl:when test="matches(lower-case(.),$panel-regex)">
<xsl:choose>
<xsl:when test="matches(.,'[;\),][\s\.]$')">
Expand All @@ -1412,9 +1415,6 @@
<xsl:otherwise/>
</xsl:choose>
</xsl:when>
<xsl:when test="matches(lower-case(.),'^\s?(and|&amp;|,)\s?$')">
<xsl:apply-templates select="text()|comment()|processing-instruction()"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates select="*|@*|text()|comment()|processing-instruction()"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@
<p>something <xref ref-type="fig">Figure 1</xref><bold>, bottom panel)</bold> something</p>
<p>something <xref ref-type="fig">Figure 1</xref>; and Figure 2<bold>, bottom panel)</bold> something</p>
<p>something <xref ref-type="table"><italic><bold>Table 1</bold></italic></xref><bold>, middle and lower;.</bold> Something</p>
<p><xref><bold>Fig. 1Bc</bold></xref><bold> i, </bold></p>
<p><xref>Fig5</xref><bold> E,F).</bold></p>
<p><xref>Figure 4—figure supplement S4C</xref><bold> and D</bold></p>
<p><xref><italic>Figure 1A</italic></xref><bold>&amp;C</bold></p>
<p><xref>Fig. 3e</xref><bold>- f</bold></p>
</sec>
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@
<p>something <xref ref-type="fig">Figure 1, bottom panel</xref>) something</p>
<p>something <xref ref-type="fig">Figure 1</xref>; and Figure 2<bold>, bottom panel)</bold> something</p>
<p>something <xref ref-type="table">Table 1, middle and lower</xref>;. Something</p>
<p><xref>Fig. 1Bc i</xref>, </p>
<p><xref>Fig5 E,F</xref>).</p>
<p><xref>Figure 4—figure supplement S4C and D</xref></p>
<p><xref>Figure 1A&amp;C</xref></p>
<p><xref>Fig. 3e- f</xref></p>
</sec>
5 changes: 5 additions & 0 deletions test/tests/preprint-changes/fix-truncated-xrefs/input.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@
<p>something <xref ref-type="fig">Figure 1</xref><bold>, bottom panel)</bold> something</p>
<p>something <xref ref-type="fig">Figure 1</xref>; and Figure 2<bold>, bottom panel)</bold> something</p>
<p>something <xref ref-type="table"><italic><bold>Table 1</bold></italic></xref><bold>, middle and lower;.</bold> Something</p>
<p><xref><bold>Fig. 1Bc</bold></xref><bold> i, </bold></p>
<p><xref>Fig5</xref><bold> E,F).</bold></p>
<p><xref>Figure 4—figure supplement S4C</xref><bold> and D</bold></p>
<p><xref><italic>Figure 1A</italic></xref><bold>&amp;C</bold></p>
<p><xref>Fig. 3e</xref><bold>- f</bold></p>
</sec>
5 changes: 5 additions & 0 deletions test/tests/preprint-changes/fix-truncated-xrefs/output.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@
<p>something <xref ref-type="fig">Figure 1, bottom panel</xref>) something</p>
<p>something <xref ref-type="fig">Figure 1</xref>; and Figure 2<bold>, bottom panel)</bold> something</p>
<p>something <xref ref-type="table">Table 1, middle and lower</xref>;. Something</p>
<p><xref>Fig. 1Bc i</xref>, </p>
<p><xref>Fig5 E,F</xref>).</p>
<p><xref>Figure 4—figure supplement S4C and D</xref></p>
<p><xref>Figure 1A&amp;C</xref></p>
<p><xref>Fig. 3e- f</xref></p>
</sec>

0 comments on commit be14a31

Please sign in to comment.