mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-18 08:00:01 +02:00
chore: fix deprecation
This commit is contained in:
parent
370dbbc579
commit
e2fddcf681
6 changed files with 36 additions and 7 deletions
|
@ -50,7 +50,7 @@ func (g *GitHubCalloutTransformer) Transform(node *ast.Document, reader text.Rea
|
|||
return ast.WalkContinue, nil
|
||||
}
|
||||
firstTextNode, ok := firstParagraph.FirstChild().(*ast.Text)
|
||||
if !ok || string(firstTextNode.Text(reader.Source())) != "[" {
|
||||
if !ok || string(firstTextNode.Value(reader.Source())) != "[" {
|
||||
return ast.WalkContinue, nil
|
||||
}
|
||||
secondTextNode, ok := firstTextNode.NextSibling().(*ast.Text)
|
||||
|
@ -59,14 +59,14 @@ func (g *GitHubCalloutTransformer) Transform(node *ast.Document, reader text.Rea
|
|||
}
|
||||
// If the second node's text isn't one of the supported attention
|
||||
// types, continue walking.
|
||||
secondTextNodeText := secondTextNode.Text(reader.Source())
|
||||
secondTextNodeText := secondTextNode.Value(reader.Source())
|
||||
attentionType := strings.ToLower(strings.TrimPrefix(string(secondTextNodeText), "!"))
|
||||
if _, has := supportedAttentionTypes[attentionType]; !has {
|
||||
return ast.WalkContinue, nil
|
||||
}
|
||||
|
||||
thirdTextNode, ok := secondTextNode.NextSibling().(*ast.Text)
|
||||
if !ok || string(thirdTextNode.Text(reader.Source())) != "]" {
|
||||
if !ok || string(thirdTextNode.Value(reader.Source())) != "]" {
|
||||
return ast.WalkContinue, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ package callout
|
|||
import (
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/modules/markup/markdown/util"
|
||||
|
||||
"github.com/yuin/goldmark/ast"
|
||||
"github.com/yuin/goldmark/parser"
|
||||
"github.com/yuin/goldmark/text"
|
||||
|
@ -40,7 +42,7 @@ func (g *GitHubLegacyCalloutTransformer) Transform(node *ast.Document, reader te
|
|||
if !ok {
|
||||
return ast.WalkContinue, nil
|
||||
}
|
||||
calloutText := string(calloutNode.Text(reader.Source()))
|
||||
calloutText := string(util.Text(calloutNode, reader.Source()))
|
||||
calloutType := strings.ToLower(calloutText)
|
||||
// We only support "Note" and "Warning" callouts in legacy mode,
|
||||
// match only those.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue