Skip to content

reopening #27605 (Math blocks can't be directly preceded or followed by alphanumeric character) #32726

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

Closed
nschloe opened this issue Dec 5, 2024 · 14 comments
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail

Comments

@nschloe
Copy link

nschloe commented Dec 5, 2024

Description

Unless I'm missing something, the issue #27605 has reappeared despite its fix in #30175.

MWE:

a$x$ -$x$ 1$x$

Screenshot:

screenshot_2024-12-05-152708

$a$1

$a$-

$a$x

screenshot_2024-12-05-152735

This also concerns the \(...\) and \[...\] syntax.

Gitea Version

1.23.0+dev-753-gc5422fae9a

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?

demo.gitea.com

Database

None

@nschloe nschloe changed the title re reopening #27605 (Math blocks can't be directly preceded or followed by alphanumeric character) Dec 5, 2024
@wxiaoguang

This comment was marked as outdated.

@wxiaoguang wxiaoguang added issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail and removed type/bug labels Dec 5, 2024
@wxiaoguang
Copy link
Contributor

wxiaoguang commented Dec 5, 2024

Unless I'm missing something, the issue #27605 has reappeared despite its fix in #30175.

The issue doesn't "reappear", because there are enough tests in #30175, a$x$ isn't rendered as "math".

image

@wxiaoguang

This comment was marked as outdated.

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Dec 5, 2024

Hmm, I see the misconception now. Actually #30175's title doesn't really match its test cases.

So, if a$x$ -$x$ 1$x$ is a must to support, we need to clarify its usage first and design the cases to avoid interfering other daily sentences like US$1 and 20US$

  • the question is: why not write $ax$ $-x$ $1x$?

The original discussion is here: #30175 (comment)

And this: #30175 (comment)

I looked at some websites and math research papers and it seems that the math expressions are never directly preceeded by a character, they are either a whole mathematical block or have a space in between like a $x$.

@nschloe
Copy link
Author

nschloe commented Dec 13, 2024

the question is: why not write $ax$ $-x$ $1x$?

There are various cases where you don't want spaces before or after math, for example:

  • $n$-dimensional
  • The answer is $x$. (any punctuation mark)
  • ($a$ replaced by $b$) (any bracket, before and after)
  • the $i$th iterate

There are more examples. None of this works in Gitea now; this also concerns the the $$...$$-, \(...\)-, and \[...\] syntaxes.

Opinion

Dealing with $-math is hard, so hard even that Donald Knuth himself suggested adding it to TeX was a mistake, later remedied by adding \(...\) to LaTeX. In Markdown, as opposed to TeX and as @wxiaoguang mentiones above, it gets even more tricky since the single $ already has a meaning that must be preserved.

Both GitLab and GitHub added a syntax that ties in beautifully with Markdown, namely

$`a + b = c`$ for inline math and 

```math
a + b = c
```

for display math.

None of the problems mentioned in this and other reports exist here because it makes use of the backticks, a well-established syntax in Markdown.

I've suggested adopting this syntax in Gitea as well.

@wxiaoguang
Copy link
Contributor

So if we support $` for inline math, then this issue (and maybe some related legacy issues) could be fully resolved?

@nschloe
Copy link
Author

nschloe commented Dec 13, 2024

At least you could point anyone running into a $-syntax bug to the working $`...`$ syntax. I myself would only use the latter anyway, and recommend everyone would do the same. (Same for $$ vs ```math.)

Edit: Highlighting why the \[...\] is problematic as well: #27645

@wxiaoguang
Copy link
Contributor

Edit: Highlighting why the \[...\] is problematic as well: #27645

Yes, I also found that \[...\] is problematic, it's not right to introduce it. But I guess we couldn't remove it since it would be a breaking change.

After " Refactor markdown math render #32831 ", the $`x`$ will be supported, then other issues could be closed IMO (encourage users to use the new syntax)

@nschloe
Copy link
Author

nschloe commented Dec 13, 2024

But I guess we couldn't remove it since it would be a breaking change.

Indeed, unfortunately so.

After " Refactor markdown math render #32831 ", the $x$ will be supported, then other issues could be closed IMO (encourage users to use the new syntax)

Note that we'd also need ```math code blocks to get feature parity with GitHub/GitLab.

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Dec 13, 2024

Note that we'd also need ```math code blocks to get feature parity with GitHub/GitLab.

It is already supported, right? https://demo.gitea.com/wxiaoguang/test-repo/issues/1#issuecomment-3436

image

@nschloe
Copy link
Author

nschloe commented Dec 13, 2024

Right! Hadn't realized that.

@wxiaoguang
Copy link
Contributor

Done in 1.23, let's use $`...`$

@nschloe
Copy link
Author

nschloe commented Dec 16, 2024

This isn't working yet in 1.23.0+dev-789-g18061af490 (on demo.gitea.com).

@wxiaoguang
Copy link
Contributor

This isn't working yet in 1.23.0+dev-789-g18061af490 (on demo.gitea.com).

Demo site is at 18061af (5 days ago), it doesn't include #32831

You can get the latest main-nightly (from dl.gitea.com or dockerhub)

@go-gitea go-gitea locked as resolved and limited conversation to collaborators Mar 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail
Projects
None yet
Development

No branches or pull requests

2 participants