mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-23 19:47:07 +09:00
fix(markdown): parse escaped alerts by default (#39633)
Previously, recognition of escaped alert markers such as `\[!NOTE\]` accidentally depended on enabling the optional `inline-parentheses` math setting, resulting in such escaped alerts not rendering properly. Goldmark splits the escaped marker differently based on the setting being enabled or disabled, and only one form was handled. This commit handles both forms. For example, in a README or issue: ``` > \[!NOTE\] > text ``` Before this commit, we'd get an ordinary blockquote displaying literal `[!NOTE]` followed by `text`. With this commit, we get the styled admonition. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
1 parent
8a553332f7
commit
ab9bcd6a79
3 files changed
+20
-9
No files matched your search
@@ -17,7 +17,7 @@ import (
|
||||
const nl = "\n"
|
||||
|
||||
func TestMathRender(t *testing.T) {
|
||||
setting.Markdown.MathCodeBlockOptions = setting.MarkdownMathCodeBlockOptions{ParseInlineDollar: true, ParseInlineParentheses: true}
|
||||
defer test.MockVariableValue(&setting.Markdown.MathCodeBlockOptions, setting.MarkdownMathCodeBlockOptions{ParseInlineDollar: true, ParseInlineParentheses: true})()
|
||||
testcases := []struct {
|
||||
testcase string
|
||||
expected string
|
||||
@@ -122,7 +122,7 @@ func TestMathRender(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMathRenderBlockIndent(t *testing.T) {
|
||||
setting.Markdown.MathCodeBlockOptions = setting.MarkdownMathCodeBlockOptions{ParseBlockDollar: true, ParseBlockSquareBrackets: true}
|
||||
defer test.MockVariableValue(&setting.Markdown.MathCodeBlockOptions, setting.MarkdownMathCodeBlockOptions{ParseBlockDollar: true, ParseBlockSquareBrackets: true})()
|
||||
testcases := []struct {
|
||||
name string
|
||||
testcase string
|
||||
@@ -257,8 +257,7 @@ x
|
||||
}
|
||||
|
||||
func TestMathRenderOptions(t *testing.T) {
|
||||
setting.Markdown.MathCodeBlockOptions = setting.MarkdownMathCodeBlockOptions{}
|
||||
defer test.MockVariableValue(&setting.Markdown.MathCodeBlockOptions)
|
||||
defer test.MockVariableValue(&setting.Markdown.MathCodeBlockOptions, setting.MarkdownMathCodeBlockOptions{})()
|
||||
test := func(t *testing.T, expected, input string) {
|
||||
res, err := RenderString(markup.NewTestRenderContext(), input)
|
||||
assert.NoError(t, err)
|
||||
|
||||
Reference in new issue
Block a user