mirror of
https://github.com/kovetskiy/mark.git
synced 2026-03-21 18:37:40 +08:00
Update Go module path from github.com/kovetskiy/mark to github.com/kovetskiy/mark/v16 across all packages and imports, following Go module versioning conventions for major versions >= 2. Also update README installation instructions and version string. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
43 lines
977 B
Go
43 lines
977 B
Go
package renderer
|
|
|
|
import (
|
|
"github.com/kovetskiy/mark/v16/parser"
|
|
"github.com/kovetskiy/mark/v16/stdlib"
|
|
"github.com/yuin/goldmark/ast"
|
|
"github.com/yuin/goldmark/renderer"
|
|
"github.com/yuin/goldmark/util"
|
|
)
|
|
|
|
type ConfluenceMentionRenderer struct {
|
|
Stdlib *stdlib.Lib
|
|
}
|
|
|
|
func NewConfluenceMentionRenderer(stdlib *stdlib.Lib) renderer.NodeRenderer {
|
|
return &ConfluenceMentionRenderer{
|
|
Stdlib: stdlib,
|
|
}
|
|
}
|
|
|
|
func (r *ConfluenceMentionRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer) {
|
|
reg.Register(parser.KindMention, r.renderMention)
|
|
}
|
|
|
|
func (r *ConfluenceMentionRenderer) renderMention(w util.BufWriter, source []byte, node ast.Node, entering bool) (ast.WalkStatus, error) {
|
|
if !entering {
|
|
return ast.WalkContinue, nil
|
|
}
|
|
|
|
n := node.(*parser.Mention)
|
|
|
|
err := r.Stdlib.Templates.ExecuteTemplate(w, "ac:link:user", struct {
|
|
Name string
|
|
}{
|
|
Name: string(n.Name),
|
|
})
|
|
if err != nil {
|
|
return ast.WalkStop, err
|
|
}
|
|
|
|
return ast.WalkContinue, nil
|
|
}
|