-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
25 lines (19 loc) · 761 Bytes
/
main.go
File metadata and controls
25 lines (19 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package main
import (
"os"
"fmt"
"regexp"
"github.com/microcosm-cc/bluemonday"
)
func main() {
p := bluemonday.NewPolicy()
p.AllowElements("p", "h3", "strong", "em", "u", "s", "span", "ol", "ul", "li", "blockquote", "pre", "br")
p.AllowStandardURLs()
p.AddTargetBlankToFullyQualifiedLinks(true)
p.AllowAttrs("href").OnElements("a")
p.AllowAttrs("class").Matching(regexp.MustCompile("^ql-align-(center|right|justify)$")).Globally()
p.AllowAttrs("spellcheck").Matching(regexp.MustCompile("^false$")).OnElements("pre")
p.AllowStyles("color", "background-color").Matching(regexp.MustCompile(`^rgb\([0-9]{1,3}, [0-9]{1,3}, [0-9]{1,3}\)$`)).Globally()
html := p.SanitizeReader(os.Stdin)
fmt.Print(html)
}