Fix markup heading parsing, fix emphasis parsing (#36284)

Fixes #36106, fix #17958

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Heath Dutton🕴️
2026-01-23 15:24:58 -05:00
committed by GitHub
parent cfd7218395
commit 0f78b99998
15 changed files with 260 additions and 196 deletions
+15 -2
View File
@@ -18,7 +18,6 @@ import (
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
"github.com/yuin/goldmark/ast"
"golang.org/x/sync/errgroup"
)
@@ -60,6 +59,19 @@ type RenderOptions struct {
EnableHeadingIDGeneration bool
}
type TocShowInSectionType string
const (
TocShowInSidebar TocShowInSectionType = "sidebar"
TocShowInMain TocShowInSectionType = "main"
)
type TocHeadingItem struct {
HeadingLevel int
AnchorID string
InnerText string
}
// RenderContext represents a render context
type RenderContext struct {
ctx context.Context
@@ -67,7 +79,8 @@ type RenderContext struct {
// the context might be used by the "render" function, but it might also be used by "postProcess" function
usedByRender bool
SidebarTocNode ast.Node
TocShowInSection TocShowInSectionType
TocHeadingItems []*TocHeadingItem
RenderHelper RenderHelper
RenderOptions RenderOptions