summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/gomarkdown/markdown/parser/callout.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/gomarkdown/markdown/parser/callout.go')
-rw-r--r--vendor/github.com/gomarkdown/markdown/parser/callout.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/vendor/github.com/gomarkdown/markdown/parser/callout.go b/vendor/github.com/gomarkdown/markdown/parser/callout.go
new file mode 100644
index 00000000..15858aa9
--- /dev/null
+++ b/vendor/github.com/gomarkdown/markdown/parser/callout.go
@@ -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 >>
+}