diff options
author | Wim <wim@42.be> | 2019-01-06 22:25:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-06 22:25:19 +0100 |
commit | 04567c765e92ad60c685c1b2fe7e77c46e065645 (patch) | |
tree | 34a587a6545c8e71e991e2a1551885faa0075738 /vendor/gitlab.com/golang-commonmark/linkify/charset.go | |
parent | 048158ad6db08cd714f39467fc0066ce41cfe6c5 (diff) | |
download | matterbridge-msglm-04567c765e92ad60c685c1b2fe7e77c46e065645.tar.gz matterbridge-msglm-04567c765e92ad60c685c1b2fe7e77c46e065645.tar.bz2 matterbridge-msglm-04567c765e92ad60c685c1b2fe7e77c46e065645.zip |
Add support for markdown to HTML conversion (matrix). Closes #663 (#670)
This uses our own gomatrix lib with the SendHTML function which
adds HTML to formatted_body in matrix.
golang-commonmark is used to convert markdown into valid HTML.
Diffstat (limited to 'vendor/gitlab.com/golang-commonmark/linkify/charset.go')
-rw-r--r-- | vendor/gitlab.com/golang-commonmark/linkify/charset.go | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/vendor/gitlab.com/golang-commonmark/linkify/charset.go b/vendor/gitlab.com/golang-commonmark/linkify/charset.go new file mode 100644 index 00000000..7ea3b625 --- /dev/null +++ b/vendor/gitlab.com/golang-commonmark/linkify/charset.go @@ -0,0 +1,51 @@ +// Copyright 2015 The Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package linkify + +import ( + "unicode" + + "golang.org/x/text/unicode/rangetable" +) + +var ( + unreserved = [256]bool{'-': true, '.': true, '_': true, '~': true} + basicPunct = [256]bool{'.': true, ',': true, '?': true, '!': true, ';': true, ':': true} + subdelims = [256]bool{'!': true, '$': true, '&': true, '\'': true, '(': true, ')': true, + '*': true, '+': true, ',': true, ';': true, '=': true} + emailcs = [256]bool{'a': true, 'b': true, 'c': true, 'd': true, 'e': true, 'f': true, 'g': true, + 'h': true, 'i': true, 'j': true, 'k': true, 'l': true, 'm': true, 'n': true, 'o': true, + 'p': true, 'q': true, 'r': true, 's': true, 't': true, 'u': true, 'v': true, 'w': true, + 'x': true, 'y': true, 'z': true, 'A': true, 'B': true, 'C': true, 'D': true, 'E': true, + 'F': true, 'G': true, 'H': true, 'I': true, 'J': true, 'K': true, 'L': true, 'M': true, + 'N': true, 'O': true, 'P': true, 'Q': true, 'R': true, 'S': true, 'T': true, 'U': true, + 'V': true, 'W': true, 'X': true, 'Y': true, 'Z': true, '0': true, '1': true, '2': true, + '3': true, '4': true, '5': true, '6': true, '7': true, '8': true, '9': true, '!': true, + '#': true, '$': true, '%': true, '&': true, '\'': true, '*': true, '+': true, '/': true, + '=': true, '?': true, '^': true, '_': true, '`': true, '{': true, '|': true, '}': true, + '~': true, '-': true} + letterOrDigit = rangetable.Merge(unicode.Letter, unicode.Digit) + punctSpaceCc = rangetable.Merge(unicode.Punct, unicode.Space, unicode.Cc) +) + +func isAllowedInEmail(r rune) bool { + return r < 0x7f && emailcs[r] +} + +func isLetterOrDigit(r rune) bool { + return unicode.Is(letterOrDigit, r) +} + +func isPunctOrSpaceOrControl(r rune) bool { + return r == '<' || r == '>' || r == '\uff5c' || unicode.Is(punctSpaceCc, r) +} + +func isUnreserved(r rune) bool { + return (r < 0x7f && unreserved[r]) || unicode.Is(letterOrDigit, r) +} + +func isSubDelimiter(r rune) bool { + return r < 0x7f && subdelims[r] +} |