Skip to content

Commit

Permalink
JSON-LD: Remove quotes in headlines & descriptions
Browse files Browse the repository at this point in the history
If a text contains "quotes", this text will create a syntax error
for JSON. Either the quotes need to be masked or removed.
I decided to remove them with translate().
  • Loading branch information
tomschr committed Aug 11, 2023
1 parent 0d4331c commit c6cc942
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions suse2022-ns/xhtml/json-ld.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@

<xsl:template name="json-ld-headline">
<xsl:param name="node" select="."/>
<xsl:variable name="headline" select="($node/d:info/d:meta[@name='title'] | $node/d:info/d:title | $node/d:title)[last()]"/>
"headline": "<xsl:value-of select="normalize-space($headline)"/>",
<xsl:variable name="headline" select="normalize-space(($node/d:info/d:meta[@name='title'] | $node/d:info/d:title | $node/d:title)[last()])"/>
"headline": "<xsl:value-of select="translate($headline, '&quot;', '')"/>",
</xsl:template>

<xsl:template name="json-ld-description">
Expand Down Expand Up @@ -121,7 +121,7 @@
</xsl:variable>

<xsl:if test="$description != ''">
"description": "<xsl:value-of select="$description"/>",
"description": "<xsl:value-of select="translate($description, '&quot;', '')"/>",
</xsl:if>
</xsl:template>

Expand Down

0 comments on commit c6cc942

Please sign in to comment.