Repository navigation
Conversation
A block element inside a list item, such as `<li><p>One</p></li>`, owed line breaks after the marker was already written, so the derived text body put the item text on its own line under an empty marker. Block separation is now skipped until the item's content starts; nested lists still start on their own line. Closes tokio-rs#609
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The plain-text body that
topcoat-mailderives from HTML breaks when a list item wraps its content in a block element.<ul><li><p>One</p></li><li><p>Two</p></li></ul>came out as"- \n\nOne\n\n- \n\nTwo", and the<ol>/<div>version came out as"1. \nFirst\n2. \nSecond". Thelibranch writes the marker right away, then the inner<p>/<div>asks for line breaks viaseparate(), and those get flushed between the marker and the text.Fix:
PlainTextnow tracks whether a marker was just written with no item content yet, andseparate()skips block breaks while that's the case. The flag clears as soon as content is flushed. Nestedul/ol/lidon't go throughseparate(), so a nested list still starts on its own line. Now these give"- One\n\n- Two"and"1. First\n2. Second".Added tests for both cases, plus one pinning the nested list output (
"- Parent\n\n- Child", same as before). No existing expectations changed.Closes #609
Testing
cargo test -p topcoat-mail --lib: the new test fails onmainwith the output above, and all 41 tests pass with the fixcargo +nightly fmt --all: no changescargo topcoat fmt: 0 files modified (the only failures are the known Leptos benchmark files)cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: cleancargo test --workspace --all-features: 3477 passed, 0 failedRUSTDOCFLAGS="--cfg docsrs -Dwarnings" cargo +nightly doc --workspace --all-features --no-deps --locked: cleanMy sandbox blocks the downloads made by the Tailwind/iconify build scripts, so I ran the workspace clippy/test/doc commands with
--exclude topcoat-ui-registry --exclude ui --exclude admin --exclude icon --exclude tailwind --exclude storefront-topcoat. None of those depend ontopcoat-mail's text conversion.Disclaimer
Made with Claude Code (Claude Opus 5.5). It traced the bug in
text.rs, reproduced it with failing tests, wrote the fix and tests, and ran the checks above. I reviewed and verified the diff.