google / budoux

https://google.github.io/budoux/
Apache License 2.0
1.44k stars 32 forks source link

ZWSP / WBR insertion causes unintended space trimming on line breaks #659

Open tushuhei opened 3 months ago

tushuhei commented 3 months ago

When a ZWSP or WBR element appears at the end of a line in source HTML, the space that should be introduced by the line break may be removed. The behavior may vary by browser. Possible solution from the BudouX side is not to insert a separator right before \n.

Demo: https://codepen.io/tushuhei/pen/GRbraYN

HTML:

<p>
  これは
  <b>テスト</b>
  です。
</p>
<p class="zwsp" style="word-break: keep-all; overflow-wrap: anywhere;">
  これは&ZeroWidthSpace;
  <b>テスト</b>
  です。&ZeroWidthSpace;
</p>
<p class="wbr" style="word-break: keep-all; overflow-wrap: anywhere;">
  これは<wbr>
  <b>テスト</b>
  です。<wbr>
</p>
tushuhei commented 2 months ago

This is the rendering of the test case in each browser. cc @kojiishi

budoux_render