docbook-apps

  • 1.  Disabling hyphenation on selected strings

    Posted 05-06-2008 15:55
    I'd like to be able to mark arbitrary subsections of para elements as
    "non-hyphenatable", something like this:

    <para>Hyphenate anywhere here Do not hyphenate
    this text
    Hyphenate anywhere here</para>

    Is this possible?

    --
    You did not read the manual
    Our tech writer is sad
    Locked in the toilet, he is crying



  • 2.  Re: [docbook-apps] Disabling hyphenation on selected strings

    Posted 05-06-2008 16:48
    On Tue, May 6, 2008 at 8:54 AM, Andrew McFarland <aamcfarland@gmail.com> wrote:
    > I'd like to be able to mark arbitrary subsections of para elements as
    > "non-hyphenatable", something like this:
    >
    > <para>Hyphenate anywhere here Do not hyphenate
    > this text
    Hyphenate anywhere here</para>

    Hi,

    We use the <phrase> inline and a @role attribute behavior to implement
    this in our customization. You'll need to check on what works with
    your FO processor, but we add these two attributes to our current
    fo:inline when we hit a matching phrase:

    <xsl:attribute
    name="keep-together.within-line">always</xsl:attribute>
    <xsl:attribute name="hyphenate">false</xsl:attribute>


    HTH,
    Keith



  • 3.  Re: [docbook-apps] Disabling hyphenation on selected strings

    Posted 05-06-2008 21:11
    
    
    Andrew
    This works for me.  I was having trouble with URLs which got hyphenated and new lined.  For DB 4.5 remove the d: bits.  Messy but it seems to work OK with XEP.  I've never tested it with FOP, but it might work.  Early FOP has some problems with keep-together, possibly fixed by now.
    Ron


    <!-- ==================================================================== -->
    <!--
    Allow use of
      <phrase role="keep-together">qwerty</phrase>
    to prevent hyphenation and a line break within the phrase
     -->


    <xsl:template match="d:phrase[@role[contains(., 'keep-together')]]">
     
    <xsl:param name="no-hyphenate" select="false()"/>
     
    <xsl:param name="content">
       
    <xsl:apply-templates/>
     
    </xsl:param>
     
    <fo:inline xsl:use-attribute-sets="monospace.properties" font-family="{$body.font.family}">
       
    <xsl:if test="@role[contains(., 'keep-together')]">
         
    <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
         
    <xsl:attribute name="hyphenate">false</xsl:attribute>
       
    </xsl:if>
       
    <xsl:choose>
         
    <xsl:when test="$no-hyphenate">
           
    <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
           
    <xsl:attribute name="hyphenate">false</xsl:attribute>
         
    </xsl:when>
         
    <xsl:otherwise>
                
    <!-- this is a zero-width space to intentionally provoke an AntennaHouse bug.
                      The FO spec says that hyphenation-character can only be on fo:block and
                      fo:character, but having anything here provides the correct result. -->

           
    <xsl:attribute name="hyphenation-character">
             
    <xsl:value-of select="'&#x200B;'"/>
           
    </xsl:attribute>
         
    </xsl:otherwise>
       
    </xsl:choose>
       
    <xsl:choose>
         
    <xsl:when test="ancestor::d:footnote">
           
    <xsl:attribute name="font-size">85%</xsl:attribute>
         
    </xsl:when>
       
    </xsl:choose>
         
    <xsl:if test="@dir">
           
    <xsl:attribute name="direction">
             
    <xsl:choose>
               
    <xsl:when test="@dir = 'ltr' or @dir = 'lro'">ltr</xsl:when>
               
    <xsl:otherwise>rtl</xsl:otherwise>
             
    </xsl:choose>
           
    </xsl:attribute>
         
    </xsl:if>
       
    <xsl:copy-of select="$content"/>
     
    </fo:inline>
    </xsl:template>     <!-- END match="d:phrase[@role[contains(., 'keep-together')]]"  -->

    <!-- ==================================================================== -->

    I'd like to be able to mark arbitrary subsections of para elements as
    "non-hyphenatable", something like this:

    <para>Hyphenate anywhere here <span type="no-hyphens">Do not hyphenate
    this text</span> Hyphenate anywhere here</para>

    Is this possible?

    --
    You did not read the manual
    Our tech writer is sad
    Locked in the toilet, he is crying

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
    For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org


    Ron Catterall, Phd, DSc       email: ron@catterall.net
    Prolongacion de Hidalgo 140http://catterall.net/
    San Felipe del Aguatel: +52 951 520 1821
    Oaxaca      68020Mexicofax: +1 530 348 8309