Update markdown parsing library to github.com/gomarkdown/markdown (#944)

This commit is contained in:
Benjamin
2019-11-18 06:18:01 +10:00
committed by Wim
parent aba86855b5
commit 0917dc8766
120 changed files with 8282 additions and 47873 deletions

View File

@@ -0,0 +1,29 @@
package parser
import (
"bytes"
"strconv"
)
// IsCallout detects a callout in the following format: <<N>> Where N is a integer > 0.
func IsCallout(data []byte) (id []byte, consumed int) {
if !bytes.HasPrefix(data, []byte("<<")) {
return nil, 0
}
start := 2
end := bytes.Index(data[start:], []byte(">>"))
if end < 0 {
return nil, 0
}
b := data[start : start+end]
b = bytes.TrimSpace(b)
i, err := strconv.Atoi(string(b))
if err != nil {
return nil, 0
}
if i <= 0 {
return nil, 0
}
return b, start + end + 2 // 2 for >>
}