summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/gomarkdown/markdown/parser/esc.go
blob: 0a79aa35ecff3175d5ba734fae977a5268febca8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package parser

// isEscape returns true if byte i is prefixed by an odd number of backslahses.
func isEscape(data []byte, i int) bool {
	if i == 0 {
		return false
	}
	if i == 1 {
		return data[0] == '\\'
	}
	j := i - 1
	for ; j >= 0; j-- {
		if data[j] != '\\' {
			break
		}
	}
	j++
	// odd number of backslahes means escape
	return (i-j)%2 != 0
}