mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-28 22:19:59 +02:00
@@ -22,6 +22,7 @@ import (
|
||||
"runtime/debug"
|
||||
|
||||
"github.com/gohugoio/hugo/markup/goldmark/internal/extensions/attributes"
|
||||
"github.com/yuin/goldmark/ast"
|
||||
|
||||
"github.com/gohugoio/hugo/identity"
|
||||
|
||||
@@ -321,7 +322,28 @@ func newHighlighting(cfg highlight.Config) goldmark.Extender {
|
||||
highlight.WriteCodeTag(w, language)
|
||||
return
|
||||
}
|
||||
w.WriteString(`<div class="highlight">`)
|
||||
|
||||
w.WriteString(`<div class="highlight`)
|
||||
|
||||
var attributes []ast.Attribute
|
||||
if ctx.Attributes() != nil {
|
||||
attributes = ctx.Attributes().All()
|
||||
}
|
||||
|
||||
if attributes != nil {
|
||||
class, found := ctx.Attributes().GetString("class")
|
||||
if found {
|
||||
w.WriteString(" ")
|
||||
w.Write(util.EscapeHTML(class.([]byte)))
|
||||
|
||||
}
|
||||
_, _ = w.WriteString("\"")
|
||||
renderAttributes(w, true, attributes...)
|
||||
} else {
|
||||
_, _ = w.WriteString("\"")
|
||||
}
|
||||
|
||||
w.WriteString(">")
|
||||
return
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user