Extract repetitive code to a func

This commit is contained in:
Vytautas Šaltenis 2013-04-13 22:26:29 +03:00
parent d5a8df164b
commit a2fda5e98f
1 changed files with 9 additions and 7 deletions

16
html.go
View File

@ -651,18 +651,13 @@ func isHtmlTag(tag []byte, tagname string) bool {
return false
}
i++
for i < len(tag) && isspace(tag[i]) {
i++
}
i = skipSpace(tag, i)
if i < len(tag) && tag[i] == '/' {
i++
}
for i < len(tag) && isspace(tag[i]) {
i++
}
i = skipSpace(tag, i)
j := 0
for ; i < len(tag); i, j = i+1, j+1 {
if j >= len(tagname) {
@ -681,6 +676,13 @@ func isHtmlTag(tag []byte, tagname string) bool {
return isspace(tag[i]) || tag[i] == '>'
}
func skipSpace(tag []byte, i int) int {
for i < len(tag) && isspace(tag[i]) {
i++
}
return i
}
func doubleSpace(out *bytes.Buffer) {
if out.Len() > 0 {
out.WriteByte('\n')