blob: 92686357234eb860e04e75e70643c511d5d0e1f9 (
plain) (
blame)
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
|
package parser
import (
"bytes"
"github.com/gomarkdown/markdown/ast"
)
func (p *Parser) documentMatter(data []byte) int {
if data[0] != '{' {
return 0
}
consumed := 0
matter := ast.DocumentMatterNone
if bytes.HasPrefix(data, []byte("{frontmatter}")) {
consumed = len("{frontmatter}")
matter = ast.DocumentMatterFront
}
if bytes.HasPrefix(data, []byte("{mainmatter}")) {
consumed = len("{mainmatter}")
matter = ast.DocumentMatterMain
}
if bytes.HasPrefix(data, []byte("{backmatter}")) {
consumed = len("{backmatter}")
matter = ast.DocumentMatterBack
}
if consumed == 0 {
return 0
}
node := &ast.DocumentMatter{Matter: matter}
p.addBlock(node)
p.finalize(node)
return consumed
}
|