Bug 184606

Summary: Translation of dashes in PDF version
Product: Documentation Reporter: Carlo Strub <cs>
Component: Books & ArticlesAssignee: Gabor Kovesdan <gabor>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description Carlo Strub freebsd_committer freebsd_triage 2013-12-08 20:30:00 UTC
There seems to be a bug in the generator for the PDF version with regard
to hyphens/dashes in code. For example in the DVD section it says:

# growisofs -dvd-compat -Z /dev/cd0=imagefile.iso


However, in the PDF version, we get

# growisofs --dvd-compat --Z -/dev/cd0=imagefile.iso
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2013-12-08 23:42:02 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-doc

reclassify.
Comment 2 dfilter service freebsd_committer freebsd_triage 2014-01-22 14:34:16 UTC
Author: gabor
Date: Wed Jan 22 14:34:08 2014
New Revision: 43630
URL: http://svnweb.freebsd.org/changeset/doc/43630

Log:
  - Line wrap indicators are rendered in the verbatim texts with the help
    of soft hyphens. However, FOP does not handle well soft hyphens when placed
    after certain characters. Apply a workaround for this.
  
  PR:		docs/184606
  Submitted by:	cs

Modified:
  head/share/xml/freebsd-fo.xsl

Modified: head/share/xml/freebsd-fo.xsl
==============================================================================
--- head/share/xml/freebsd-fo.xsl	Wed Jan 22 12:13:12 2014	(r43629)
+++ head/share/xml/freebsd-fo.xsl	Wed Jan 22 14:34:08 2014	(r43630)
@@ -513,6 +513,51 @@
   <!-- Suppress list titles -->
   <xsl:template match="db:title" mode="list.title.mode"/>
 
+  <!-- Soft-hyphen workaround for verbatim hyphenation -->
+  <xsl:template name="hyphenate.verbatim">
+    <xsl:param name="content"/>
+    <xsl:variable name="apos" select='"&apos;"'/>
+    <xsl:variable name="head" select="substring($content, 1, 1)"/>
+    <xsl:variable name="tail" select="substring($content, 2)"/>
+    <xsl:variable name="next" select="substring($tail, 1, 1)"/>
+    <xsl:choose>
+      <!-- Place soft-hyphen after space or non-breakable space. -->
+      <xsl:when test="$next = '&#xA;' or $next = '' or $next = '&quot;' or
+	$next = '.' or $next = ',' or $next = '-' or $next = '/' or
+	$next = $apos or $next = ':' or $next = '!' or $next = '|' or
+	$next = '?' or $next = ')'">
+	<xsl:value-of select="$head"/>
+      </xsl:when>
+      <xsl:when test="($head = ' ' or $head = '&#160;') and $next != '.' and
+	$next != '}' and $next != ' ' and $next != '&#160;'">
+	<xsl:text>&#160;</xsl:text>
+	<xsl:text>&#x00AD;</xsl:text>
+      </xsl:when>
+      <xsl:when test="$head = '.' and translate($next, '0123456789', '') != ''">
+	<xsl:text>.</xsl:text>
+	<xsl:text>&#x00AD;</xsl:text>
+      </xsl:when>
+      <xsl:when test="$hyphenate.verbatim.characters != '' and
+	translate($head, $hyphenate.verbatim.characters, '') = '' and
+	translate($next, $hyphenate.verbatim.characters, '') != ''">
+	<xsl:value-of select="$head"/>
+	<xsl:text>&#x00AD;</xsl:text>
+      </xsl:when>
+      <xsl:when test="$next = '('">
+	<xsl:value-of select="$head"/>
+	<xsl:text>&#x00AD;</xsl:text>
+      </xsl:when>
+      <xsl:otherwise>
+	<xsl:value-of select="$head"/>
+      </xsl:otherwise>
+    </xsl:choose>
+    <xsl:if test="$tail">
+      <xsl:call-template name="hyphenate.verbatim">
+	<xsl:with-param name="content" select="$tail"/>
+      </xsl:call-template>
+    </xsl:if>
+  </xsl:template>
+
 <!--
 	TITLEPAGE TEMPLATES
 -->
_______________________________________________
svn-doc-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-doc-all
To unsubscribe, send any mail to "svn-doc-all-unsubscribe@freebsd.org"
Comment 3 Gabor Kovesdan freebsd_committer freebsd_triage 2014-01-22 14:35:12 UTC
State Changed
From-To: open->closed

Fixed, thanks! 


Comment 4 Gabor Kovesdan freebsd_committer freebsd_triage 2014-01-22 14:35:12 UTC
Responsible Changed
From-To: freebsd-doc->gabor

Fixed, thanks!