Skip to content

Commit

Permalink
RP XSL - handle <i> tags
Browse files Browse the repository at this point in the history
  • Loading branch information
fred-atherden committed Dec 16, 2024
1 parent b6e475a commit 9139eb0
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/preprint-changes.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,20 @@
|italic[bold[xref]]">
<xsl:apply-templates select="*|text()|comment()|processing-instruction()"/>
</xsl:template>

<!-- Strip or convert HTML <i> tags -->
<xsl:template xml:id="strip-i-tags" match="i">
<xsl:choose>
<xsl:when test="ancestor::italic">
<xsl:apply-templates select="*|text()|comment()|processing-instruction()"/>
</xsl:when>
<xsl:otherwise>
<xsl:element name="italic">
<xsl:apply-templates select="*|text()|comment()|processing-instruction()"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<!-- Strip unnecessary bolding and italicisation above citations -->
<xsl:template xml:id="strip-bold-italic-from-above-xref" match="bold[xref]|italic[xref]">
Expand Down
2 changes: 2 additions & 0 deletions test/tests/preprint-changes/all/input.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@
</sec>
<sec id="s3">
<title>MATERIALS &amp; METHODS</title>
<p><italic><bold><i>some text</i></bold></italic></p>
<p><i>ital<bold>ics</bold></i></p>
</sec>
</body>
<back>
Expand Down
2 changes: 2 additions & 0 deletions test/tests/preprint-changes/all/output.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@
</sec>
<sec id="s3">
<title>Materials &amp; methods</title>
<p><italic><bold>some text</bold></italic></p>
<p><italic>ital<bold>ics</bold></italic></p>
</sec>
</body>
<back>
Expand Down
5 changes: 5 additions & 0 deletions test/tests/preprint-changes/strip-i-tags/input.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!--Testing template with id: strip-i-tags-->
<sec id="s3">
<p><italic><bold><i>some text</i></bold></italic></p>
<p><i>ital<bold>ics</bold></i></p>
</sec>
5 changes: 5 additions & 0 deletions test/tests/preprint-changes/strip-i-tags/output.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!--Testing template with id: strip-i-tags-->
<sec id="s3">
<p><italic><bold>some text</bold></italic></p>
<p><italic>ital<bold>ics</bold></italic></p>
</sec>
1 change: 1 addition & 0 deletions test/xspec/countries.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<country country="IS">Iceland</country>
<country country="IN">India</country>
<country country="ID">Indonesia</country>
<country country="IR">Iran</country>
<country country="IR">Islamic Republic of Iran</country>
<country country="IQ">Iraq</country>
<country country="IE">Ireland</country>
Expand Down
4 changes: 4 additions & 0 deletions test/xspec/preprint-changes.xspec
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@
<x:context href="../tests/preprint-changes/strip-bold-italic-around-xref/input.xml"/>
<x:expect label="Testing the template: strip-bold-italic-around-xref" href="../tests/preprint-changes/strip-bold-italic-around-xref/output.xml"/>
</x:scenario>
<x:scenario label="strip-i-tags">
<x:context href="../tests/preprint-changes/strip-i-tags/input.xml"/>
<x:expect label="Testing the template: strip-i-tags" href="../tests/preprint-changes/strip-i-tags/output.xml"/>
</x:scenario>
<x:scenario label="strip-bold-italic-from-above-xref">
<x:context href="../tests/preprint-changes/strip-bold-italic-from-above-xref/input.xml"/>
<x:expect label="Testing the template: strip-bold-italic-from-above-xref" href="../tests/preprint-changes/strip-bold-italic-from-above-xref/output.xml"/>
Expand Down

0 comments on commit 9139eb0

Please sign in to comment.