Topics

Word wrapping in tables for PDF #PDF #tables

Zoë Lawson
 

Greetings!

Somewhere I found the fun and exciting workaround for word wrapping in tables where you insert zero width spaces between camel-case letters, before _ . , : etc. 
I did this for “code” type elements, since that’s where most of the “non-traditional hyphenation” stuff comes in. It’s working reasonably well. 

Of course, now I have a xref to a topic with a camel-cased word in the title, and it’s not word-wrapping. The camel-cased word is in a paramname, which has the zero space shenanigans, but the paramname is not getting carried along to the xref text. 

What’s the best way to approach this?
Add word wrapping shenanigans to all xref?
Try to get the paramname pulled along in the xref?

Thanks,
Zoë 



Zoë Lawson

Radu Coravu
 

Hi Zoë,

Doing this kind of fix directly in the DITA content does not seem very scalable.
In older threads Eliot Kimber suggested doing this in the XSLT code:

https://dita-users.groups.io/g/main/topic/48666312

Something like:

<xsl:template match="*[contains(@class, ' topic/entry ')]/text()">
<xsl:value-of select="local:addBreakPointsToString(.)"/>
</xsl:template>
<xsl:function name="local:addBreakPointsToString" as="xs:string">
<xsl:param name="text" as="xs:string"/>
<xsl:variable name="result" as="xs:string" select="local:insertBreakPoints($text, ())"/>
<xsl:sequence select="$result"/>
</xsl:function>
<xsl:function name="local:insertBreakPoints" as="xs:string">
<xsl:param name="text" as="xs:string?"/>
<xsl:param name="resultString" as="xs:string?"/>
<xsl:choose>
<xsl:when test="not($text)">
<xsl:sequence select="$resultString"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="pre" select="substring($text, 1, 5)" as="xs:string"/>
<xsl:variable name="rest" select="substring($text, 6)" as="xs:string?"/>
<xsl:sequence
select="local:insertBreakPoints($rest, concat($resultString, '&#x200b;’, $pre)"
/>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
In our custom DITA to PDF using CSS output there are various properties which can be set to help with this:

https://www.oxygenxml.com/doc/ug-pdf-css/topics/dcpp_tables.html#ariaid-title4

Regards,
Radu

Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

On 2/25/2020 5:11 PM, Zoë Lawson wrote:
Greetings!
Somewhere I found the fun and exciting workaround for word wrapping in tables where you insert zero width spaces between camel-case letters, before _ . , : etc.
I did this for “code” type elements, since that’s where most of the “non-traditional hyphenation” stuff comes in. It’s working reasonably well.
Of course, now I have a xref to a topic with a camel-cased word in the title, and it’s not word-wrapping. The camel-cased word is in a paramname, which has the zero space shenanigans, but the paramname is not getting carried along to the xref text.
What’s the best way to approach this?
Add word wrapping shenanigans to all xref?
Try to get the paramname pulled along in the xref?
Thanks,
Zoë
Zoë Lawson

Zoë Lawson
 

Sorry, I wasn’t clear, I am doing this in the XSLT. I probably found Elliot’s suggestion back when I started this 2-4 months ago.

I’m just trying to figure out which template to work with next. I can see advantages and disadvantages for each approach and was looking for a second opinion.

Thanks,
Zoë

Zoë Lawson


From: main@dita-users.groups.io <main@dita-users.groups.io> on behalf of Radu Coravu <radu_coravu@...>
Sent: Wednesday, February 26, 2020 1:59:05 AM
To: main@dita-users.groups.io <main@dita-users.groups.io>; dita-users@groups.io <dita-users@groups.io>
Subject: Re: [dita-users] Word wrapping in tables for PDF
 
Hi Zoë,

Doing this kind of fix directly in the DITA content does not seem very
scalable.
In older threads Eliot Kimber suggested doing this in the XSLT code:

https://dita-users.groups.io/g/main/topic/48666312

Something like:

>     <xsl:template match="*[contains(@class, ' topic/entry ')]/text()">
>         <xsl:value-of select="local:addBreakPointsToString(.)"/>
>     </xsl:template>
>     <xsl:function name="local:addBreakPointsToString" as="xs:string">
>         <xsl:param name="text" as="xs:string"/>
>         <xsl:variable name="result" as="xs:string" select="local:insertBreakPoints($text, ())"/>
>         <xsl:sequence select="$result"/>
>     </xsl:function>
>     <xsl:function name="local:insertBreakPoints" as="xs:string">
>         <xsl:param name="text" as="xs:string?"/>
>         <xsl:param name="resultString" as="xs:string?"/>
>         <xsl:choose>
>             <xsl:when test="not($text)">
>                 <xsl:sequence select="$resultString"/>
>             </xsl:when>
>             <xsl:otherwise>
>                 <xsl:variable name="pre" select="substring($text, 1, 5)" as="xs:string"/>
>                 <xsl:variable name="rest" select="substring($text, 6)" as="xs:string?"/>
>                 <xsl:sequence
>                     select="local:insertBreakPoints($rest, concat($resultString, '&#x200b;’, $pre)"
>                 />
>             </xsl:otherwise>
>         </xsl:choose>
>     </xsl:function>

In our custom DITA to PDF using CSS output there are various properties
which can be set to help with this:

https://www.oxygenxml.com/doc/ug-pdf-css/topics/dcpp_tables.html#ariaid-title4

Regards,
Radu

Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

On 2/25/2020 5:11 PM, Zoë Lawson wrote:
> Greetings!
>
> Somewhere I found the fun and exciting workaround for word wrapping in
> tables where you insert zero width spaces between camel-case letters,
> before _ . , : etc.
> I did this for “code” type elements, since that’s where most of the
> “non-traditional hyphenation” stuff comes in. It’s working reasonably well.
>
> Of course, now I have a xref to a topic with a camel-cased word in the
> title, and it’s not word-wrapping. The camel-cased word is in a
> paramname, which has the zero space shenanigans, but the paramname is
> not getting carried along to the xref text.
>
> What’s the best way to approach this?
> Add word wrapping shenanigans to all xref?
> Try to get the paramname pulled along in the xref?
>
> Thanks,
> Zoë
>
>
>
> Zoë Lawson
>