From f0e8c3c3d02630b7fd117b62dabe3264a09c84aa Mon Sep 17 00:00:00 2001 From: Giteabot Date: Wed, 30 Sep 2026 08:06:27 -0700 Subject: [PATCH] fix(markup): skip post-processing inside MathML (#39497) (#39502) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Nico Schlömer Co-authored-by: wxiaoguang --- modules/markup/html.go | 4 ++-- modules/markup/html_test.go | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/markup/html.go b/modules/markup/html.go index 4687244668b..f64114226e1 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -349,8 +349,8 @@ func visitNode(ctx *RenderContext, procs []processor, node *html.Node) *html.Nod // TextNode emoji will be converted to ``, then the next iteration will visit the "span" // if we don't stop it, it will go into the TextNode again and create an infinite recursion return node.NextSibling - } else if node.Data == "code" || node.Data == "pre" { - return node.NextSibling // ignore code and pre nodes + } else if node.Data == "code" || node.Data == "pre" || node.Data == "math" { + return node.NextSibling // ignore code, pre and math nodes } else if node.Data == "img" { return visitNodeImg(ctx, node) } else if node.Data == "video" { diff --git a/modules/markup/html_test.go b/modules/markup/html_test.go index 8881edb9486..f4b44a5cbe1 100644 --- a/modules/markup/html_test.go +++ b/modules/markup/html_test.go @@ -543,6 +543,9 @@ func TestPostProcess(t *testing.T) { `Some text with 😄 in the middle`) test("http://localhost:3000/person/repo/issues/4#issuecomment-1234", `person/repo#4 (comment)`) + test( + ":gitea: go-gitea/gitea#12345", + ":gitea: go-gitea/gitea#12345") // special tags, GitHub's behavior, and for unclosed tags, output as text content as much as possible test("