mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-16 02:00:02 +02:00
modules/markup: Lift out the GitHub callout transformer
This lifts out the GitHub callout transformer from `modules/markup/markdown/goldmark.go` to `callout/github.go`. While there, clean up the transformer code: - Use a map to look up supported callout types, rather than a regexp. - Allow the callout type to be in any case, rather than just uppercase. - Simplified `.Segment.Value()` to `.Text()`. Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
This commit is contained in:
parent
0b3193bbbe
commit
a177a5c4cb
5 changed files with 183 additions and 112 deletions
|
@ -13,6 +13,7 @@ import (
|
|||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/markup"
|
||||
"code.gitea.io/gitea/modules/markup/common"
|
||||
"code.gitea.io/gitea/modules/markup/markdown/callout"
|
||||
"code.gitea.io/gitea/modules/markup/markdown/math"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
giteautil "code.gitea.io/gitea/modules/util"
|
||||
|
@ -124,6 +125,7 @@ func SpecializedMarkdown() goldmark.Markdown {
|
|||
parser.WithAttribute(),
|
||||
parser.WithAutoHeadingID(),
|
||||
parser.WithASTTransformers(
|
||||
util.Prioritized(&callout.GitHubCalloutTransformer{}, 9000),
|
||||
util.Prioritized(&ASTTransformer{}, 10000),
|
||||
),
|
||||
),
|
||||
|
@ -135,6 +137,7 @@ func SpecializedMarkdown() goldmark.Markdown {
|
|||
// Override the original Tasklist renderer!
|
||||
specMarkdown.Renderer().AddOptions(
|
||||
renderer.WithNodeRenderers(
|
||||
util.Prioritized(callout.NewGitHubCalloutHTMLRenderer(), 10),
|
||||
util.Prioritized(NewHTMLRenderer(), 10),
|
||||
),
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue