Skip to content

Commit

Permalink
Tweak supp file captions (#158)
Browse files Browse the repository at this point in the history
* Add xsl to introduce label into content surfaced for supp files

* Add docs

* update kitchen sink fixture

to include various iterations of supplementary files

* correct filename/heading in docs

* update text cases

* typos in docs
  • Loading branch information
fred-atherden authored Jan 17, 2025
1 parent f0d638c commit e9e1190
Show file tree
Hide file tree
Showing 25 changed files with 1,522 additions and 22 deletions.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,46 @@ The output in Encoda is missing the link:

Since `related-object` can be used in numerous places, this xsl replaces the element with a hyperlink (`<ext-link>`) and if necessary moves it to a different locaiton in the text so that it can be surfaced by EPP.

### [/src/supplementary-materials-label.xsl](/src/supplementary-materials-label.xsl)

This xslt introduces the labels for `<supplementary-material>` into the (title within the) caption. If there is no existing caption with a title, then one is created for the purposes of surfacing the label in EPP.

This is a workaround until the Encoda JSON output can be improved to surface all content within labels and captions for supplementary material, currently captured in this ticket: https://github.com/elifesciences/enhanced-preprints-issues/issues/1233. Once that ticket is complete, this XSLT can be removed.

At time of writing, for an `object.type == "Link"` EPP will surface the `.content` (and `.target`) in the HTML (`.title` appears to be unhandled, but this where Encoda outputs the label).

As a result of this xslt, the encoda output changes from, for example:
```json
{
"type": "Link",
"target": "supplements/562203_file05.pdf",
"title": "This is the label",
"content": [
"This is the title",
"This is the caption"
]
}
```

to:
```json
{
"type": "Link",
"target": "supplements/562203_file05.pdf",
"title": "This is the label",
"content": [
{
"type": "Strong",
"content": [
"This is the label. "
]
},
"This is the title",
"This is the caption"
]
}
```

# Modify bioRxiv XML in preparation for Encoda

Prerequisites:
Expand Down
59 changes: 59 additions & 0 deletions src/supplementary-materials-label.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xlink="http://www.w3.org/1999/xlink"
exclude-result-prefixes="xs"
version="3.0">

<xsl:output method="xml" encoding="UTF-8"/>

<xsl:template match="*|@*|text()|comment()|processing-instruction()">
<xsl:copy>
<xsl:apply-templates select="*|@*|text()|comment()|processing-instruction()"/>
</xsl:copy>
</xsl:template>

<!-- Introduce a caption so that we can surface the label -->
<xsl:template match="supplementary-material[label and not(caption[title or p])]">
<xsl:copy>
<xsl:apply-templates select="@*|label|label/preceding-sibling::text()"/>
<xsl:text>&#xa;</xsl:text>
<xsl:element name="caption">
<xsl:element name="title">
<xsl:element name="bold">
<xsl:apply-templates select="./label[1]/(*|text())"/>
</xsl:element>
</xsl:element>
</xsl:element>
<xsl:apply-templates select="*[name()!='label']|text()|comment()|processing-instruction()"/>
</xsl:copy>
</xsl:template>

<!-- Introduce the label into the existing caption -->
<xsl:template match="supplementary-material[label and caption[title or p]]">
<xsl:copy>
<xsl:apply-templates select="@*|label|label/preceding-sibling::text()"/>
<xsl:text>&#xa;</xsl:text>
<xsl:element name="caption">
<xsl:element name="title">
<xsl:element name="bold">
<xsl:apply-templates select="./label[1]/(*|text())"/>
<!-- If it doesn't end with punctuation then add some, otherwise just a space -->
<xsl:choose>
<xsl:when test="not(matches([label[1]],'\p{P}$'))">
<xsl:text>. </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
<xsl:apply-templates select="caption/title/(*|text())"/>
</xsl:element>
<xsl:apply-templates select="caption/p|caption/title/following-sibling::text()"/>
</xsl:element>
<xsl:apply-templates select="*[not(name()=('label','caption'))]|caption/following-sibling::text()|comment()|processing-instruction()"/>
</xsl:copy>
</xsl:template>


</xsl:stylesheet>
27 changes: 26 additions & 1 deletion test/boxed-text-workaround/kitchen-sink.xml
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,34 @@ return :shrug:
<sec sec-type="supplementary-material">
<title>Supporting information</title>
<supplementary-material>
<label>Supplemental figures</label>
<label>Supp file 1</label>
<media xlink:href="supplements/468444_file02.pdf"/>
</supplementary-material>
<supplementary-material>
<label>Supp file 2</label>
<caption>
<p>This is a para.</p>
</caption>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
<supplementary-material>
<label>Supp file 3</label>
<caption>
<title>This is a title</title>
<p>This is a para.</p>
</caption>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
<supplementary-material>
<label>Supp file 4.</label>
<caption>
<title>This is a title</title>
</caption>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
<supplementary-material>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
</sec>
</body>
<back>
Expand Down
27 changes: 26 additions & 1 deletion test/change-label-and-title-elements/kitchen-sink.xml
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,34 @@ return :shrug:
<sec sec-type="supplementary-material">
<title>Supporting information</title>
<supplementary-material>
<label>Supplemental figures</label>
<label>Supp file 1</label>
<media xlink:href="supplements/468444_file02.pdf"/>
</supplementary-material>
<supplementary-material>
<label>Supp file 2</label>
<caption>
<p>This is a para.</p>
</caption>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
<supplementary-material>
<label>Supp file 3</label>
<caption>
<title>This is a title</title>
<p>This is a para.</p>
</caption>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
<supplementary-material>
<label>Supp file 4.</label>
<caption>
<title>This is a title</title>
</caption>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
<supplementary-material>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
</sec>
</body>
<back>
Expand Down
27 changes: 26 additions & 1 deletion test/code-workaround/kitchen-sink.xml
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,34 @@ return :shrug:
<sec sec-type="supplementary-material">
<title>Supporting information</title>
<supplementary-material>
<label>Supplemental figures</label>
<label>Supp file 1</label>
<media xlink:href="supplements/468444_file02.pdf"/>
</supplementary-material>
<supplementary-material>
<label>Supp file 2</label>
<caption>
<p>This is a para.</p>
</caption>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
<supplementary-material>
<label>Supp file 3</label>
<caption>
<title>This is a title</title>
<p>This is a para.</p>
</caption>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
<supplementary-material>
<label>Supp file 4.</label>
<caption>
<title>This is a title</title>
</caption>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
<supplementary-material>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
</sec>
</body>
<back>
Expand Down
27 changes: 26 additions & 1 deletion test/collate-reference-lists/kitchen-sink.xml
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,34 @@ return :shrug:
<sec sec-type="supplementary-material">
<title>Supporting information</title>
<supplementary-material>
<label>Supplemental figures</label>
<label>Supp file 1</label>
<media xlink:href="supplements/468444_file02.pdf"/>
</supplementary-material>
<supplementary-material>
<label>Supp file 2</label>
<caption>
<p>This is a para.</p>
</caption>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
<supplementary-material>
<label>Supp file 3</label>
<caption>
<title>This is a title</title>
<p>This is a para.</p>
</caption>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
<supplementary-material>
<label>Supp file 4.</label>
<caption>
<title>This is a title</title>
</caption>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
<supplementary-material>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
</sec>
</body>
<back>
Expand Down
27 changes: 26 additions & 1 deletion test/conf-ref-workaround/kitchen-sink.xml
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,34 @@ return :shrug:
<sec sec-type="supplementary-material">
<title>Supporting information</title>
<supplementary-material>
<label>Supplemental figures</label>
<label>Supp file 1</label>
<media xlink:href="supplements/468444_file02.pdf"/>
</supplementary-material>
<supplementary-material>
<label>Supp file 2</label>
<caption>
<p>This is a para.</p>
</caption>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
<supplementary-material>
<label>Supp file 3</label>
<caption>
<title>This is a title</title>
<p>This is a para.</p>
</caption>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
<supplementary-material>
<label>Supp file 4.</label>
<caption>
<title>This is a title</title>
</caption>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
<supplementary-material>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
</sec>
</body>
<back>
Expand Down
27 changes: 26 additions & 1 deletion test/convert-doi-links-to-pub-id-elements/kitchen-sink.xml
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,34 @@ return :shrug:
<sec sec-type="supplementary-material">
<title>Supporting information</title>
<supplementary-material>
<label>Supplemental figures</label>
<label>Supp file 1</label>
<media xlink:href="supplements/468444_file02.pdf"/>
</supplementary-material>
<supplementary-material>
<label>Supp file 2</label>
<caption>
<p>This is a para.</p>
</caption>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
<supplementary-material>
<label>Supp file 3</label>
<caption>
<title>This is a title</title>
<p>This is a para.</p>
</caption>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
<supplementary-material>
<label>Supp file 4.</label>
<caption>
<title>This is a title</title>
</caption>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
<supplementary-material>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
</sec>
</body>
<back>
Expand Down
27 changes: 26 additions & 1 deletion test/convert-glossaries/kitchen-sink.xml
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,34 @@ return :shrug:
<sec sec-type="supplementary-material">
<title>Supporting information</title>
<supplementary-material>
<label>Supplemental figures</label>
<label>Supp file 1</label>
<media xlink:href="supplements/468444_file02.pdf"/>
</supplementary-material>
<supplementary-material>
<label>Supp file 2</label>
<caption>
<p>This is a para.</p>
</caption>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
<supplementary-material>
<label>Supp file 3</label>
<caption>
<title>This is a title</title>
<p>This is a para.</p>
</caption>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
<supplementary-material>
<label>Supp file 4.</label>
<caption>
<title>This is a title</title>
</caption>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
<supplementary-material>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
</sec>
</body>
<back>
Expand Down
27 changes: 26 additions & 1 deletion test/disp-quote-workaround/kitchen-sink.xml
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,34 @@ return :shrug:
<sec sec-type="supplementary-material">
<title>Supporting information</title>
<supplementary-material>
<label>Supplemental figures</label>
<label>Supp file 1</label>
<media xlink:href="supplements/468444_file02.pdf"/>
</supplementary-material>
<supplementary-material>
<label>Supp file 2</label>
<caption>
<p>This is a para.</p>
</caption>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
<supplementary-material>
<label>Supp file 3</label>
<caption>
<title>This is a title</title>
<p>This is a para.</p>
</caption>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
<supplementary-material>
<label>Supp file 4.</label>
<caption>
<title>This is a title</title>
</caption>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
<supplementary-material>
<media xlink:href="supplements/468444_file03.pdf"/>
</supplementary-material>
</sec>
</body>
<back>
Expand Down
Loading

0 comments on commit e9e1190

Please sign in to comment.