tmedwards / sugarcube-2

SugarCube is a free (gratis and libre) story format for Twine/Twee.
https://www.motoslave.net/sugarcube/2/
BSD 2-Clause "Simplified" License
177 stars 41 forks source link

Enhance Config.cleanupWikifierOutput to ellide paragraphs of whitespace #224

Closed hituro closed 2 months ago

hituro commented 1 year ago

The current cleanupWikifierOutput code will produce empty paragraphs between elements separated only by a single line-break. e.g. in a passage with nobr enabled

<div></div>
<div></div>

produces

<div></div>
<p> </p>
<div></div>

The empty paragraph there appears to be a mistake, since it is generated from the single line-break between the adjacent divs. It probably occurs because the line break is replaced with a single space, and that single space gets enclosed in a paragraph. It seems more logical not to generate a paragraph containing only whitespace.

greyelf commented 1 year ago

A slight correction...

The HTML output generated by @hituro's original Passage example when the nobr tag and the cleanupWikifierOutput setting are used in conjunction is..

<div> </div>
<p> </p>
<div> </div>

eg. each of the three elements will contain a single SPACE character.

hituro commented 1 year ago

Note, my original Discord example had a line-break inside each <div> which produces the spaces in the divs that @greyelf shows. The example above would only put a space in the <p>