summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/gomarkdown/markdown/parser/matter.go
diff options
context:
space:
mode:
authorBenjamin <b.mpickford@outlook.com>2019-11-18 06:18:01 +1000
committerWim <wim@42.be>2019-11-17 21:18:01 +0100
commit0917dc876613fd71c9726a34bf0138b4f5121be9 (patch)
tree1eacaadaa4869e8f74ccf65c684c2a80f90787f9 /vendor/github.com/gomarkdown/markdown/parser/matter.go
parentaba86855b5f71c9809d892a7eebc6b69872fcd5b (diff)
downloadmatterbridge-msglm-0917dc876613fd71c9726a34bf0138b4f5121be9.tar.gz
matterbridge-msglm-0917dc876613fd71c9726a34bf0138b4f5121be9.tar.bz2
matterbridge-msglm-0917dc876613fd71c9726a34bf0138b4f5121be9.zip
Update markdown parsing library to github.com/gomarkdown/markdown (#944)
Diffstat (limited to 'vendor/github.com/gomarkdown/markdown/parser/matter.go')
-rw-r--r--vendor/github.com/gomarkdown/markdown/parser/matter.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/vendor/github.com/gomarkdown/markdown/parser/matter.go b/vendor/github.com/gomarkdown/markdown/parser/matter.go
new file mode 100644
index 00000000..92686357
--- /dev/null
+++ b/vendor/github.com/gomarkdown/markdown/parser/matter.go
@@ -0,0 +1,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
+}