diff options
author | Yarden Shoham <hrsi88@gmail.com> | 2022-11-09 02:11:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-09 02:11:26 +0200 |
commit | cb83288530b1860677b07d72bc4ce8349e3c0d67 (patch) | |
tree | 704d9e7d178b0b1dd84d8a0cef7ac28f73e5c627 /modules/markup/markdown/ast.go | |
parent | 2ebab429347f04330dab9de5a730e0296ba6524b (diff) | |
download | gitea-cb83288530b1860677b07d72bc4ce8349e3c0d67.tar.gz gitea-cb83288530b1860677b07d72bc4ce8349e3c0d67.zip |
Add attention blocks within quote blocks for `Note` and `Warning` (#21711)
For each quote block, the first `**Note**` or `**Warning**` gets an icon
prepended to it and its text is colored accordingly. GitHub does this
(community/community#16925). [Initially requested on
Discord.](https://discord.com/channels/322538954119184384/322538954119184384/1038816475638661181)
### Before

### After

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: silverwind <me@silverwind.io>
Diffstat (limited to 'modules/markup/markdown/ast.go')
-rw-r--r-- | modules/markup/markdown/ast.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/modules/markup/markdown/ast.go b/modules/markup/markdown/ast.go index c82d5e5e73..3d49620253 100644 --- a/modules/markup/markdown/ast.go +++ b/modules/markup/markdown/ast.go @@ -180,3 +180,37 @@ func IsColorPreview(node ast.Node) bool { _, ok := node.(*ColorPreview) return ok } + +const ( + AttentionNote string = "Note" + AttentionWarning string = "Warning" +) + +// Attention is an inline for a color preview +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, + } +} |