Skip to content

Commit d735903

Browse files
committed
#482: We must skip lines consisting only of soft-hypen no matter how many
they are. Also extended the test file. Thanks to @syjer to bring these cases up.
1 parent 0b25c48 commit d735903

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

  • openhtmltopdf-core/src/main/java/com/openhtmltopdf/layout
  • openhtmltopdf-examples/src/main/resources/testcases

openhtmltopdf-core/src/main/java/com/openhtmltopdf/layout/Breaker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public static LineBreakResult breakText(LayoutContext c,
175175
} else {
176176
if (context.getWidth() == 0) {
177177
String calculatedSubstring = context.getCalculatedSubstring();
178-
if (calculatedSubstring.length() == 1 && calculatedSubstring.charAt(0) == SOFT_HYPHEN) {
178+
if (calculatedSubstring.chars().allMatch(ch -> ch == SOFT_HYPHEN)) {
179179
// Consists only of soft hypen, we have to break here and skip all togheter. We do not
180180
// need to try breaking on the charater level, this will not work.
181181
tryToBreakAnywhere = true;

openhtmltopdf-examples/src/main/resources/testcases/oom.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,23 @@
1818
<tr>
1919
<td>­</td>
2020
</tr>
21+
<tr>
22+
<td>­­</td>
23+
</tr>
24+
<tr>
25+
<td>­­­</td>
26+
</tr>
27+
</table>
28+
<table class="content">
29+
<tr>
30+
<td> ­</td>
31+
</tr>
32+
<tr>
33+
<td>­ ­</td>
34+
</tr>
35+
<tr>
36+
<td>­ ­ ­</td>
37+
</tr>
2138
</table>
2239
</body>
2340
</html>

0 commit comments

Comments
 (0)