budoux icon indicating copy to clipboard operation
budoux copied to clipboard

ZWSP / WBR insertion causes unintended space trimming on line breaks

Open tushuhei opened this issue 1 year ago • 1 comments

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 avatar Jul 31 '24 08:07 tushuhei

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

budoux_render

tushuhei avatar Aug 08 '24 02:08 tushuhei