-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Fixes #27605: inline math blocks can't be preceeded/followed by alphanumerical characters #30175
Fixes #27605: inline math blocks can't be preceeded/followed by alphanumerical characters #30175
Conversation
… alphanumerical characters Inline math blocks couldn't be preceeded or succeeded by alphanumerical characters due to changes introduced in PR go-gitea#21171. Removed the condition that caused this (precedingCharacter) and added a new if statement that checks if a specific '$' was escaped using '\'. Signed-off-by: João Tiago <joao.leal.tintas@tecnico.ulisboa.pt>
c75fa56
to
1edf43a
Compare
I tested what GitHub renders for your example and only the first one works. Would you say those are bugs in GitHub's implementation? |
Also, could you add a few more test cases, instead of only modifying the existing ones. |
Added one test case to check that math blocks render correctly when preceeded by an alphanumerical character, and another one for when it is succeeded by an alphanumerical character. Signed-off-by: João Tiago <joao.leal.tintas@tecnico.ulisboa.pt>
I think so since I don't see a particular reason why it wouldn't be allowed for characters to come directly before or after the math expressions. |
Seems like GitLab rendering does agree with your solution, so 👍 from me on the rendering part. |
We missed it but it seems that GitLab does not agree with my solution after all, the last expression of the second line is not rendered, and the rendering in the fourth line does not match |
…ical characters Signed-off-by: João Tiago <joao.leal.tintas@tecnico.ulisboa.pt>
fff63a7
to
88f41f3
Compare
TBH, I still have question about why it needs this change. Why it needs to handle By reading #27605, I didn't get the answer, and I haven't seen a real world example yet .... Could you elaborate the use cases by real examples? |
For the As for the |
Why people would write such expr
Yup, I agree that it is just a side-effect of this change. The root question is still the first one. |
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 I will change the code to not allow either preceeding or suceeding characters, and solely fix the bug that was fixed by as a side-effect. |
Should the math expressions not allowed to be followed by alphanumerical characters or also not allowed to be followed by any character besides ' ' or a newline? |
IMO following by a punctuation or newline is fine, because that's also how a sentence is written. GitHub:
|
Signed-off-by: João Tiago <joao.leal.tintas@tecnico.ulisboa.pt>
{ | ||
`$a a$b b$`, | ||
`<p>$a a<code class="language-math is-loading">b b</code></p>` + nl, | ||
`<p>$a a$b b$</p>` + nl, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could there be a case for something like:
-
$a a\\$b b$
=>$a a\$b b$
?
In case the users would like to escape and use $
I have this question because I guess the old code might work with $a a\\$b b$
(although it reports errors for $a a$b b$
, it is still acceptable)
So I'd like to confirm the new code's behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old code does what you described with $a a\$b b$
, with only one backslash. With two, or any even number of backslashes it would generate an error.
With the current code, the expression $a a\\$b b$
generates the expression below.
If the user wanted to get the output that you described he would need to use the following expression
$a a \$ b b$
…by alphanumerical characters (go-gitea#30175) - Inline math blocks couldn't be preceeded or succeeded by alphanumerical characters due to changes introduced in PR go-gitea#21171. Removed the condition that caused this (precedingCharacter condition) and added a new exit condition of the for-loop that checks if a specific '$' was escaped using '\' so that the math expression can be rendered as intended. - Additionally this PR fixes another bug where math blocks of the type '$xyz$abc$' where the dollar sign was not escaped by the user, generated an error (shown in the screenshots below) - Altered the tests to accomodate for the changes Former behaviour (from try.gitea.io): ![image](https://github.com/go-gitea/gitea/assets/114936010/8f0cbb21-321d-451c-b871-c67a8e1e9235) Fixed behaviour (from my local build): ![image](https://github.com/go-gitea/gitea/assets/114936010/5c22687c-6f11-4407-b5e7-c14b838bc20d) (Edit) Source code for the README.md file: ``` $x$ -$x$ $x$- a$xa$ $xa$a 1$xb$ $xb$1 $a a$b b$ a$b $a a$b b$ $a a\$b b$ ``` --------- Signed-off-by: João Tiago <joao.leal.tintas@tecnico.ulisboa.pt> Co-authored-by: Giteabot <teabot@gitea.io>
…by alphanumerical characters (go-gitea#30175) - Inline math blocks couldn't be preceeded or succeeded by alphanumerical characters due to changes introduced in PR go-gitea#21171. Removed the condition that caused this (precedingCharacter condition) and added a new exit condition of the for-loop that checks if a specific '$' was escaped using '\' so that the math expression can be rendered as intended. - Additionally this PR fixes another bug where math blocks of the type '$xyz$abc$' where the dollar sign was not escaped by the user, generated an error (shown in the screenshots below) - Altered the tests to accomodate for the changes Former behaviour (from try.gitea.io): ![image](https://github.com/go-gitea/gitea/assets/114936010/8f0cbb21-321d-451c-b871-c67a8e1e9235) Fixed behaviour (from my local build): ![image](https://github.com/go-gitea/gitea/assets/114936010/5c22687c-6f11-4407-b5e7-c14b838bc20d) (Edit) Source code for the README.md file: ``` $x$ -$x$ $x$- a$xa$ $xa$a 1$xb$ $xb$1 $a a$b b$ a$b $a a$b b$ $a a\$b b$ ``` --------- Signed-off-by: João Tiago <joao.leal.tintas@tecnico.ulisboa.pt> Co-authored-by: Giteabot <teabot@gitea.io>
Guess 1.22 backport is enough. Edit: Nevermind, GiteaBot was faster. |
…by alphanumerical characters (go-gitea#30175) - Inline math blocks couldn't be preceeded or succeeded by alphanumerical characters due to changes introduced in PR go-gitea#21171. Removed the condition that caused this (precedingCharacter condition) and added a new exit condition of the for-loop that checks if a specific '$' was escaped using '\' so that the math expression can be rendered as intended. - Additionally this PR fixes another bug where math blocks of the type '$xyz$abc$' where the dollar sign was not escaped by the user, generated an error (shown in the screenshots below) - Altered the tests to accomodate for the changes Former behaviour (from try.gitea.io): ![image](https://github.com/go-gitea/gitea/assets/114936010/8f0cbb21-321d-451c-b871-c67a8e1e9235) Fixed behaviour (from my local build): ![image](https://github.com/go-gitea/gitea/assets/114936010/5c22687c-6f11-4407-b5e7-c14b838bc20d) (Edit) Source code for the README.md file: ``` $x$ -$x$ $x$- a$xa$ $xa$a 1$xb$ $xb$1 $a a$b b$ a$b $a a$b b$ $a a\$b b$ ``` --------- Signed-off-by: João Tiago <joao.leal.tintas@tecnico.ulisboa.pt> Co-authored-by: Giteabot <teabot@gitea.io>
…numerical characters (#30175) (#30250) Backport #30175 by @jmlt2002 - Inline math blocks couldn't be preceeded or succeeded by alphanumerical characters due to changes introduced in PR #21171. Removed the condition that caused this (precedingCharacter condition) and added a new exit condition of the for-loop that checks if a specific '$' was escaped using '\' so that the math expression can be rendered as intended. - Additionally this PR fixes another bug where math blocks of the type '$xyz$abc$' where the dollar sign was not escaped by the user, generated an error (shown in the screenshots below) - Altered the tests to accomodate for the changes Former behaviour (from try.gitea.io): ![image](https://github.com/go-gitea/gitea/assets/114936010/8f0cbb21-321d-451c-b871-c67a8e1e9235) Fixed behaviour (from my local build): ![image](https://github.com/go-gitea/gitea/assets/114936010/5c22687c-6f11-4407-b5e7-c14b838bc20d) (Edit) Source code for the README.md file: ``` $x$ -$x$ $x$- a$xa$ $xa$a 1$xb$ $xb$1 $a a$b b$ a$b $a a$b b$ $a a\$b b$ ``` Signed-off-by: João Tiago <joao.leal.tintas@tecnico.ulisboa.pt> Co-authored-by: João Tiago <114936010+jmlt2002@users.noreply.github.com>
…numerical characters (#30175) (#30251) Backport #30175 by @jmlt2002 - Inline math blocks couldn't be preceeded or succeeded by alphanumerical characters due to changes introduced in PR #21171. Removed the condition that caused this (precedingCharacter condition) and added a new exit condition of the for-loop that checks if a specific '$' was escaped using '\' so that the math expression can be rendered as intended. - Additionally this PR fixes another bug where math blocks of the type '$xyz$abc$' where the dollar sign was not escaped by the user, generated an error (shown in the screenshots below) - Altered the tests to accomodate for the changes Former behaviour (from try.gitea.io): ![image](https://github.com/go-gitea/gitea/assets/114936010/8f0cbb21-321d-451c-b871-c67a8e1e9235) Fixed behaviour (from my local build): ![image](https://github.com/go-gitea/gitea/assets/114936010/5c22687c-6f11-4407-b5e7-c14b838bc20d) (Edit) Source code for the README.md file: ``` $x$ -$x$ $x$- a$xa$ $xa$a 1$xb$ $xb$1 $a a$b b$ a$b $a a$b b$ $a a\$b b$ ``` Signed-off-by: João Tiago <joao.leal.tintas@tecnico.ulisboa.pt> Co-authored-by: João Tiago <114936010+jmlt2002@users.noreply.github.com>
* giteaofficial/main: Refactor "dump" sub-command (go-gitea#30240) Add -u git to docs when using docker exec with root installation (go-gitea#29314) Show 12 lines in markup code preview (go-gitea#30255) Fixes go-gitea#27605: inline math blocks can't be preceeded/followed by alphanumerical characters (go-gitea#30175) Render embedded code preview by permlink in markdown (go-gitea#30234) Fix missing 0 prefix of GPG key id (go-gitea#30245) Fix spacing in issue navbar (go-gitea#30238) Add unique index for project_issue to prevent duplicate data (go-gitea#30190) [skip ci] Updated translations via Crowdin Refactor commit signature parser (go-gitea#30228) Refactor dropzone (go-gitea#30232) Remove scheduled action tasks if the repo is archived (go-gitea#30224) Refactor file view & render (go-gitea#30227) Refactor DeleteInactiveUsers, fix bug and add tests (go-gitea#30206) [skip ci] Updated licenses and gitignores Add `/options/license` and `/options/gitignore` to `.ignore` (go-gitea#30219)
…by alphanumerical characters (go-gitea#30175) - Inline math blocks couldn't be preceeded or succeeded by alphanumerical characters due to changes introduced in PR go-gitea#21171. Removed the condition that caused this (precedingCharacter condition) and added a new exit condition of the for-loop that checks if a specific '$' was escaped using '\' so that the math expression can be rendered as intended. - Additionally this PR fixes another bug where math blocks of the type '$xyz$abc$' where the dollar sign was not escaped by the user, generated an error (shown in the screenshots below) - Altered the tests to accomodate for the changes Former behaviour (from try.gitea.io): ![image](https://github.com/go-gitea/gitea/assets/114936010/8f0cbb21-321d-451c-b871-c67a8e1e9235) Fixed behaviour (from my local build): ![image](https://github.com/go-gitea/gitea/assets/114936010/5c22687c-6f11-4407-b5e7-c14b838bc20d) (Edit) Source code for the README.md file: ``` $x$ -$x$ $x$- a$xa$ $xa$a 1$xb$ $xb$1 $a a$b b$ a$b $a a$b b$ $a a\$b b$ ``` --------- Signed-off-by: João Tiago <joao.leal.tintas@tecnico.ulisboa.pt> Co-authored-by: Giteabot <teabot@gitea.io>
Former behaviour (from try.gitea.io):
Fixed behaviour (from my local build):
(Edit) Source code for the README.md file: