Fix various legacy problems (#37092)
1. Fix #36439 2. Fix #37089 3. Fix incorrect layout of admin auth oidc page 4. Fix #35866 5. Fix #35800 6. Fix #36243
This commit is contained in:
@@ -21,7 +21,6 @@ import (
|
||||
chromahtml "github.com/alecthomas/chroma/v2/formatters/html"
|
||||
"github.com/yuin/goldmark"
|
||||
highlighting "github.com/yuin/goldmark-highlighting/v2"
|
||||
meta "github.com/yuin/goldmark-meta"
|
||||
"github.com/yuin/goldmark/ast"
|
||||
"github.com/yuin/goldmark/extension"
|
||||
"github.com/yuin/goldmark/parser"
|
||||
@@ -166,7 +165,6 @@ func SpecializedMarkdown(ctx *markup.RenderContext) *GlodmarkRender {
|
||||
ParseBlockDollar: setting.Markdown.MathCodeBlockOptions.ParseBlockDollar,
|
||||
ParseBlockSquareBrackets: setting.Markdown.MathCodeBlockOptions.ParseBlockSquareBrackets, // this is a bad syntax "\[ ... \]", it conflicts with normal markdown escaping
|
||||
}),
|
||||
meta.Meta,
|
||||
),
|
||||
goldmark.WithParserOptions(
|
||||
parser.WithAttribute(),
|
||||
|
||||
@@ -429,9 +429,12 @@ test
|
||||
---
|
||||
test
|
||||
`,
|
||||
`- item1
|
||||
- item2
|
||||
|
||||
`<hr/>
|
||||
<ul>
|
||||
<li>item1</li>
|
||||
<li>item2</li>
|
||||
</ul>
|
||||
<hr/>
|
||||
<p>test</p>
|
||||
`,
|
||||
},
|
||||
@@ -443,8 +446,8 @@ anything
|
||||
---
|
||||
test
|
||||
`,
|
||||
`anything
|
||||
|
||||
`<hr/>
|
||||
<h2>anything</h2>
|
||||
<p>test</p>
|
||||
`,
|
||||
},
|
||||
@@ -471,14 +474,26 @@ foo: bar
|
||||
</details><ul>
|
||||
<li class="task-list-item"><input type="checkbox" disabled="" data-source-position="19"/>task 1</li>
|
||||
</ul>
|
||||
`,
|
||||
},
|
||||
// we have our own frontmatter parser, don't need to use github.com/yuin/goldmark-meta
|
||||
{
|
||||
"InvalidFrontmatter",
|
||||
`---
|
||||
foo
|
||||
`,
|
||||
`<hr/>
|
||||
<p>foo</p>
|
||||
`,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testcases {
|
||||
res, err := markdown.RenderString(markup.NewTestRenderContext(), test.input)
|
||||
assert.NoError(t, err, "Unexpected error in testcase: %q", test.name)
|
||||
assert.Equal(t, test.expected, string(res), "Unexpected result in testcase %q", test.name)
|
||||
for _, tt := range testcases {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
res, err := markdown.RenderString(markup.NewTestRenderContext(), tt.input)
|
||||
assert.NoError(t, err, "Unexpected error in testcase: %q", tt.name)
|
||||
assert.Equal(t, tt.expected, string(res), "Unexpected result in testcase %q", tt.name)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,8 +60,8 @@ func ExtractMetadata(contents string, out any) (string, error) {
|
||||
return string(body), err
|
||||
}
|
||||
|
||||
// ExtractMetadata consumes a markdown file, parses YAML frontmatter,
|
||||
// and returns the frontmatter metadata separated from the markdown content
|
||||
// ExtractMetadataBytes consumes a Markdown content, parses YAML frontmatter,
|
||||
// and returns the frontmatter metadata separated from the Markdown content
|
||||
func ExtractMetadataBytes(contents []byte, out any) ([]byte, error) {
|
||||
var front, body []byte
|
||||
|
||||
|
||||
Reference in New Issue
Block a user