[xep-support] hyphenating on special characters

Jirka Kosek jirka at kosek.cz
Tue Nov 2 10:05:04 PST 2004


Konrad Rokicki wrote:

> I was wondering if there is any way to tell XEP what characters to
> hyphenate on? I don't want any hyphenation on regular words, so I've
> set hyphenate to false. But I've got some long ids like
> very_long_word_that_should_be_broken_on_underscores_if_needed
> And I would like that to wrap if it doesn't fit, rather than render
> the letters on top of each other.

You can do this by adding soft-hyphen (­) after each character on 
which break can occur. You can add such characters automatically to your 
FO output by XSLT. E.g.:

<xsl:template match="text()">
   <xsl:call-template name="hyphenate">
     <xsl:with-param name="content" select="."/>
   </xsl:call-template>
</xsl:template>

<xsl:template name="hyphenate">
   <xsl:param name="content"/>
   <xsl:variable name="head" select="substring($content, 1, 1)"/>
   <xsl:variable name="tail" select="substring($content, 2)"/>
   <xsl:value-of select="$head"/>
   <!-- Place soft-hyphen after selected characters -->
   <xsl:if test="$head = '/' or $head = '_'">
      <xsl:text>&#x00AD;</xsl:text>
   </xsl:if>
   <xsl:if test="$tail">
     <xsl:call-template name="hyphenate">
       <xsl:with-param name="content" select="$tail"/>
     </xsl:call-template>
   </xsl:if>
</xsl:template>

-- 
------------------------------------------------------------------
   Jirka Kosek     e-mail: jirka at kosek.cz     http://www.kosek.cz
------------------------------------------------------------------
   Profesionální školení a poradenství v oblasti technologií XML.
      Podívejte se na náš nově spuštěný web http://DocBook.cz
        Podrobný přehled školení http://xmlguru.cz/skoleni/
------------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3158 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.renderx.com/pipermail/xep-support/attachments/20041102/0aedc747/attachment.bin>


More information about the Xep-support mailing list