1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
package xml
import "bytes"
// Iscomment detects if a html span is a comment: <!-- .... --!>. Return the comment text and true is so.
func IsComment(data []byte) ([]byte, bool) {
if !bytes.HasPrefix(data, []byte("<!--")) {
return nil, false
}
if !bytes.HasSuffix(data, []byte("-->")) {
return nil, false
}
return data[5 : len(data)-4], true
}
func IsBr(data []byte) bool {
// <br> <br/> <br /> and <br></br> are recognized
if bytes.Equal(data, []byte("<br>")) {
return true
}
if bytes.Equal(data, []byte("<br >")) {
return true
}
if bytes.Equal(data, []byte("<br/>")) {
return true
}
if bytes.Equal(data, []byte("<br />")) {
return true
}
if bytes.Equal(data, []byte("<br></br>")) {
return true
}
return false
}
|