Improve tokenizing of linkable terms

Currently only tabs and blanks are used for tokenizing the description,
which breaks when a term is at the end of a line or has () appended to
it.
1. Use also other white space characters such as new-lines and carriage
   return for splitting.
2. Remove some common non-word characters from the token before lookup.

Signed-off-by: Philipp Hahn <hahn@univention.de>
This commit is contained in:
Philipp Hahn 2011-08-11 14:44:00 +02:00 committed by Eric Blake
parent 977ba05973
commit ce7244a014

View File

@ -54,10 +54,13 @@
because the keys are only defined on the main document -->
<xsl:template mode="dumptoken" match='*'>
<xsl:param name="token"/>
<xsl:variable name="ref" select="key('symbols', $token)"/>
<xsl:variable name="stem" select="translate($token, '(),.:;@', '')"/>
<xsl:variable name="ref" select="key('symbols', $stem)"/>
<xsl:choose>
<xsl:when test="$ref">
<a href="libvirt-{$ref/@file}.html#{$ref/@name}"><xsl:value-of select="$token"/></a>
<xsl:value-of select="substring-before($token, $stem)"/>
<a href="libvirt-{$ref/@file}.html#{$ref/@name}"><xsl:value-of select="$stem"/></a>
<xsl:value-of select="substring-after($token, $stem)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$token"/>
@ -70,7 +73,7 @@
<xsl:param name="text"/>
<xsl:variable name="ctxt" select='.'/>
<!-- <xsl:value-of select="$text"/> -->
<xsl:for-each select="str:tokenize($text, ' &#9;')">
<xsl:for-each select="str:tokenize($text, ' &#9;&#10;&#13;')">
<xsl:apply-templates select="$ctxt" mode='dumptoken'>
<xsl:with-param name="token" select="string(.)"/>
</xsl:apply-templates>