Merge pull request 'Update module github.com/yuin/goldmark to v1.7.8 (forgejo)' (#5780) from renovate/forgejo-github.com-yuin-goldmark-1.x into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/5780 Reviewed-by: Gusted <gusted@noreply.codeberg.org>
This commit is contained in:
commit
a729384dfd
8 changed files with 39 additions and 10 deletions
2
go.mod
2
go.mod
|
@ -97,7 +97,7 @@ require (
|
||||||
github.com/valyala/fastjson v1.6.4
|
github.com/valyala/fastjson v1.6.4
|
||||||
github.com/xanzy/go-gitlab v0.109.0
|
github.com/xanzy/go-gitlab v0.109.0
|
||||||
github.com/yohcop/openid-go v1.0.1
|
github.com/yohcop/openid-go v1.0.1
|
||||||
github.com/yuin/goldmark v1.7.4
|
github.com/yuin/goldmark v1.7.8
|
||||||
github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc
|
github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc
|
||||||
go.uber.org/mock v0.4.0
|
go.uber.org/mock v0.4.0
|
||||||
golang.org/x/crypto v0.28.0
|
golang.org/x/crypto v0.28.0
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -692,8 +692,8 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
|
||||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
github.com/yuin/goldmark v1.4.15/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
github.com/yuin/goldmark v1.4.15/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
github.com/yuin/goldmark v1.7.4 h1:BDXOHExt+A7gwPCJgPIIq7ENvceR7we7rOS9TNoLZeg=
|
github.com/yuin/goldmark v1.7.8 h1:iERMLn0/QJeHFhxSt3p6PeN9mGnvIKSpG9YYorDMnic=
|
||||||
github.com/yuin/goldmark v1.7.4/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
|
github.com/yuin/goldmark v1.7.8/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
|
||||||
github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc h1:+IAOyRda+RLrxa1WC7umKOZRsGq4QrFFMYApOeHzQwQ=
|
github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc h1:+IAOyRda+RLrxa1WC7umKOZRsGq4QrFFMYApOeHzQwQ=
|
||||||
github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc/go.mod h1:ovIvrum6DQJA4QsJSovrkC4saKHQVs7TvcaeO8AIl5I=
|
github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc/go.mod h1:ovIvrum6DQJA4QsJSovrkC4saKHQVs7TvcaeO8AIl5I=
|
||||||
github.com/zeebo/assert v1.1.0 h1:hU1L1vLTHsnO8x8c9KAR5GmM5QscxHg5RNU5z5qbUWY=
|
github.com/zeebo/assert v1.1.0 h1:hU1L1vLTHsnO8x8c9KAR5GmM5QscxHg5RNU5z5qbUWY=
|
||||||
|
|
|
@ -50,7 +50,7 @@ func (g *GitHubCalloutTransformer) Transform(node *ast.Document, reader text.Rea
|
||||||
return ast.WalkContinue, nil
|
return ast.WalkContinue, nil
|
||||||
}
|
}
|
||||||
firstTextNode, ok := firstParagraph.FirstChild().(*ast.Text)
|
firstTextNode, ok := firstParagraph.FirstChild().(*ast.Text)
|
||||||
if !ok || string(firstTextNode.Text(reader.Source())) != "[" {
|
if !ok || string(firstTextNode.Value(reader.Source())) != "[" {
|
||||||
return ast.WalkContinue, nil
|
return ast.WalkContinue, nil
|
||||||
}
|
}
|
||||||
secondTextNode, ok := firstTextNode.NextSibling().(*ast.Text)
|
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
|
// If the second node's text isn't one of the supported attention
|
||||||
// types, continue walking.
|
// types, continue walking.
|
||||||
secondTextNodeText := secondTextNode.Text(reader.Source())
|
secondTextNodeText := secondTextNode.Value(reader.Source())
|
||||||
attentionType := strings.ToLower(strings.TrimPrefix(string(secondTextNodeText), "!"))
|
attentionType := strings.ToLower(strings.TrimPrefix(string(secondTextNodeText), "!"))
|
||||||
if _, has := supportedAttentionTypes[attentionType]; !has {
|
if _, has := supportedAttentionTypes[attentionType]; !has {
|
||||||
return ast.WalkContinue, nil
|
return ast.WalkContinue, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
thirdTextNode, ok := secondTextNode.NextSibling().(*ast.Text)
|
thirdTextNode, ok := secondTextNode.NextSibling().(*ast.Text)
|
||||||
if !ok || string(thirdTextNode.Text(reader.Source())) != "]" {
|
if !ok || string(thirdTextNode.Value(reader.Source())) != "]" {
|
||||||
return ast.WalkContinue, nil
|
return ast.WalkContinue, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@ package callout
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"code.gitea.io/gitea/modules/markup/markdown/util"
|
||||||
|
|
||||||
"github.com/yuin/goldmark/ast"
|
"github.com/yuin/goldmark/ast"
|
||||||
"github.com/yuin/goldmark/parser"
|
"github.com/yuin/goldmark/parser"
|
||||||
"github.com/yuin/goldmark/text"
|
"github.com/yuin/goldmark/text"
|
||||||
|
@ -40,7 +42,7 @@ func (g *GitHubLegacyCalloutTransformer) Transform(node *ast.Document, reader te
|
||||||
if !ok {
|
if !ok {
|
||||||
return ast.WalkContinue, nil
|
return ast.WalkContinue, nil
|
||||||
}
|
}
|
||||||
calloutText := string(calloutNode.Text(reader.Source()))
|
calloutText := string(util.Text(calloutNode, reader.Source()))
|
||||||
calloutType := strings.ToLower(calloutText)
|
calloutType := strings.ToLower(calloutText)
|
||||||
// We only support "Note" and "Warning" callouts in legacy mode,
|
// We only support "Note" and "Warning" callouts in legacy mode,
|
||||||
// match only those.
|
// match only those.
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"code.gitea.io/gitea/modules/markup"
|
"code.gitea.io/gitea/modules/markup"
|
||||||
|
mdutil "code.gitea.io/gitea/modules/markup/markdown/util"
|
||||||
|
|
||||||
"github.com/yuin/goldmark/ast"
|
"github.com/yuin/goldmark/ast"
|
||||||
"github.com/yuin/goldmark/renderer/html"
|
"github.com/yuin/goldmark/renderer/html"
|
||||||
|
@ -49,7 +50,7 @@ func (r *HTMLRenderer) renderCodeSpan(w util.BufWriter, source []byte, n ast.Nod
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *ASTTransformer) transformCodeSpan(_ *markup.RenderContext, v *ast.CodeSpan, reader text.Reader) {
|
func (g *ASTTransformer) transformCodeSpan(_ *markup.RenderContext, v *ast.CodeSpan, reader text.Reader) {
|
||||||
colorContent := v.Text(reader.Source())
|
colorContent := mdutil.Text(v, reader.Source())
|
||||||
if matchColor(strings.ToLower(string(colorContent))) {
|
if matchColor(strings.ToLower(string(colorContent))) {
|
||||||
v.AppendChild(v, NewColorPreview(colorContent))
|
v.AppendChild(v, NewColorPreview(colorContent))
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ func (g *ASTTransformer) transformHeading(_ *markup.RenderContext, v *ast.Headin
|
||||||
v.SetAttribute(attr.Name, []byte(fmt.Sprintf("%v", attr.Value)))
|
v.SetAttribute(attr.Name, []byte(fmt.Sprintf("%v", attr.Value)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
txt := v.Text(reader.Source())
|
txt := v.Lines().Value(reader.Source())
|
||||||
header := markup.Header{
|
header := markup.Header{
|
||||||
Text: util.UnsafeBytesToString(txt),
|
Text: util.UnsafeBytesToString(txt),
|
||||||
Level: v.Level,
|
Level: v.Level,
|
||||||
|
|
26
modules/markup/markdown/util/text.go
Normal file
26
modules/markup/markdown/util/text.go
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
// Copyright 2024 The Forgejo Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
package util
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
|
||||||
|
"github.com/yuin/goldmark/ast"
|
||||||
|
)
|
||||||
|
|
||||||
|
func textOfChildren(n ast.Node, src []byte, b *bytes.Buffer) {
|
||||||
|
for c := n.FirstChild(); c != nil; c = c.NextSibling() {
|
||||||
|
if t, ok := c.(*ast.Text); ok {
|
||||||
|
b.Write(t.Value(src))
|
||||||
|
} else {
|
||||||
|
textOfChildren(c, src, b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Text(n ast.Node, src []byte) []byte {
|
||||||
|
var b bytes.Buffer
|
||||||
|
textOfChildren(n, src, &b)
|
||||||
|
return b.Bytes()
|
||||||
|
}
|
|
@ -46,7 +46,7 @@ func (r *stripRenderer) Render(w io.Writer, source []byte, doc ast.Node) error {
|
||||||
coalesce := prevSibIsText
|
coalesce := prevSibIsText
|
||||||
r.processString(
|
r.processString(
|
||||||
w,
|
w,
|
||||||
v.Text(source),
|
v.Value(source),
|
||||||
coalesce)
|
coalesce)
|
||||||
if v.SoftLineBreak() {
|
if v.SoftLineBreak() {
|
||||||
r.doubleSpace(w)
|
r.doubleSpace(w)
|
||||||
|
|
Loading…
Add table
Reference in a new issue