summaryrefslogtreecommitdiff
path: root/vendor/github.com
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2024-06-24 08:06:44 +0000
committerLibravatar GitHub <noreply@github.com>2024-06-24 08:06:44 +0000
commitddef307622b28bee67a22ea4181b9ca8ef2e7dbc (patch)
tree1912ed4116d3c11ded4ec5e2fb52da2f7a4794dd /vendor/github.com
parent[feature/frontend] Rain Forest Theme (#3021) (diff)
downloadgotosocial-ddef307622b28bee67a22ea4181b9ca8ef2e7dbc.tar.xz
[chore]: Bump github.com/yuin/goldmark from 1.7.2 to 1.7.3 (#3034)
Diffstat (limited to 'vendor/github.com')
-rw-r--r--vendor/github.com/yuin/goldmark/renderer/html/html.go36
1 files changed, 18 insertions, 18 deletions
diff --git a/vendor/github.com/yuin/goldmark/renderer/html/html.go b/vendor/github.com/yuin/goldmark/renderer/html/html.go
index b1da368e0..f9521d0fa 100644
--- a/vendor/github.com/yuin/goldmark/renderer/html/html.go
+++ b/vendor/github.com/yuin/goldmark/renderer/html/html.go
@@ -680,7 +680,7 @@ func (r *Renderer) renderImage(w util.BufWriter, source []byte, node ast.Node, e
_, _ = w.Write(util.EscapeHTML(util.URLEscape(n.Destination, true)))
}
_, _ = w.WriteString(`" alt="`)
- _, _ = w.Write(nodeToHTMLText(n, source))
+ r.renderAttribute(w, source, n)
_ = w.WriteByte('"')
if n.Title != nil {
_, _ = w.WriteString(` title="`)
@@ -770,6 +770,23 @@ func (r *Renderer) renderString(w util.BufWriter, source []byte, node ast.Node,
return ast.WalkContinue, nil
}
+func (r *Renderer) renderAttribute(w util.BufWriter, source []byte, n ast.Node) {
+ for c := n.FirstChild(); c != nil; c = c.NextSibling() {
+ if s, ok := c.(*ast.String); ok {
+ _, _ = r.renderString(w, source, s, true)
+ } else if t, ok := c.(*ast.String); ok {
+ _, _ = r.renderText(w, source, t, true)
+ } else if !c.HasChildren() {
+ r.Writer.Write(w, c.Text(source))
+ if t, ok := c.(*ast.Text); ok && t.SoftLineBreak() {
+ w.WriteByte('\n')
+ }
+ } else {
+ r.renderAttribute(w, source, c)
+ }
+ }
+}
+
var dataPrefix = []byte("data-")
// RenderAttributes renders given node's attributes.
@@ -1007,20 +1024,3 @@ func IsDangerousURL(url []byte) bool {
return hasPrefix(url, bJs) || hasPrefix(url, bVb) ||
hasPrefix(url, bFile) || hasPrefix(url, bData)
}
-
-func nodeToHTMLText(n ast.Node, source []byte) []byte {
- var buf bytes.Buffer
- for c := n.FirstChild(); c != nil; c = c.NextSibling() {
- if s, ok := c.(*ast.String); ok && s.IsCode() {
- buf.Write(s.Text(source))
- } else if !c.HasChildren() {
- buf.Write(util.EscapeHTML(c.Text(source)))
- if t, ok := c.(*ast.Text); ok && t.SoftLineBreak() {
- buf.WriteByte('\n')
- }
- } else {
- buf.Write(nodeToHTMLText(c, source))
- }
- }
- return buf.Bytes()
-}