summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/gomarkdown/markdown/html/callouts.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/html/callouts.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/html/callouts.go')
-rw-r--r--vendor/github.com/gomarkdown/markdown/html/callouts.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/vendor/github.com/gomarkdown/markdown/html/callouts.go b/vendor/github.com/gomarkdown/markdown/html/callouts.go
new file mode 100644
index 00000000..e377af22
--- /dev/null
+++ b/vendor/github.com/gomarkdown/markdown/html/callouts.go
@@ -0,0 +1,42 @@
+package html
+
+import (
+ "bytes"
+ "io"
+
+ "github.com/gomarkdown/markdown/ast"
+ "github.com/gomarkdown/markdown/parser"
+)
+
+// EscapeHTMLCallouts writes html-escaped d to w. It escapes &, <, > and " characters, *but*
+// expands callouts <<N>> with the callout HTML, i.e. by calling r.callout() with a newly created
+// ast.Callout node.
+func (r *Renderer) EscapeHTMLCallouts(w io.Writer, d []byte) {
+ ld := len(d)
+Parse:
+ for i := 0; i < ld; i++ {
+ for _, comment := range r.opts.Comments {
+ if !bytes.HasPrefix(d[i:], comment) {
+ break
+ }
+
+ lc := len(comment)
+ if i+lc < ld {
+ if id, consumed := parser.IsCallout(d[i+lc:]); consumed > 0 {
+ // We have seen a callout
+ callout := &ast.Callout{ID: id}
+ r.callout(w, callout)
+ i += consumed + lc - 1
+ continue Parse
+ }
+ }
+ }
+
+ escSeq := Escaper[d[i]]
+ if escSeq != nil {
+ w.Write(escSeq)
+ } else {
+ w.Write([]byte{d[i]})
+ }
+ }
+}