1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-09 20:17:21 +00:00

Refactor markdown math render (#32831)

Add more tests
This commit is contained in:
wxiaoguang
2024-12-14 13:43:05 +08:00
committed by GitHub
parent 82c59d52ea
commit cc5ff98e0d
10 changed files with 137 additions and 151 deletions

View File

@ -12,8 +12,9 @@ import (
"github.com/stretchr/testify/assert"
)
const nl = "\n"
func TestMathRender(t *testing.T) {
const nl = "\n"
testcases := []struct {
testcase string
expected string
@ -86,6 +87,18 @@ func TestMathRender(t *testing.T) {
`$\text{$b$}$`,
`<p><code class="language-math">\text{$b$}</code></p>` + nl,
},
{
"a$`b`$c",
`<p>a<code class="language-math">b</code>c</p>` + nl,
},
{
"a $`b`$ c",
`<p>a <code class="language-math">b</code> c</p>` + nl,
},
{
"a$``b``$c x$```y```$z",
`<p>a<code class="language-math">b</code>c x<code class="language-math">y</code>z</p>` + nl,
},
}
for _, test := range testcases {
@ -215,6 +228,11 @@ x
</ol>
`,
},
{
"inline-non-math",
`\[x]`,
`<p>[x]</p>` + nl,
},
}
for _, test := range testcases {