go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
43.01k stars 5.31k forks source link

bracket syntax `\(\)\[\]` for math problematic #27645

Open nschloe opened 8 months ago

nschloe commented 8 months ago

Description

Here's another issue with the bracket syntax: \[ and \] are actually valid Markdown characters (see Markdown definition here), rendering to [ and ], respectively. The escaping is to set brackets apart from Markdown links à la [abc](https://example.com). Markdown formatters like prettier or mdformat escape brackets in various places, accidentally producing Gitea math. (See here for the corresponding mdformat bug.)

Related to https://github.com/go-gitea/gitea/issues/27602/.

Edit: I've surveyed math syntaxes and performance on GitHub, Gitea, GitLab.. Gitea's bracket-syntax is unique and hence not compatible. The backticked syntax is sorely missing from Gitea, especially given its great performance on the other platforms.

Gitea Version

1.22.0+dev-188-g1be49fdda

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

https://try.gitea.io/

Database

None

jamesbraza commented 8 months ago

@nschloe did you try using the mdformat-myst plugin? See https://github.com/executablebooks/mdformat/issues/334

nschloe commented 8 months ago

Yeah, same result with

import mdformat

print(mdformat.text("[a]", extensions={"myst"}))
\[a\]
jamesbraza commented 8 months ago

Thought it was worth a shot haha, sorry. Hope this gets resolved! You can also try prettier while mdformat isn't compatible

nschloe commented 8 months ago

As mentioned in my original post, prettier also escapes square brackets (though not always, as mdformat does).