mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-23 23:14:32 +02:00
fix(markup): parse \(...\) inline math next to letters and digits (#39773)
Fixes https://github.com/go-gitea/gitea/issues/39770 `\(x^2\)is` and `\(x^2\)123` rendered as plain text because `\(...\)` went through the same check on surrounding characters as `$...$`. That check is there to skip things like `US$1`, which can't happen with explicit `\(` `\)` delimiters, so it's now skipped for them, the same as for "$`...`$". `$x$a` still isn't parsed.
This commit is contained in:
1 parent
c6069f8d9f
commit
41ccfce3e9
2 files changed
+5
No files matched your search
@@ -42,6 +42,10 @@ func TestMathRender(t *testing.T) {
|
|||||||
`\(a\) \(b\)`,
|
`\(a\) \(b\)`,
|
||||||
`<p><code class="language-math">a</code> <code class="language-math">b</code></p>` + nl,
|
`<p><code class="language-math">a</code> <code class="language-math">b</code></p>` + nl,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
`\(x^2\)is \(x^2\)123 a\(b\)c`,
|
||||||
|
`<p><code class="language-math">x^2</code>is <code class="language-math">x^2</code>123 a<code class="language-math">b</code>c</p>` + nl,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
`$a$.`,
|
`$a$.`,
|
||||||
`<p><code class="language-math">a</code>.</p>` + nl,
|
`<p><code class="language-math">a</code>.</p>` + nl,
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ func (parser *inlineParser) Parse(parent ast.Node, block text.Reader, pc parser.
|
|||||||
} else {
|
} else {
|
||||||
startMarkLen = 2
|
startMarkLen = 2
|
||||||
stopMark = parser.endBytesParentheses
|
stopMark = parser.endBytesParentheses
|
||||||
|
checkSurrounding = false // explicit delimiters like "$`...`$", adjacent text is unambiguous
|
||||||
}
|
}
|
||||||
|
|
||||||
if line[0] == '$' && !parser.enableInlineDollar && (len(line) == 1 || line[1] != '`') {
|
if line[0] == '$' && !parser.enableInlineDollar && (len(line) == 1 || line[1] != '`') {
|
||||||
|
|||||||
Reference in new issue
Block a user