Incorrect KaTex markdown rendering with \[ sequence #10618

Closed
opened 2025-11-02 09:12:51 -06:00 by GiteaMirror · 5 comments
Owner

Originally created by @silverwind on GitHub (Apr 8, 2023).

Description

Given this markdown:

-   \[CSS] - Nested atRule's `@media` or `@supports` now properly are replaced with unique identifiers by [@​noreiller](https://github.com/noreiller) in https://github.com/webpack/webpack/pull/15812

It renders

image

It should render like GitHub

image

Gitea Version

main

Can you reproduce the bug on the Gitea demo site?

Yes

Originally created by @silverwind on GitHub (Apr 8, 2023). ### Description Given this markdown: ````markdown - \[CSS] - Nested atRule's `@media` or `@supports` now properly are replaced with unique identifiers by [@&#8203;noreiller](https://github.com/noreiller) in https://github.com/webpack/webpack/pull/15812 ```` It renders <img width="769" alt="image" src="https://user-images.githubusercontent.com/115237/230737099-377b137c-02b6-49a4-a1b4-fd9dbc5cc244.png"> It should render like GitHub <img width="1102" alt="image" src="https://user-images.githubusercontent.com/115237/230737118-1ab6e96b-8bea-4cd3-8e2c-8930bf11a8f6.png"> ### Gitea Version main ### Can you reproduce the bug on the Gitea demo site? Yes
GiteaMirror added the outdated/theme/markdowntype/bug labels 2025-11-02 09:12:51 -06:00
Author
Owner

@silverwind commented on GitHub (Apr 8, 2023):

So I think the bug is in the backend where it detects \[CSS] as math content. I think we need to be more strict and require the $$ wrapping around math, like below:

$$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$
@silverwind commented on GitHub (Apr 8, 2023): So I think the bug is in the backend where it detects `\[CSS]` as math content. I think we need to be more strict and require the `$$` wrapping around math, like below: ``` $$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$
Author
Owner

@nschloe commented on GitHub (Nov 17, 2023):

Gitea was one of the first services to offer math support using a \(...\)/\[...\] syntax. Unfortunatly, it has not been adopted by any other platform, perhaps also because of the fact that it collides with standard Markdown syntax. (More about this in https://github.com/go-gitea/gitea/issues/27645.)

Right now, GitLab, GitHub, and Pandoc support two syntaxes:

  • $...$/$$...$$ (traditional TeX),
  • $`...`$/ ```math... ``` (originally introduced by GitLab in 2016).

In a survey across GitHub, GitLab, Gitea, and Pandoc, I've found that the $-syntax is error prone, also because it's non-native to Markdown. The backticked syntax (not supported by Gitea right now) is a great practical alternative.

For full compatibility with other platform, perhaps Gitea can think about sunsetting the bracket syntax for math, and add the backticked syntax. This would also fix this bug here.

@nschloe commented on GitHub (Nov 17, 2023): Gitea was one of the first services to offer math support using a `\(...\)`/`\[...\]` syntax. Unfortunatly, it has not been adopted by any other platform, perhaps also because of the fact that it collides with standard Markdown syntax. (More about this in https://github.com/go-gitea/gitea/issues/27645.) Right now, GitLab, GitHub, and Pandoc support two syntaxes: - `$...$`/`$$...$$` (traditional TeX), - `` $`...`$ ``/ ```` ```math... ``` ```` (originally introduced by GitLab in 2016). [In a survey across GitHub, GitLab, Gitea, and Pandoc](https://nschloe.github.io/2023/11/16/the-state-of-math-in-markdown.html#comparison-table), I've found that the `$`-syntax is error prone, also because it's non-native to Markdown. The backticked syntax (not supported by Gitea right now) is a great practical alternative. For full compatibility with other platform, perhaps Gitea can think about sunsetting the bracket syntax for math, and add the backticked syntax. This would also fix this bug here.
Author
Owner

@wxiaoguang commented on GitHub (Dec 13, 2024):

Will be fixed by #32831

@wxiaoguang commented on GitHub (Dec 13, 2024): Will be fixed by #32831
Author
Owner

@wxiaoguang commented on GitHub (Dec 14, 2024):

The \[ ... ] has been fixed in #32831, but the \[ ... \] is still problematic, I have left a TODO in code, we should drop this "math" syntax in the future by a config option.

@wxiaoguang commented on GitHub (Dec 14, 2024): The `\[ ... ]` has been fixed in #32831, but the `\[ ... \]` is still problematic, I have left a TODO in code, we should drop this "math" syntax in the future by a config option.
Author
Owner

@wxiaoguang commented on GitHub (Apr 4, 2025):

The complete fix is Fix markdown render behaviors #34122

@wxiaoguang commented on GitHub (Apr 4, 2025): The complete fix is Fix markdown render behaviors #34122
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#10618