Skip to content

✨ feat(mq-lang): add squeeze_whitespace - #2437

Merged
harehare merged 1 commit into
feat/replace-prosefrom
feat/squeeze-whitespace
Sep 24, 2026
Merged

harehare merged 1 commit into
feat/replace-prosefrom
feat/squeeze-whitespace

Conversation

@harehare

Copy link
Copy Markdown
Owner

Summary

Joining or re-flowing text from multiple sources commonly leaves runs of extra spaces/tabs/newlines behind, with no single builtin to clean that up. Adds squeeze_whitespace(s), collapsing whitespace runs to one space and trimming the ends. String-only (mirrors normalize_newlines' own convention): gsub/trim on a markdown node only behave correctly for leaf nodes (text, code, ...) — on a container node (heading, paragraph, ...) they flatten it to its rendered source text instead, which isn't something this function should paper over.

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • ♻️ Refactor
  • 📝 Documentation
  • ⚡ Performance
  • ✅ Test
  • 📦 Build / dependencies
  • 👷 CI

Checklist

  • I ran cargo fmt and cargo clippy and addressed any warnings
  • I ran just test-all and all tests pass
  • I added or updated tests covering this change
  • I updated relevant documentation (/docs, crate README.md) if needed
  • I added a changelog entry if this is a user-facing change

Additional Context

@harehare
harehare added this pull request to stack #2438 September 24, 2026 05:16
@codspeed

codspeed Bot commented Sep 24, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 27 untouched benchmarks
⏩ 35 skipped benchmarks1


Comparing feat/squeeze-whitespace (ff0fde8) with feat/replace-prose (6514893)

Open in CodSpeed

Footnotes

  1. 35 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@harehare
harehare force-pushed the feat/squeeze-whitespace branch from 0fa6e1d to 1aca49d Compare September 24, 2026 05:55
Joining or re-flowing text from multiple sources commonly leaves
runs of extra spaces/tabs/newlines behind, with no single builtin to
clean that up. Adds squeeze_whitespace(s), collapsing whitespace runs
to one space and trimming the ends. String-only (mirrors
normalize_newlines' own convention): gsub/trim on a markdown node
only behave correctly for leaf nodes (text, code, ...) — on a
container node (heading, paragraph, ...) they flatten it to its
rendered source text instead, which isn't something this function
should paper over.
@harehare
harehare force-pushed the feat/squeeze-whitespace branch from 1aca49d to ff0fde8 Compare September 24, 2026 07:45
@harehare
harehare merged commit c66da36 into main Sep 24, 2026
11 checks passed
@harehare
harehare deleted the feat/squeeze-whitespace branch September 24, 2026 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant