forked from forgejo/forgejo
modules/markup: Lift out the GitHub callout transformer
This lifts out the GitHub callout transformer from `modules/markup/markdown/goldmark.go` to `callout/github.go`. While there, clean up the transformer code: - Use a map to look up supported callout types, rather than a regexp. - Allow the callout type to be in any case, rather than just uppercase. - Simplified `.Segment.Value()` to `.Text()`. Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
This commit is contained in:
parent
0b3193bbbe
commit
a177a5c4cb
5 changed files with 183 additions and 112 deletions
|
@ -181,32 +181,3 @@ func IsColorPreview(node ast.Node) bool {
|
|||
_, ok := node.(*ColorPreview)
|
||||
return ok
|
||||
}
|
||||
|
||||
// Attention is an inline for an attention
|
||||
type Attention struct {
|
||||
ast.BaseInline
|
||||
AttentionType string
|
||||
}
|
||||
|
||||
// Dump implements Node.Dump.
|
||||
func (n *Attention) Dump(source []byte, level int) {
|
||||
m := map[string]string{}
|
||||
m["AttentionType"] = n.AttentionType
|
||||
ast.DumpHelper(n, source, level, m, nil)
|
||||
}
|
||||
|
||||
// KindAttention is the NodeKind for Attention
|
||||
var KindAttention = ast.NewNodeKind("Attention")
|
||||
|
||||
// Kind implements Node.Kind.
|
||||
func (n *Attention) Kind() ast.NodeKind {
|
||||
return KindAttention
|
||||
}
|
||||
|
||||
// NewAttention returns a new Attention node.
|
||||
func NewAttention(attentionType string) *Attention {
|
||||
return &Attention{
|
||||
BaseInline: ast.BaseInline{},
|
||||
AttentionType: attentionType,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue