-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextend.go
49 lines (45 loc) · 1.19 KB
/
extend.go
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
package admonitions
import (
"github.com/yuin/goldmark"
"github.com/yuin/goldmark/parser"
"github.com/yuin/goldmark/renderer"
"github.com/yuin/goldmark/util"
)
// This extender allows you to use admonitions in markdown
//
// Admonitions are a markdown extension that allows you to style markdown as
// nice boxes with a title. This is done by way of wrapping other elements in
// divs with classes starting with "adm-"
//
// !!!note This is the title {.some-additional-class}
// This is the admonition
//
// ## with a header
//
// !!!danger Nesting is possible!
// ```R
// X <- as.data.table(iris)
// X[Species != "virginica", mean(Sepal.Length), Species]
// ```
// !!!
// !!!
type Extender struct {
priority int // optional int != 0. the priority value for parser and renderer. Defaults to 100.
}
// This implements the Extend method for goldmark-admonitions.Extender
func (e *Extender) Extend(md goldmark.Markdown) {
priority := 100
if e.priority != 0 {
priority = e.priority
}
md.Parser().AddOptions(
parser.WithBlockParsers(
util.Prioritized(&admonitionParser{}, priority),
),
)
md.Renderer().AddOptions(
renderer.WithNodeRenderers(
util.Prioritized(&Renderer{}, priority),
),
)
}