Re: [xep-support] hyphenating on special characters

From: Jirka Kosek <jirka@kosek.cz>
Date: Tue Nov 02 2004 - 10:05:04 PST

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 (&#x00AD;) 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@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/
------------------------------------------------------------------

-------------------
(*) To unsubscribe, send a message with words 'unsubscribe xep-support'
in the body of the message to majordomo@renderx.com from the address
you are subscribed from.
(*) By using the Service, you expressly agree to these Terms of Service http://www.renderx.com/tos.html

Received on Tue Nov 2 10:53:22 2004

This archive was generated by hypermail 2.1.8 : Tue Nov 02 2004 - 10:53:23 PST