]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Improve tokenizing of linkable terms
authorPhilipp Hahn <hahn@univention.de>
Thu, 11 Aug 2011 12:44:00 +0000 (14:44 +0200)
committerEric Blake <eblake@redhat.com>
Fri, 12 Aug 2011 13:35:19 +0000 (07:35 -0600)
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>
docs/newapi.xsl

index 445a48c796794118147de1d98e377d00f0d88520..6e1c646703a805923ec6fde9433c939b79d5ab5f 100644 (file)
        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>