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

Fix markdown frontmatter rendering (#34102) (#34107)

Backport #34102
Fix #34101
This commit is contained in:
wxiaoguang
2025-04-03 15:26:43 +08:00
committed by GitHub
parent a40e15a116
commit 3063e37802
8 changed files with 140 additions and 117 deletions

View File

@ -4,6 +4,7 @@
package markdown
import (
"html/template"
"strconv"
"github.com/yuin/goldmark/ast"
@ -29,9 +30,7 @@ func (n *Details) Kind() ast.NodeKind {
// NewDetails returns a new Paragraph node.
func NewDetails() *Details {
return &Details{
BaseBlock: ast.BaseBlock{},
}
return &Details{}
}
// Summary is a block that contains the summary of details block
@ -54,9 +53,7 @@ func (n *Summary) Kind() ast.NodeKind {
// NewSummary returns a new Summary node.
func NewSummary() *Summary {
return &Summary{
BaseBlock: ast.BaseBlock{},
}
return &Summary{}
}
// TaskCheckBoxListItem is a block that represents a list item of a markdown block with a checkbox
@ -95,29 +92,6 @@ type Icon struct {
Name []byte
}
// Dump implements Node.Dump .
func (n *Icon) Dump(source []byte, level int) {
m := map[string]string{}
m["Name"] = string(n.Name)
ast.DumpHelper(n, source, level, m, nil)
}
// KindIcon is the NodeKind for Icon
var KindIcon = ast.NewNodeKind("Icon")
// Kind implements Node.Kind.
func (n *Icon) Kind() ast.NodeKind {
return KindIcon
}
// NewIcon returns a new Paragraph node.
func NewIcon(name string) *Icon {
return &Icon{
BaseInline: ast.BaseInline{},
Name: []byte(name),
}
}
// ColorPreview is an inline for a color preview
type ColorPreview struct {
ast.BaseInline
@ -175,3 +149,24 @@ func NewAttention(attentionType string) *Attention {
AttentionType: attentionType,
}
}
var KindRawHTML = ast.NewNodeKind("RawHTML")
type RawHTML struct {
ast.BaseBlock
rawHTML template.HTML
}
func (n *RawHTML) Dump(source []byte, level int) {
m := map[string]string{}
m["RawHTML"] = string(n.rawHTML)
ast.DumpHelper(n, source, level, m, nil)
}
func (n *RawHTML) Kind() ast.NodeKind {
return KindRawHTML
}
func NewRawHTML(rawHTML template.HTML) *RawHTML {
return &RawHTML{rawHTML: rawHTML}
}