Skip to content

🐛 fix(markdown): keep line breaks out of link titles - #1259

Merged
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:fix/markdown-link-title
Oct 9, 2026
Merged

gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:fix/markdown-link-title

Conversation

@gaborbernat

Copy link
Copy Markdown
Member

to_markdown copied a line break in a link or image title as written. <a href="t" title="&#10;&gt;">x</a> became [x](t "\n>"), and its second line opens a block quote (CommonMark 5.1) that ends the paragraph in the middle of the link. A & that starts a reference stayed bare too, so title="a&amp;amp;" read back as a&.

A title decodes character references (6.3), so the converter now writes a line break as &#10; or &#13; and escapes a reference-shaped &. The first example becomes [x](t "&#10;>").

markdownify 1.2.3 writes [x](t "\n>"), and html2text 2025.4.15 writes [x](t "\n\n>")\n\n, a blank line that ends the paragraph inside the title.

@gaborbernat gaborbernat added the bug Something isn't working label Oct 9, 2026
A line break in a title came out raw, and the next line could open a block,
such as a quote, ending the paragraph mid-link. A title decodes character
references (CommonMark 6.3), so the converter writes line breaks as &tox-dev#10; or
&tox-dev#13; and escapes a reference-shaped "&".
@gaborbernat
gaborbernat force-pushed the fix/markdown-link-title branch from 8eee286 to 40da425 Compare October 9, 2026 01:40
@codspeed

codspeed Bot commented Oct 9, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 581 untouched benchmarks
⏩ 32 skipped benchmarks1


Comparing gaborbernat:fix/markdown-link-title (40da425) with main (8caa008)

Open in CodSpeed

Footnotes

  1. 32 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. ↩

@gaborbernat
gaborbernat merged commit e06ff49 into tox-dev:main Oct 9, 2026
60 checks passed
@gaborbernat
gaborbernat deleted the fix/markdown-link-title branch October 15, 2026 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant