MCPcopy
hub / github.com/russross/blackfriday / tagLength

Function tagLength

inline.go:931–1005  ·  view source on GitHub ↗

return the length of the given tag, or 0 is it's not valid

(data []byte)

Source from the content-addressed store, hash-verified

929
930// return the length of the given tag, or 0 is it's not valid
931func tagLength(data []byte) (autolink autolinkType, end int) {
932 var i, j int
933
934 // a valid tag can't be shorter than 3 chars
935 if len(data) < 3 {
936 return notAutolink, 0
937 }
938
939 // begins with a '<' optionally followed by '/', followed by letter or number
940 if data[0] != '<' {
941 return notAutolink, 0
942 }
943 if data[1] == '/' {
944 i = 2
945 } else {
946 i = 1
947 }
948
949 if !isalnum(data[i]) {
950 return notAutolink, 0
951 }
952
953 // scheme test
954 autolink = notAutolink
955
956 // try to find the beginning of an URI
957 for i < len(data) && (isalnum(data[i]) || data[i] == '.' || data[i] == '+' || data[i] == '-') {
958 i++
959 }
960
961 if i > 1 && i < len(data) && data[i] == '@' {
962 if j = isMailtoAutoLink(data[i:]); j != 0 {
963 return emailAutolink, i + j
964 }
965 }
966
967 if i > 2 && i < len(data) && data[i] == ':' {
968 autolink = normalAutolink
969 i++
970 }
971
972 // complete autolink test: no whitespace or ' or "
973 switch {
974 case i >= len(data):
975 autolink = notAutolink
976 case autolink != notAutolink:
977 j = i
978
979 for i < len(data) {
980 if data[i] == '\\' {
981 i += 2
982 } else if data[i] == '>' || data[i] == '\'' || data[i] == '"' || isspace(data[i]) {
983 break
984 } else {
985 i++
986 }
987
988 }

Callers 1

leftAngleFunction · 0.85

Calls 3

isalnumFunction · 0.85
isMailtoAutoLinkFunction · 0.85
isspaceFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…