Preserve whitespace of removed "empty" elements #48

Merged
newsch merged 2 commits from nbsp into main 2024-07-08 21:13:55 +00:00

2 commits

Author SHA1 Message Date
Evan Lloyd New-Schmidt
457bd548ec Preserve whitespace of removed "empty" elements
Some articles use non-breaking spaces between quantities and units,
which Wikipedia seems to wrap with a span. Elements with no or
whitespace-only text were previously removed to prune `<link>`s and
parents of other removed elements.

This fix preserves the internal whitespace of elements that would
otherwise be removed for being "empty". It does not distinguish between
"meaningful" whitespace and padding between elements that would be
collapsed by HTML formatting rules. It also cannot distinguish between
elements that _started_ with only whitespace and nodes that now contain
only whitespace after previous steps. The preserved whitespace in the
latter case is unlikely to remain because of later processing steps.

Fixes #47, fixes organicmaps/organicmaps#8651

Signed-off-by: Evan Lloyd New-Schmidt <evan@new-schmidt.com>
2024-07-08 15:01:02 -04:00
Evan Lloyd New-Schmidt
e4219d94fd Remove pretty-printing
Whitespace behavior is different between Html::html and this
half-working pretty printer. Now the tests match the parser output
exactly.

Signed-off-by: Evan Lloyd New-Schmidt <evan@new-schmidt.com>
2024-07-08 13:44:30 -04:00