backtick math #11841

Closed
opened 2025-11-02 09:49:26 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @nschloe on GitHub (Oct 13, 2023).

Feature Description

GitLab and GitHub both have support for backtick math, i.e.,

The Pythagorean theorem can be written as an equation
relating the lengths of the sides $`a`$, $`b`$ and the
hypotenuse $`c`$:

```math
a^2 + b^2 = c^2.
```

The Pythagorean theorem can be written as an equation relating the lengths of the sides a, b and the hypotenuse c:

a^2 + b^2 = c^2.

The backticks avoid problems with accidental markdown sanitation in math content (which causes many problems for GitHub). The backticks suggests to the sanitizer that this is "code", not be touched.

GitLab started out with only the backticked mode in 2016. (They've added an imperfect dollar mode now.)

Right now, Gitea has no proper support for backticked math. Inline backticks

$`a + b = c`$

are literally rendered as backticks,

screenshot_2023-10-13-141058

and display-block backticks are rendered, but not centralized:

```math
abc
```

$$
abc
$$

screenshot_2023-10-13-141140

Using backticks in math also has the advantage that other Markdown software, e.g., linters or formatters, can be run on the file without modification.

It'd be great if Gitea could support backticked math as well.

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.

Originally created by @nschloe on GitHub (Oct 13, 2023). ### Feature Description GitLab and GitHub both have support for backtick math, i.e., ````markdown The Pythagorean theorem can be written as an equation relating the lengths of the sides $`a`$, $`b`$ and the hypotenuse $`c`$: ```math a^2 + b^2 = c^2. ``` ```` The Pythagorean theorem can be written as an equation relating the lengths of the sides $`a`$, $`b`$ and the hypotenuse $`c`$: ```math a^2 + b^2 = c^2. ``` The backticks avoid problems with accidental markdown sanitation in math content (which causes [many problems](https://github.com/nschloe/github-math-bugs/) for GitHub). The backticks suggests to the sanitizer that this is "code", not be touched. GitLab started out with only the backticked mode in 2016. (They've added an imperfect dollar mode now.) Right now, Gitea has no proper support for backticked math. Inline backticks ```markdown $`a + b = c`$ ``` are literally rendered as backticks, ![screenshot_2023-10-13-141058](https://github.com/go-gitea/gitea/assets/181628/11eafe4f-3c46-4039-a886-619294a336f5) and display-block backticks are rendered, but not centralized: ````markdown ```math abc ``` $$ abc $$ ```` ![screenshot_2023-10-13-141140](https://github.com/go-gitea/gitea/assets/181628/083a4ca1-005d-4e92-a965-c9cd017f6379) Using backticks in math also has the advantage that other Markdown software, e.g., linters or formatters, can be run on the file without modification. It'd be great if Gitea could support backticked math as well. _Edit:_ [I've surveyed math syntaxes and performance on GitHub, Gitea, GitLab.](https://nschloe.github.io/2023/11/16/the-state-of-math-in-markdown.html#comparison-table). 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.
GiteaMirror added the type/proposal label 2025-11-02 09:49:26 -06:00
Author
Owner

@nschloe commented on GitHub (Oct 14, 2023):

I see there is some discussion on this on the corresponding PR from Sep 2022. One of the participants repeats some points I've made concerning the GitHub $-math implementation (see here). GitHub struggles with their math implementation to this day (see here), but Gitea got many things right straight away. Great! Still, I believe using the $-syntax is a mistake; you'll always find yourself fighting with Markdown, and things like

The $n$th apple costs $(n+1).

will probably never render correctly. (LaTeX has \$, Markdown doesn't.) Compare that with backticks:

The $`n`$th apple costs $$`(n+1)`$.

The nth apple costs $(n+1).

Using backticks plays nicely with Markdown and avoids all kinds of problems. And this doesn't mention the straightforward implementation of it.

@nschloe commented on GitHub (Oct 14, 2023): I see there is some discussion on this on [the corresponding PR](https://github.com/go-gitea/gitea/pull/20571) from Sep 2022. One of the participants [repeats](https://github.com/go-gitea/gitea/pull/20571#issuecomment-1201775946) some points I've made concerning the GitHub $-math implementation (see [here](https://nschloe.github.io/2022/06/27/math-on-github-follow-up.html)). GitHub struggles with their math implementation to this day (see [here](https://github.com/nschloe/github-math-bugs/)), but Gitea got many things right straight away. Great! Still, I believe using the $-syntax is a mistake; you'll always find yourself fighting with Markdown, and things like > The $n$th apple costs $$(n+1)$. will probably never render correctly. (LaTeX has `\$`, Markdown doesn't.) Compare that with backticks: ```markdown The $`n`$th apple costs $$`(n+1)`$. ``` The $`n`$th apple costs $$`(n+1)`$. Using backticks plays nicely with Markdown and avoids all kinds of problems. And this doesn't mention the straightforward implementation of it.
Author
Owner

@eeyrjmr commented on GitHub (Oct 14, 2023):

These mathblocks exist for gitea, does this help?

(...), [...], ... and ...

@eeyrjmr commented on GitHub (Oct 14, 2023): These mathblocks exist for gitea, does this help? > \(...\), \[...\], $...$ and $$...$$
Author
Owner

@nschloe commented on GitHub (Oct 14, 2023):

@eeyrjmr Sorry for not being clear enough. These don't help at all, no, and that's what I'm trying to say. Markdown interferes with this syntax and will never be reliable.

Edit: Maybe \(\)/\[\] can help with rendering. Still worried about interoperability though.

Edit:: This syntax looks a little weird:

\[
\begin{align*}
a = b
\end{align*}
\]
@nschloe commented on GitHub (Oct 14, 2023): @eeyrjmr Sorry for not being clear enough. These don't help at all, no, and that's what I'm trying to say. Markdown interferes with this syntax and will never be reliable. _Edit:_ Maybe `\(\)`/`\[\]` can help with rendering. Still worried about interoperability though. _Edit:_: This syntax looks a little weird: ```markdown \[ \begin{align*} a = b \end{align*} \] ```
Author
Owner

@nschloe commented on GitHub (Dec 20, 2024):

It's supported now.

@nschloe commented on GitHub (Dec 20, 2024): It's supported now.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#11841