Markdown callouts/attention blocks do not follow GitHub's behaviour with backslashes #13088

Closed
opened 2025-11-02 10:30:07 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @UtkarshKunwar on GitHub (Jun 1, 2024).

Description

GitHub's markdown attention blocks discussed in #28316 and introduced in v1.22.0 with #21711 do not follow the same behaviour when the square brackets are escaped with backslashes.

I noted this issue when the mdformat tool corrected the syntax by escaping the square brackets. GitHub was dealing with this just fine but Gitea failed in this situation.

Gitea Version

v1.22.0

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

Behaviour on GitHub

> [!NOTE]
> testing note without backslash

Note

testing note without backslash


> \[!NOTE\]
> testing note with backslash

[!NOTE]
testing note with backslash

Behaviour on Gitea

image

Git Version

No response

Operating System

No response

How are you running Gitea?

Used https://demo.gitea.com as well as self-hosted deb package instance.

Database

None

Originally created by @UtkarshKunwar on GitHub (Jun 1, 2024). ### Description GitHub's markdown attention blocks discussed in #28316 and introduced in v1.22.0 with #21711 do not follow the same behaviour when the square brackets are escaped with backslashes. I noted this issue when the `mdformat` tool corrected the syntax by escaping the square brackets. GitHub was dealing with this just fine but Gitea failed in this situation. ### Gitea Version v1.22.0 ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Screenshots ## Behaviour on GitHub ```markdown > [!NOTE] > testing note without backslash ``` > [!NOTE] > testing note without backslash --- ```markdown > \[!NOTE\] > testing note with backslash ``` > \[!NOTE\] > testing note with backslash ## Behaviour on Gitea ![image](https://github.com/go-gitea/gitea/assets/14164924/de12bbef-6f30-40ac-a0a4-7de30e9ffd52) ### Git Version _No response_ ### Operating System _No response_ ### How are you running Gitea? Used <https://demo.gitea.com> as well as self-hosted `deb` package instance. ### Database None
GiteaMirror added the type/bug label 2025-11-02 10:30:07 -06:00
Author
Owner

@yp05327 commented on GitHub (Jun 3, 2024):

@yardenshoham
maybe related to #29121 ?

@yp05327 commented on GitHub (Jun 3, 2024): @yardenshoham maybe related to #29121 ?
Author
Owner

@yardenshoham commented on GitHub (Jun 3, 2024):

cc @wxiaoguang as he last touched this code

@yardenshoham commented on GitHub (Jun 3, 2024): cc @wxiaoguang as he last touched this code
Author
Owner

@wxiaoguang commented on GitHub (Jun 3, 2024):

cc @wxiaoguang as he last touched this code

IIRC I didn't change the syntax for parsing, just kept the logic from #29121 :

https://github.com/go-gitea/gitea/pull/29121/files#diff-d78a9d361b1fddc12218e4dd42f42d39d6be1fda184041e06bb6fb30f0d94c59R199-R213

The new code still checks: // > Text("[") Text("!TYPE") Text("]").


I think the problem is related to the "unescaping" behavior.

GitHub does the unescaping before parsing, so > \[!NOTE\] becomes > [!NOTE] first before parsing the attentions.

Gitea mayebe doesn't do unescaping, so it only sees > \[!NOTE\], and it is not recognized at the moment. (Update: Just a guess, maybe Gitea also unescapes it correctly and sees [!NOTE], but there is only one text node, so it still not recognized since 29121 .....)

For this case, I think it could be simply fixed by adding more checks in code, and add a proper test.

@wxiaoguang commented on GitHub (Jun 3, 2024): > cc @wxiaoguang as he last touched this code IIRC I didn't change the syntax for parsing, just kept the logic from #29121 : https://github.com/go-gitea/gitea/pull/29121/files#diff-d78a9d361b1fddc12218e4dd42f42d39d6be1fda184041e06bb6fb30f0d94c59R199-R213 The new code still checks: `// > Text("[") Text("!TYPE") Text("]")`. ---- I think the problem is related to the "unescaping" behavior. GitHub does the unescaping before parsing, so `> \[!NOTE\]` becomes `> [!NOTE]` first before parsing the attentions. Gitea mayebe doesn't do unescaping, so it only sees `> \[!NOTE\]`, and it is not recognized at the moment. (Update: Just a guess, maybe Gitea also unescapes it correctly and sees `[!NOTE]`, but there is only one text node, so it still not recognized since 29121 .....) For this case, I think it could be simply fixed by adding more checks in code, and add a proper test.
Author
Owner

@yardenshoham commented on GitHub (Jun 3, 2024):

@yardenshoham commented on GitHub (Jun 3, 2024): - https://github.com/go-gitea/gitea/pull/31231
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#13088