Skip to content

Commit

Permalink
Make sure mixed emphasis words are kept together
Browse files Browse the repository at this point in the history
or generally do not split words at inline element boundaries

e.g. CO<sup>2</sup> will become CO2

This is useless in the dictionary as liblouis translates each node
separately, i.e. translates 'CO' and '2' separately. So there is no
real point in adding CO2 to the dictionary.

OTOH there is also no point in putting the separate words 'CO' and '2'
in the dictionary, as the actual string that is sent to liblouis in
this case of mixed emphasis contains additional characters. So putting
the separate words in the dictionary has also no effect.

The best would probably be to not show mixed emphasis words in the
dictionary altogether.
  • Loading branch information
egli committed Jan 22, 2025
1 parent a6618a9 commit 9084831
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion resources/xslt/to_string.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,20 @@

<xsl:output method="text" encoding="utf-8" indent="no" />

<!-- Inline elements do not need any spacing -->
<xsl:template match="dtb:em|dtb:strong|dtb:span|dtb:sub|dtb:sup">
<xsl:apply-templates/>
</xsl:template>

<!-- Add some spacing to (block) elements to avoid words getting glued together -->
<xsl:template match="element()">
<xsl:value-of select="' '"/>
<xsl:apply-templates/>
<xsl:value-of select="' '"/>
</xsl:template>

<xsl:template match="text()">
<xsl:value-of select="concat(' ', string(.), ' ')"/>
<xsl:value-of select="string(.)"/>
</xsl:template>

</xsl:stylesheet>

0 comments on commit 9084831

Please sign in to comment.