You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
FEATURE: Optional strip_trailing_invisibles config flag
Outlook/Word HTML exports frequently leave zero-width soft-break hints
and nbsp spacers at the end of paragraph content. Without trimming,
these survive into the rendered Markdown as invisible artifacts —
visually identical in the final rendered HTML, but confusing for
anyone editing the stored Markdown later or trying to diff/grep it.
Add a `strip_trailing_invisibles` config flag (default false) that,
when enabled, has `cleanup_markdown` rstrip the invisible set at every
line end. Members: NBSP (U+00A0), ZWSP (U+200B), ZWNJ (U+200C),
ZWJ (U+200D), WJ (U+2060), ZWNBSP/BOM (U+FEFF). Excludes ASCII space
and tab so Markdown's two-trailing-spaces hard-break syntax keeps
working.
```ruby
Markbridge.configure { |c| c.strip_trailing_invisibles = true }
```
Default-off matches the existing `escape_hard_line_breaks` precedent
("preserve more semantics by default") and means no behavior change
for current consumers. High-throughput migration paths pay nothing
extra; consumers who care about clean stored output opt in for the
~4-5% slowdown.
The Outlook spacer paragraph case (`<p> </p>` between two
paragraphs) drops out indirectly when enabled: rstripping the nbsp
leaves an empty line, which the existing `gsub(/\n{3,}/, "\n\n")`
collapse plus the trailing `.strip` swallow.
Benchmark, mixed block + inline HTML (ruby 3.4.8 +YJIT, 5 runs avg):
- main / flag off: ~3.27k i/s
- flag on: ~3.13k i/s (-4.5%)
Within typical run-to-run variance on this benchmark.
0 commit comments