Overflow Wrap in Tables Overriding Hyphenation Rules

shannonxtreme
Posts: 24
Joined: Fri Aug 24, 2018 4:27 pm

Overflow Wrap in Tables Overriding Hyphenation Rules

Post by shannonxtreme » Wed Feb 27, 2019 7:58 pm

We're using DITA-CSS PDF transforms to generate documentation. A lot of our content is in tables. Some of the content is typical words:

Example table cell contents:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris feugiat orci sed diam ultricies, et cursus purus mollis. Fusce nec dui ac lectus hendrerit convallis et at purus.

Other table cell content is names of API elements (so long strings of letters)

Example string:

loreumIpsumDolorSit.AmetConsectetur

ISSUE 1

We want the long strings to wrap instead of bleeding over to the next cell, so we use the following CSS rules:

Code: Select all


*[class~="topic/table"] {
table-layout: auto;
border: none;
width: 100%;
overflow-wrap: break-word;
-oxy-hyphenation-character: " ";
This causes the long strings to wrap inside the cell without visible hyphens.

ISSUE 2

However, this also causes normal words to break in weird places.

So for example,

"position"

would break into

"positio
n"

We wanted to make this so that if the word has a minimum number of characters after the hyphen, it'll move the entire word to the next line instead of breaking it.

We used the following code:

Code: Select all


*[class~="topic/table"] {
table-layout: auto;
border: none;
width: 100%;
overflow-wrap: break-word;
hyphens: auto;
-oxy-hyphenation-character: " "; /* removes hyphens in line-broken words */
-oxy-hyphenation-push-character-count: "3" !important;
-oxy-hyphenation-remain-character-count: "10" !important;
}
Here's the problem: if we enable overflow-wrap: break-word, ISSUE 1 is solved but causes ISSUE 2 (weird breaking of words). If we disable overflow-wrap: break-word, ISSUE 2 is solved but causes ISSUE 1 to occur (bleeding across cells). overflow-wrap appears to override hyphens: auto and the oxy-push and oxy-remain rules.

How do we have both active for tables?

Dan
Posts: 428
Joined: Mon Feb 03, 2003 10:56 am

Re: Overflow Wrap in Tables Overriding Hyphenation Rules

Post by Dan » Thu Feb 28, 2019 12:02 pm

The problem is that we implemented overflow wrap using hyphenation. Anyway, is not a good idea to mix both of them, as there is no priority defined in the standard.

Your situation is like this:
- Some of the table cells contain API names, that are long, without dashes or underscores, but having a camel case naming.
- The hyphenation options are not enough because some of the API names cannot be hyphenated at all.

Maybe one solution is to reimplement the hyphenation code, to take into account as possible breaking points the case change. In this case, the API name should break like this:

Code: Select all

loreum[SH]Ipsum[SH]Dolor[SH]Sit.Amet[SH]Consectetur
where SH is a soft hyphen.

If you want, we can make this change and give you a build to test it.

Many regards,
Dan

Dan
Posts: 428
Joined: Mon Feb 03, 2003 10:56 am

Re: Overflow Wrap in Tables Overriding Hyphenation Rules

Post by Dan » Thu Feb 28, 2019 12:08 pm

Another idea: If your API names are wrapped in an element, like a codeph, you can set overflow-wrap: break-word; on this element, and leave the parent table with the hyphenation settings.

Many regards,
Dan

shannonxtreme
Posts: 24
Joined: Fri Aug 24, 2018 4:27 pm

Re: Overflow Wrap in Tables Overriding Hyphenation Rules

Post by shannonxtreme » Thu Feb 28, 2019 7:01 pm

Dan wrote:The problem is that we implemented overflow wrap using hyphenation. Anyway, is not a good idea to mix both of them, as there is no priority defined in the standard.

Your situation is like this:
- Some of the table cells contain API names, that are long, without dashes or underscores, but having a camel case naming.
- The hyphenation options are not enough because some of the API names cannot be hyphenated at all.

Maybe one solution is to reimplement the hyphenation code, to take into account as possible breaking points the case change. In this case, the API name should break like this:

Code: Select all

loreum[SH]Ipsum[SH]Dolor[SH]Sit.Amet[SH]Consectetur
where SH is a soft hyphen.

If you want, we can make this change and give you a build to test it.

Many regards,
Dan

Hi Dan. I tried out the other solution (the workaround, if you will) and it didn't work because the table contents are all wrapped in <p> with no unique identifiers. We have a few hundred documents dating back a decade or so and refactoring doesn't seem to be an option because we can't distinguish between the strings and "normal" content.

We'd be quite interested in a test build that inserts soft hyphens at case changes. Could you please let me know how to move forward with that?

Dan
Posts: 428
Joined: Mon Feb 03, 2003 10:56 am

Re: Overflow Wrap in Tables Overriding Hyphenation Rules

Post by Dan » Fri Mar 01, 2019 1:52 pm

Hello,

Ok. We will send you a download link when we will have the fix ready.

Many regards,
Dan

Dan
Posts: 428
Joined: Mon Feb 03, 2003 10:56 am

Re: Overflow Wrap in Tables Overriding Hyphenation Rules

Post by Dan » Fri Mar 01, 2019 3:59 pm

I verified the current implementation (from oXygen 21) and it does hyphenation at the case change. Do you use oXygen 20.1?

If running with oXygen 21 and you still have problems, please send us using the transformation console log:
https://www.oxygenxml.com/techSupport.html

You can also download and install the latest Chemistry version (https://www.oxygenxml.com/pdf_chemistry/download.html), and change the transformation scenario to use it. There is a parameter named "css.processor.path.chemistry" that you can set to the full path of the chemistry sarting script.

Many regards,
Dan

shannonxtreme
Posts: 24
Joined: Fri Aug 24, 2018 4:27 pm

Re: Overflow Wrap in Tables Overriding Hyphenation Rules

Post by shannonxtreme » Tue Mar 05, 2019 1:20 am

Dan wrote:I verified the current implementation (from oXygen 21) and it does hyphenation at the case change. Do you use oXygen 20.1?

If running with oXygen 21 and you still have problems, please send us using the transformation console log:
https://www.oxygenxml.com/techSupport.html

You can also download and install the latest Chemistry version (https://www.oxygenxml.com/pdf_chemistry/download.html), and change the transformation scenario to use it. There is a parameter named "css.processor.path.chemistry" that you can set to the full path of the chemistry sarting script.

Many regards,
Dan
Hi Dan,

Sorry for the delay in getting back to you on this. We tried it out on 21.0 and it didn't work. I did notice that we do not have Chemistry installed on our computers, but the Transformation Scenario is oXygen PDF Chemistry in the CSS Processor tab of the Edit DITA Scenario dialog box. However, Chemistry is not installed and does not show up in the Start menu or elsewhere. Could this be the problem?

Dan
Posts: 428
Joined: Mon Feb 03, 2003 10:56 am

Re: Overflow Wrap in Tables Overriding Hyphenation Rules

Post by Dan » Tue Mar 05, 2019 4:16 pm

Can you send us to support some sample API words that are not hyphenated?

Many regards,
Dan

shannonxtreme
Posts: 24
Joined: Fri Aug 24, 2018 4:27 pm

Re: Overflow Wrap in Tables Overriding Hyphenation Rules

Post by shannonxtreme » Tue Mar 05, 2019 5:51 pm

Dan wrote:Can you send us to support some sample API words that are not hyphenated?

Many regards,
Dan
Sure thing!

ComplyRptJuris.ComplyCode2
ComplyRptJuris.ModDateTime
ComplyRptJuris.ComplyRptJuris–UUID

to name a few. On the backend, here's the current XML and CSS.

Code: Select all


<table>		
<tgroup>
<tbody>
<row>
<entry>ComplyRptJuris.ModDateTime
</entry>
</row>
</tbody>
</tgroup>
</table>

Code: Select all


*[class~="topic/table"] {
table-layout: auto;
border: none;
width: 100%;
hyphens: auto;
-oxy-hyphenation-character: " "; /* removes hyphens in line-broken words */
-oxy-hyphenation-push-character-count: "3" !important; /* Minimum 3 characters pushed to next line */
-oxy-hyphenation-remain-character-count: "4" !important; /* Minimum 4 characters remain on previous line */
Thank you for all your help so far!

Dan
Posts: 428
Joined: Mon Feb 03, 2003 10:56 am

Re: Overflow Wrap in Tables Overriding Hyphenation Rules

Post by Dan » Wed Mar 06, 2019 5:08 pm

Hello,
Thank you for the examples.

First, make sure you remove the quotes from the hyphenation properties:

Code: Select all


   -oxy-hyphenation-push-character-count: 6 !important; /* Minimum 3 characters pushed to next line */
-oxy-hyphenation-remain-character-count: 2 !important; /* Minimum 4 characters remain on previous line */
We created a very small sample with the content:

Code: Select all


<?xml-stylesheet type="text/css" href="hyphenation-on-underscores.in.css"?>
<article xml:lang="de">
<intro>The table should not bleed out the page, it should use hyphenation to keep size to a minimum.</intro>
<table>

<tr>
<td>ComplyRptJuris.ComplyCode2</td>
<td>ComplyRptJuris.ComplyRptJuris–UUID</td>
</tr>

</table>
</article>
The css:

Code: Select all



@page {
size: 6in 10in;
}

* {
display:block;
}

intro {
font-size: 2em;
font-style: italic;
}

table {
display:table;
table-layout:auto;
border: 2pt solid orange;
hyphens: auto;
width: 100%;
-oxy-hyphenation-character: " "; /* removes hyphens in line-broken words */
-oxy-hyphenation-push-character-count: 6 !important; /* Minimum 3 characters pushed to next line */
-oxy-hyphenation-remain-character-count: 2 !important; /* Minimum 4 characters remain on previous line */
}

tr {
display:table-row;
}

td {
display: table-cell;
border: 1pt solid orange;
padding: 1em;
}

The result was:

First cell:

Code: Select all


ComplyRptJur
is.ComplyCode2
Second cell:

Code: Select all


ComplyRptJuris.Comply
RptJuris–UUID
So the hyphenation worked. Can you double-check that the root DITA map element has an xml:lang set on it? If there is no xml:lang, the hyphenation will not work.

NielsVerstappen
Posts: 9
Joined: Thu Jul 04, 2019 3:49 pm

Re: Overflow Wrap in Tables Overriding Hyphenation Rules

Post by NielsVerstappen » Wed Aug 07, 2019 5:28 pm

Hi Dan,

I came across this topic, which quite closely described a problem I had myself. Using your reply, I got words that were too long for a table cell to wrap in a logical way. However now, when I search for the wrapped word in Adobe Reader, it does not find this word. It appears by wrapping the word, Adobe Reader recognises the word as two seperate words. Is there a way to wrap a word and still being able to find it as a single word?

Thanks in advance,
Niels

Costin
Posts: 621
Joined: Mon Dec 05, 2011 6:04 pm

Re: Overflow Wrap in Tables Overriding Hyphenation Rules

Post by Costin » Fri Aug 09, 2019 2:25 pm

Hi Niels,

I logged this in our internal tracking system, so we will investigate if this behavior comes from the PDF reader, or if there is something we could do to make the hyphenated words searchable in the PDF.
We will update this thread once we reach to a conclusion.

Regards,
Costin
Costin Sandoi
oXygen XML Editor and Author Support

Post Reply