Skip to content

Fix link title double-quote escaping in inline links (#390)#443

Open
gaoflow wants to merge 1 commit into
Alir3z4:masterfrom
gaoflow:fix/link-title-quote-escaping
Open

Fix link title double-quote escaping in inline links (#390)#443
gaoflow wants to merge 1 commit into
Alir3z4:masterfrom
gaoflow:fix/link-title-quote-escaping

Conversation

@gaoflow

@gaoflow gaoflow commented Jun 25, 2026

Copy link
Copy Markdown

Problem

When an HTML link title contains double-quote characters (e.g. via the " entity), the generated inline Markdown link is invalid:

<a href="http://example.com" title="foo &quot;bar&quot; baz">link</a>

Produces:

[link](http://example.com "foo "bar" baz")

The unescaped inner " characters break CommonMark title parsing — the title ends at the first unescaped " after the opening one, leaving bar" baz" as stray text outside the link.

Fix

Backslash-escape any " characters in the title string before wrapping it in the "…" delimiter inside link_url(). In CommonMark, \" inside a double-quoted title is a valid escape for a literal ".

After the fix:

[link](http://example.com "foo \"bar\" baz")

Adds test/link_title_with_quotes.{html,md} to the existing glob-driven test suite.

Fixes #390


This pull request was prepared with the assistance of AI, under my direction and review.

When an HTML link title contains double-quote characters (e.g. decoded
from &quot;), the generated inline Markdown was invalid:

  [link](http://example.com "foo "bar" baz")

The inner quotes break any CommonMark-compliant title parser. Fix by
backslash-escaping double quotes inside the title string before wrapping
it in the "…" delimiter inside link_url().

Adds a test fixture that exercises the broken case.

Fixes Alir3z4#390
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.

Link titles break with encoded quote

1 participant