Skip to content

Fix empty text after trimming whitespace - #993

Closed
lntutor wants to merge 1 commit into
tafia:masterfrom
lntutor:fix/trim-text-end-empty
Closed

Fix empty text after trimming whitespace#993
lntutor wants to merge 1 commit into
tafia:masterfrom
lntutor:fix/trim-text-end-empty

Conversation

@lntutor

@lntutor lntutor commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Config::trim_text_end promises not to emit a text event when trimming leaves it empty, but whitespace-only text immediately before markup still produced Text("").

This change lets both slice and buffered readers skip those whitespace-only spans before constructing an event. read_to_end temporarily disables both start and end trimming so its byte-range accounting remains unchanged.

Regression coverage exercises both Reader::from_str and buffered Reader::from_reader.

Verification:

  • cargo fmt --all -- --check
  • cargo test skips_whitespace_only_text_before_markup --all-features
  • cargo test --all-features
  • git diff --check

Closes #984

@lntutor
lntutor marked this pull request as draft July 30, 2026 13:55
@lntutor
lntutor marked this pull request as ready for review July 30, 2026 14:06
@lntutor

lntutor commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Closing as a duplicate of #986, which was already open for the same reported behavior. Sorry for the overlap.

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.

trim_text_end still emits an empty Text event for whitespace-only text before a tag

1 participant