Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
UtkarshKunwar opened this issue Jun 1, 2024 · 4 comments · Fixed by #31240
Closed
Labels

Comments

@UtkarshKunwar
Copy link

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

@yp05327
Copy link
Contributor

yp05327 commented Jun 3, 2024

@yardenshoham
maybe related to #29121 ?

@yardenshoham
Copy link
Member

cc @wxiaoguang as he last touched this code

@wxiaoguang
Copy link
Contributor

wxiaoguang commented 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.

@yardenshoham
Copy link
Member

wxiaoguang added a commit that referenced this issue Jun 4, 2024
Backport #31240 by wxiaoguang

Fix #31214

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Sep 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
4 participants