-
Notifications
You must be signed in to change notification settings - Fork 0
/
footer.go
46 lines (40 loc) · 1.07 KB
/
footer.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
package renderer
import (
"io"
"github.com/gomarkdown/markdown/ast"
"github.com/gomarkdown/markdown/html"
)
// RenderFooter writes HTML document footer.
func (r *Renderer) RenderFooter(w io.Writer, _ ast.Node) {
if r.state.documentMatter != ast.DocumentMatterNone {
r.Outs(w, "</section>\n")
}
if r.h != nil && r.h.isUsed {
err := r.h.renderCSS(w)
if err != nil {
r.logger.Warn("CSS render error", err)
}
}
if r.Opts.Flags&html.CompletePage == 0 {
return
}
io.WriteString(w, "\n</body>\n</html>\n")
}
// DocumentMatter just copies parent method using child's `state` property
func (r *Renderer) DocumentMatter(w io.Writer, node *ast.DocumentMatter, entering bool) {
if !entering {
return
}
if r.state.documentMatter != ast.DocumentMatterNone {
r.Outs(w, "</section>\n")
}
switch node.Matter {
case ast.DocumentMatterFront:
r.Outs(w, `<section data-matter="front">`)
case ast.DocumentMatterMain:
r.Outs(w, `<section data-matter="main">`)
case ast.DocumentMatterBack:
r.Outs(w, `<section data-matter="back">`)
}
r.state.documentMatter = node.Matter
}