aboutsummaryrefslogtreecommitdiff
path: root/vendor/gopkg.in/russross/blackfriday.v2/esc.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/gopkg.in/russross/blackfriday.v2/esc.go')
-rw-r--r--vendor/gopkg.in/russross/blackfriday.v2/esc.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/vendor/gopkg.in/russross/blackfriday.v2/esc.go b/vendor/gopkg.in/russross/blackfriday.v2/esc.go
new file mode 100644
index 0000000..6385f27
--- /dev/null
+++ b/vendor/gopkg.in/russross/blackfriday.v2/esc.go
@@ -0,0 +1,34 @@
+package blackfriday
+
+import (
+ "html"
+ "io"
+)
+
+var htmlEscaper = [256][]byte{
+ '&': []byte("&"),
+ '<': []byte("&lt;"),
+ '>': []byte("&gt;"),
+ '"': []byte("&quot;"),
+}
+
+func escapeHTML(w io.Writer, s []byte) {
+ var start, end int
+ for end < len(s) {
+ escSeq := htmlEscaper[s[end]]
+ if escSeq != nil {
+ w.Write(s[start:end])
+ w.Write(escSeq)
+ start = end + 1
+ }
+ end++
+ }
+ if start < len(s) && end <= len(s) {
+ w.Write(s[start:end])
+ }
+}
+
+func escLink(w io.Writer, text []byte) {
+ unesc := html.UnescapeString(string(text))
+ escapeHTML(w, []byte(unesc))
+}