File: comment.go

package info (click to toggle)
mmark 2.2.25%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 996 kB
  • sloc: xml: 228; makefile: 81; ansic: 3
file content (35 lines) | stat: -rw-r--r-- 746 bytes parent folder | download
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
}