diff --git a/markitzero.go b/markitzero.go
index b315e26..b918cdb 100644
--- a/markitzero.go
+++ b/markitzero.go
@@ -29,7 +29,7 @@ var re_italicer = regexp.MustCompile(`(^|\W)\*([\w\s,.!?':_-]+)\*($|\W)`)
var re_bigcoder = regexp.MustCompile("```(.*)\n?((?s:.*?))\n?```\n?")
var re_coder = regexp.MustCompile("`([^`]*)`")
var re_quoter = regexp.MustCompile(`(?m:^> (.*)\n?)`)
-var re_link = regexp.MustCompile(`.?.?https?://[^\s"]+[\w/)]`)
+var re_link = regexp.MustCompile(`.?.?https?://[^\s"]+[\w/)!]`)
var re_zerolink = regexp.MustCompile(`\[([^]]*)\]\(([^)]*\)?)\)`)
var lighter = synlight.New(synlight.Options{Format: synlight.HTML})
@@ -50,8 +50,21 @@ func markitzero(s string) string {
return "`x`"
})
- s = html.EscapeString(s)
- s = strings.Replace(s, "'", "'", -1) // dammit go
+ // fewer side effects than html.EscapeString
+ buf := make([]byte, 0, len(s))
+ for _, c := range []byte(s) {
+ switch c {
+ case '&':
+ buf = append(buf, []byte("&")...)
+ case '<':
+ buf = append(buf, []byte("<")...)
+ case '>':
+ buf = append(buf, []byte(">")...)
+ default:
+ buf = append(buf, c)
+ }
+ }
+ s = string(buf)
// mark it zero
s = re_bolder.ReplaceAllString(s, "$1$2$3")
diff --git a/markitzero_test.go b/markitzero_test.go
index 0a00e29..5cdd3a6 100644
--- a/markitzero_test.go
+++ b/markitzero_test.go
@@ -58,3 +58,16 @@ func TestWikilink(t *testing.T) {
output := `I watched Hackers`
doonezerotest(t, input, output)
}
+
+func TestQuotedlink(t *testing.T) {
+ input := `quoted "https://example.com/link" here`
+ output := `quoted "https://example.com/link" here`
+ doonezerotest(t, input, output)
+}
+
+func TestHonklink(t *testing.T) {
+ input := `https://en.wikipedia.org/wiki/Honk!`
+ output := `https://en.wikipedia.org/wiki/Honk!`
+ doonezerotest(t, input, output)
+}
+