// Copyright 2024 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT package markdown import ( "strings" "testing" "code.gitea.io/gitea/modules/markup" "github.com/stretchr/testify/assert" ) func TestMathRender(t *testing.T) { const nl = "\n" testcases := []struct { testcase string expected string }{ { "$a$", `
a
a
a
b
a
b
a
.
.$a$
` + nl, }, { `$a a$b b$`, `$a a$b b$
` + nl, }, { `a a$b b`, `a a$b b
` + nl, }, { `a$b $a a$b b$`, `a$b $a a$b b$
` + nl, }, { "a$x$", `a$x$
` + nl, }, { "$x$a", `$x$a
` + nl, }, { "$a$ ($b$) [$c$] {$d$}", `a
(b
) [$c$] {$d$}
a
` + nl,
},
{
"$$a$$ test",
`a
test
test a
foo x=\$
bar
\text{$b$}
\alpha
`,
},
{
"indent-1",
`
\[
\alpha
\]
`,
`
\alpha
`,
},
{
"indent-2-mismatch",
`
\[
a
b
c
d
\]
`,
`
a
b
c
d
`,
},
{
"indent-2",
`
\[
a
b
c
\]
`,
`
a
b
c
`,
},
{
"indent-0-oneline",
`$$ x $$
foo`,
` x
foo
`, }, { "indent-3-oneline", ` $$ x $$ x
foo
`, }, { "quote-block", ` > \[ > a > \] > \[ > b > \] `, ``, }, { "list-block", ` 1. a \[ x \] 2. b`, `a
b
x