diff --git a/html.go b/html.go
index 23e86dd..3ece7e5 100644
--- a/html.go
+++ b/html.go
@@ -123,6 +123,13 @@ func HtmlTocRenderer(flags int) *Renderer {
func attrEscape(out *bytes.Buffer, src []byte) {
org := 0
for i, ch := range src {
+ // doing this check is a bit faster than falling into
+ // the switch statement. as the compiler improves, this
+ // should be unnecessary
+ if ch != '"' && ch != '&' && ch != '<' && ch != '>' {
+ continue
+ }
+
switch ch {
case '<':
if i > org {