-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalert.go
More file actions
61 lines (46 loc) · 1.88 KB
/
alert.go
File metadata and controls
61 lines (46 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package markdown
import (
"fmt"
"github.com/yuin/goldmark/ast"
)
func (m *Markdown) callout(label, text string) *Markdown {
blockquote := ast.NewBlockquote()
head := ast.NewParagraph()
head.AppendChild(head, ast.NewString([]byte(label+" ")))
blockquote.AppendChild(blockquote, head)
body := ast.NewParagraph()
body.AppendChild(body, ast.NewString([]byte(text)))
blockquote.AppendChild(blockquote, body)
m.appendBlock(blockquote)
return m
}
// Note set text with note format.
func (m *Markdown) Note(text string) *Markdown { return m.callout("[!NOTE]", text) }
// Notef set text with note format.
func (m *Markdown) Notef(format string, args ...interface{}) *Markdown {
return m.Note(fmt.Sprintf(format, args...))
}
// Tip set text with tip format.
func (m *Markdown) Tip(text string) *Markdown { return m.callout("[!TIP]", text) }
// Tipf set text with tip format.
func (m *Markdown) Tipf(format string, args ...interface{}) *Markdown {
return m.Tip(fmt.Sprintf(format, args...))
}
// Important set text with important format.
func (m *Markdown) Important(text string) *Markdown { return m.callout("[!IMPORTANT]", text) }
// Importantf set text with important format.
func (m *Markdown) Importantf(format string, args ...interface{}) *Markdown {
return m.Important(fmt.Sprintf(format, args...))
}
// Warning set text with warning format.
func (m *Markdown) Warning(text string) *Markdown { return m.callout("[!WARNING]", text) }
// Warningf set text with warning format.
func (m *Markdown) Warningf(format string, args ...interface{}) *Markdown {
return m.Warning(fmt.Sprintf(format, args...))
}
// Caution set text with caution format.
func (m *Markdown) Caution(text string) *Markdown { return m.callout("[!CAUTION]", text) }
// Cautionf set text with caution format.
func (m *Markdown) Cautionf(format string, args ...interface{}) *Markdown {
return m.Caution(fmt.Sprintf(format, args...))
}