Disabling hyphenation in DocBook

When you are using the chain “DocBook -> FO -> PDF”, it is the FO processor that decides on the hyphenation of your words. This is because it knows the lengths of the lines it is making.

In FOP, hyphenation can only be turned on and off at the level of <fo:blocks>. For some dumb reason, DocBook doesn’t have a way to turn off hyphenation in one region of the document.

Here’s a way to add a hyphenate flag onto the DocBook <para> tag:

  <!-- make it possible to turn off hyphenation when it's giving us probs -->
  <xsl:template match="para[@hyphenate='false']">
    <fo:block hyphenate="false" xsl:use-attribute-sets="normal.para.spacing">
      <xsl:call-template name="anchor"/>

Put that into your customization stylesheet. Most of that garbage is copied from block.xsl in the DocBook stylesheets. The key is the selector, which makes this template fire if and only if you have a para that looks like this: <para hyphenate=”false”>.

Happy non-hyphenation!


One response to “Disabling hyphenation in DocBook”

  1. Documentation Template…

    Purpose This template gives the initial structure of each Assentis related document that is written in docbook…….

Leave a Reply

Your email address will not be published. Required fields are marked *