]> granicus.if.org Git - docbook-dsssl/commitdiff
Provide option to allow URLs to be conditionally hyphenated
authorNorman Walsh <ndw@nwalsh.com>
Mon, 28 Jan 2002 16:13:09 +0000 (16:13 +0000)
committerNorman Walsh <ndw@nwalsh.com>
Mon, 28 Jan 2002 16:13:09 +0000 (16:13 +0000)
xsl/fo/param.ent
xsl/fo/param.xweb
xsl/fo/xref.xsl
xsl/params/ulink.hyphenate.xml [new file with mode: 0644]

index c187d1382150937e23c0792d7f4e478c205d1b9a..69e870864c71d77068c258d7ccda4d9fe189e654 100644 (file)
 <!ENTITY toc.section.depth SYSTEM "../params/toc.section.depth.xml">
 <!ENTITY use.extensions SYSTEM "../params/use.extensions.xml">
 <!ENTITY ulink.footnotes SYSTEM "../params/ulink.footnotes.xml">
+<!ENTITY ulink.hyphenate SYSTEM "../params/ulink.hyphenate.xml">
 <!ENTITY ulink.show SYSTEM "../params/ulink.show.xml">
 <!ENTITY variablelist.as.blocks SYSTEM "../params/variablelist.as.blocks.xml">
 <!ENTITY verbatim.properties SYSTEM "../params/verbatim.properties.xml">
index 3c9d72adb37cdb983f9b284f957f93c21be7687b..0900f64c29ed0801a5cbca48874a5bde3eda9fd2 100644 (file)
@@ -188,6 +188,7 @@ to be incomplete. Don't forget to read the source, too :-)</para>
 &blockquote.properties;
 &ulink.show;
 &ulink.footnotes;
+&ulink.hyphenate;
 </reference>
 
 <reference><title>FO</title>
@@ -467,6 +468,7 @@ around all these parameters.</para>
 <src:fragref linkend="toc.section.depth.frag"/>
 <src:fragref linkend="use.extensions.frag"/>
 <src:fragref linkend="ulink.footnotes.frag"/>
+<src:fragref linkend="ulink.hyphenate.frag"/>
 <src:fragref linkend="ulink.show.frag"/>
 <src:fragref linkend="variablelist.as.blocks.frag"/>
 <src:fragref linkend="verbatim.properties.frag"/>
index 49754d44e7ee41d8805745cfbde1c3dbc0aadaff..3023c0c078d2e05d814eadba947b6fecb2b93c9c 100644 (file)
                  xsl:use-attribute-sets="xref.properties">
     <xsl:choose>
       <xsl:when test="count(child::node())=0">
-       <xsl:value-of select="@url"/>
+        <xsl:call-template name="hyphenate-url">
+          <xsl:with-param name="url" select="@url"/>
+        </xsl:call-template>
       </xsl:when>
       <xsl:otherwise>
        <xsl:apply-templates/>
                 and $ulink.show != 0">
     <fo:inline hyphenate="false">
       <xsl:text> [</xsl:text>
-      <xsl:value-of select="@url"/>
+      <xsl:call-template name="hyphenate-url">
+        <xsl:with-param name="url" select="@url"/>
+      </xsl:call-template>
       <xsl:text>]</xsl:text>
     </fo:inline>
   </xsl:if>
 </xsl:template>
 
+<xsl:template name="hyphenate-url">
+  <xsl:param name="url" select="''"/>
+  <xsl:choose>
+    <xsl:when test="$ulink.hyphenate = ''">
+      <xsl:value-of select="$url"/>
+    </xsl:when>
+    <xsl:when test="contains($url, '/')">
+      <xsl:value-of select="substring-before($url, '/')"/>
+      <xsl:text>/</xsl:text>
+      <xsl:copy-of select="$ulink.hyphenate"/>
+      <xsl:call-template name="hyphenate-url">
+        <xsl:with-param name="url" select="substring-after($url, '/')"/>
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:value-of select="$url"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
 <xsl:template match="olink" name="olink">
   <xsl:apply-templates/>
 </xsl:template>
diff --git a/xsl/params/ulink.hyphenate.xml b/xsl/params/ulink.hyphenate.xml
new file mode 100644 (file)
index 0000000..0fc56f4
--- /dev/null
@@ -0,0 +1,28 @@
+<refentry id="ulink.hyphenate">
+<refmeta>
+<refentrytitle>ulink.hyphenate</refentrytitle>
+<refmiscinfo role="type">string</refmiscinfo>
+</refmeta>
+<refnamediv>
+<refname>ulink.hyphenate</refname>
+<refpurpose>Allow URLs to be automatically hyphenated</refpurpose>
+</refnamediv>
+
+<refsynopsisdiv>
+<src:fragment id='ulink.hyphenate.frag'>
+<xsl:param name="ulink.hyphenate" select="'&#xAD;'"/>
+</src:fragment>
+</refsynopsisdiv>
+
+<refsect1><title>Description</title>
+
+<para>If not empty, the specified character (or more generally, content) is
+added to URLs after every <quote>/</quote>. If the character specified is a
+Unicode soft hyphen (0x00AD) or Unicode zero-width space (0x200B), some FO
+processors will be able to reasonably hyphenate long URLs.</para>
+
+<para>As of 28 Jan 2002, discretionary hyphens are more widely and correctly
+supported than zero-width spaces for this purpose.</para>
+
+</refsect1>
+</refentry>