all repos — grayfriday @ 4a17a5b58fa863811b2377d0553d59471b244d44

blackfriday fork with a few changes

remove dependency on less function
Russ Ross russ@russross.com
Mon, 30 May 2011 14:42:38 -0600
commit

4a17a5b58fa863811b2377d0553d59471b244d44

parent

cd7b9521488b24c6f4ff98c55452879cf73b8e98

2 files changed, 1 insertions(+), 29 deletions(-)

jump to
M inline.goinline.go

@@ -634,7 +634,7 @@ func isSafeLink(link []byte) bool {

for _, prefix := range validUris { // TODO: handle unicode here // case-insensitive prefix test - if len(link) > len(prefix) && !less(link[:len(prefix)], prefix) && !less(prefix, link[:len(prefix)]) && isalnum(link[len(prefix)]) { + if len(link) > len(prefix) && bytes.Equal(bytes.ToLower(link[:len(prefix)]), prefix) && isalnum(link[len(prefix)]) { return true } }
M markdown.gomarkdown.go

@@ -14,7 +14,6 @@ package blackfriday

import ( "bytes" - "unicode" ) // These are the supported markdown parsing extensions.

@@ -273,33 +272,6 @@ // References are parsed and stored in this struct.

type reference struct { link []byte title []byte -} - -// Compare two []byte values (case-insensitive), returning -// true if a is less than b. -func less(a []byte, b []byte) bool { - // adapted from bytes.Compare in stdlib - m := len(a) - if m > len(b) { - m = len(b) - } - for i, ac := range a[0:m] { - // do a case-insensitive comparison - ai, bi := unicode.ToLower(int(ac)), unicode.ToLower(int(b[i])) - switch { - case ai > bi: - return false - case ai < bi: - return true - } - } - switch { - case len(a) < len(b): - return true - case len(a) > len(b): - return false - } - return false } // Check whether or not data starts with a reference link.