You have URLs or paths which you want to hyphenate correctly. The URLs have to break on slashes or other characters only, but not between words.
The hyphenation of URLs in the DocBook stylesheets are
controlled by two parameters: ulink.hyphenate
and ulink.hyphenate.chars
. The first
parameter, if not empty, turns on hyphenation. Specify a
hyphenation character, usually either a Unicode soft hyphen
(U+00AD) or a Unicode zero-width space (U+200B).
The second parameter,
ulink.hyphenate.chars
, let you define
your allowable hyphenation points. The default value is a slash
(/), but URLs can contain more characters where it is desirable to
hyphenate. For this reason, the DocBook parameter reference recommends the
following value:
<xsl:param name="ulink.hyphenate.chars">:/@&?.#</xsl:param
The easiest way is to set the parameters
ulink.hyphenate.chars
and
ulink.hyphenate
to the values showed in
the last section and be happy. However, for professional needs,
this is not enough. The parameters and embedded algorithm
do not take into account protocols, for example http
. Protocols begin with
the schema followed by ://
as in
http://
. In some situations (although
rare), a hyphenation can occur between the double slashes or before
the colon. Furthermore, according to the Chicago
Manual of Style, it is desirable to distinguish
characters before and
after the hyphenation takes place.
All these requirements are implemented in the stylesheet showed in
Example 4.1, “hyphenate-url.xsl
”. It cuts off the protocol
with its ://
and iterates through each
characters and checks, if a hyphenation point needs to be inserted
before or after it.
Include the above stylesheet into your customization layer with additionally the following parameters:
<!-- Insert breakpoint /before/ the following characters: --> <xsl:param name="ulink.hyphenate.before.chars" >.,%?&#\-+{_</xsl:param> <!-- Insert breakpoint /after/ the following characters: --> <xsl:param name="ulink.hyphenate.after.chars" >/:@=};</xsl:param>
Project@GitHub | Issue#9 |