Skip to content

GO-6032 Protect angle brackets in HTML-to-blocks pipeline#3035

Draft
KirillSto wants to merge 1 commit intodevelopfrom
go-6032-fix-pasting-code-with-angle-brackets
Draft

GO-6032 Protect angle brackets in HTML-to-blocks pipeline#3035
KirillSto wants to merge 1 commit intodevelopfrom
go-6032-fix-pasting-code-with-angle-brackets

Conversation

@KirillSto
Copy link
Copy Markdown
Member

Summary

  • Add < and > to the protectedRunes escape list in anymark/escape.go
  • When pasting HTML containing &lt;/&gt; entities (e.g. from CodeMirror copy buttons, ViolentMonkey, IDE copy buttons), the html-to-markdown library decodes them to bare </>, which goldmark then misinterprets as HTML tags and silently drops
  • The existing PUA sentinel escape mechanism already protects markdown-special characters ([, ], *, etc.) — this extends it to also protect angle brackets
  • Fixes the issue for all paste targets (code blocks, paragraphs, etc.) since the fix is in the shared conversion pipeline

Test plan

  • TestEscapeUnescapeAngleBrackets — round-trip escape/unescape preserves < and >
  • TestHTMLToBlocks_AngleBrackets — HTML entities, arrow functions, JSX, generics, comparison operators all preserved through HTMLToBlocks
  • TestClipboard_PasteHtmlWithAngleBrackets — end-to-end paste into code blocks and paragraphs preserves angle brackets
  • All existing TestConvertHTMLToBlocks JSON test cases still pass (including underline <u> tags)
  • All existing clipboard tests pass

🤖 Generated with Claude Code

Add < and > to the protectedRunes escape list so that HTML entities
(&lt; &gt;) decoded during HTML→markdown conversion are not
misinterpreted as raw HTML tags by goldmark. This fixes pasting code
containing angle brackets (arrow functions, generics, JSX) from
clipboard sources that only provide HTML.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@KirillSto KirillSto self-assigned this Mar 22, 2026
@github-actions
Copy link
Copy Markdown

New Coverage 46.5% of statements
Patch Coverage 0.0% of changed statements (0/0)

Coverage provided by https://github.com/seriousben/go-patch-cover-action

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.

1 participant