Skip to content

Commit

Permalink
Fix missing newlines in src/items-to-csv.xslt.
Browse files Browse the repository at this point in the history
The GitHub Action`.github/workflows/pages-deploy.yaml` is set to use
`ubuntu-latest`, which was Ubuntu 18.04 for the initial release and
Ubuntu 20.04 as of the last commit 954cc5d (90ff811). For the most recent
build cd7ac80 (bba081f), `ubuntu-latest` points to Ubuntu 22.04.

tdewolff/minify@200330f7 (first in v2.6.0) made it so that `minify`
automatically expands any character entities in the input XML.
Unfortunately, due to XML attribute whitespace normalization, a newline
in an attribute is processed as a space. Ubuntu 20.04 contains
`minify` v2.5.2 while Ubuntu 22.04 contains `minify` v2.9.22, so the
recent upgrade caused the issue to appear.

To fix this, we'll use `<xsl:text>` elements instead of a `$variable`
since elements use less aggressive whitespace normalization than
attributes. We still need to use a character entity plus a trailing
space though to prevent the minifier + normalization combo from deleting
the newline.

Thanks to @WoodlandSkipper for tracking down the issue in the comments
of #5.
  • Loading branch information
gucci-on-fleek committed Apr 21, 2024
1 parent cd7ac80 commit 3b73728
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/items-to-csv.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
<!-- Stardew Valley Item Finder
https://gucci-on-fleek.github.io/Stardew-Valley-Item-Finder/
SPDX-License-Identifier: MPL-2.0+
SPDX-FileCopyrightText: 2022 Max Chernoff
SPDX-FileCopyrightText: 2024 Max Chernoff
-->
<xsl:output method="text" encoding="utf-8" />

<xsl:variable name="col_sep" select="','" />
<xsl:variable name="quote" select="''" />
<xsl:variable name="row_sep" select="'&#xA;'" />

<xsl:template match="/items">
<xsl:value-of select="concat($quote, 'Item Name', $quote, $col_sep)" />
<xsl:value-of select="concat($quote, 'Quality', $quote, $col_sep)" />
<xsl:value-of select="concat($quote, 'Price', $quote, $col_sep)" />
<xsl:value-of select="concat($quote, 'Count', $quote, $col_sep)" />
<xsl:value-of select="concat($quote, 'Stored in', $quote, $col_sep)" />
<xsl:value-of select="concat($quote, 'Stack Price', $quote, $row_sep)" />
<xsl:value-of select="concat($quote, 'Stack Price', $quote)" />
<xsl:text>&#xA; </xsl:text>

<xsl:for-each select="item">
<xsl:sort select="actual_price * count" data-type="number" order="descending" />
Expand Down Expand Up @@ -48,7 +48,7 @@
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="concat($quote, actual_price * count, $quote)" />
<xsl:value-of select="$row_sep" />
<xsl:text>&#xA; </xsl:text>
</xsl:for-each>
</xsl:template>

Expand Down

0 comments on commit 3b73728

Please sign in to comment.