Skip to content

Fix markdown_parser: unclosed <u> markers no longer delete surrounding text - #15275

Open
arpansahu wants to merge 1 commit into
warpdotdev:masterfrom
arpansahu:arpansahu/fix-unclosed-underline-emphasis-deletes-text
Open

Fix markdown_parser: unclosed <u> markers no longer delete surrounding text#15275
arpansahu wants to merge 1 commit into
warpdotdev:masterfrom
arpansahu:arpansahu/fix-unclosed-underline-emphasis-deletes-text

Conversation

@arpansahu

Copy link
Copy Markdown

Description

parse_markdown was silently deleting text when a <u> underline marker was left unclosed and another <u> appeared later in the same line.

<u> is tokenized as an UnderlineStart delimiter and pushed onto the shared delimiter stack. process_emphasis treats two <u> markers as a matchable opener/closer pair (since can_open_for only checked kind equality), consuming both markers and removing the text nodes between them.

Underline is only ever supposed to be closed by an explicit </u>, which is handled separately by parse_underline (it never goes through can_open_for). Pairing two <u> openers through the emphasis path is therefore always wrong.

Fix

can_open_for now explicitly rejects DelimiterKind::UnderlineStart openers, so an unclosed <u> round-trips to literal text — the same behavior as an unclosed * or ~~.

Input Before After
<u><u> empty line — all text gone <u><u>
<u>a<u> a (both <u> deleted) <u>a<u>
a <u>word<u> b a word b (both <u> deleted) a <u>word<u> b

Linked Issue

Fixes #12863

  • The linked issue is labeled ready-to-implement.
  • No UI changes — this is a pure parser logic fix in crates/markdown_parser.

Testing

  • Added test_parse_unclosed_underline_round_trips_to_literal_text, covering the three repro cases from the issue (<u><u>, <u>a<u>, a <u>word<u> b).
  • Ran cargo test -p markdown_parser: all 155 tests pass (154 pre-existing + 1 new).
  • Ran cargo fmt -p markdown_parser --check: clean.
  • Ran cargo clippy -p markdown_parser --all-targets --all-features -- -D warnings: no warnings.

This is a crate-scoped, platform-independent parser fix with no UI surface, so it was verified via the automated test suite above rather than manual app testing (./script/run builds the full desktop app, which isn't feasible in this environment).

Screenshots / Videos

N/A — parser-only change, no UI.

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

…g text

An unclosed `<u>` marker was being tokenized as a normal emphasis
delimiter and matched against a later `<u>` marker by
`process_emphasis` (since both share DelimiterKind::UnderlineStart and
can_open_for only checked kind equality). This silently consumed both
delimiters and the text nodes between them.

`<u>` is only ever meant to be closed by an explicit `</u>`, which is
handled separately by parse_underline (it never goes through
can_open_for). Pairing two `<u>` openers via the emphasis algorithm is
therefore always incorrect.

Fix can_open_for to reject DelimiterKind::UnderlineStart openers, so an
unclosed <u> now round-trips to literal text, consistent with how an
unclosed * or ~~ is handled.

Fixes warpdotdev#12863

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@cla-bot

cla-bot Bot commented Aug 18, 2026

Copy link
Copy Markdown

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @arpansahu on file. In order for us to review and merge your code, each contributor must visit https://cla.warp.dev to read and agree to our CLA. Once you have done so, please comment @cla-bot check to trigger another check.

@github-actions github-actions Bot added the external-contributor Indicates that a PR has been opened by someone outside the Warp team. label Aug 18, 2026
@oz-for-oss

oz-for-oss Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

@arpansahu

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I reviewed this pull request and requested human review from: @kevinyang372.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview

This PR updates markdown_parser so bare <u> start tags are not matched as opener/closer pairs by the emphasis algorithm; underline remains closed only by explicit </u>. It also adds focused unit coverage for the reported unclosed-underline cases.

Concerns

  • None found.

Verdict

Found: 0 critical, 0 important, 0 suggestions

Approve

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss
oz-for-oss Bot requested a review from kevinyang372 August 18, 2026 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor Indicates that a PR has been opened by someone outside the Warp team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

markdown_parser: unclosed <u> markers pair via the emphasis algorithm and delete surrounding text

1 participant