chore: fix deprecation

This commit is contained in:
Gusted 2024-11-02 13:35:24 +01:00
parent 370dbbc579
commit e2fddcf681
No known key found for this signature in database
GPG key ID: FD821B732837125F
6 changed files with 36 additions and 7 deletions

View 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()
}