summaryrefslogtreecommitdiffstats
path: root/vendor/gitlab.com/golang-commonmark/markdown/text.go
blob: ae98e74355e3e9ad185da5c315bebaa4871ae779 (plain) (blame)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2015 The Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package markdown

var terminatorCharTable = [256]bool{
	'\n': true,
	'!':  true,
	'#':  true,
	'$':  true,
	'%':  true,
	'&':  true,
	'*':  true,
	'+':  true,
	'-':  true,
	':':  true,
	'<':  true,
	'=':  true,
	'>':  true,
	'@':  true,
	'[':  true,
	'\\': true,
	']':  true,
	'^':  true,
	'_':  true,
	'`':  true,
	'{':  true,
	'}':  true,
	'~':  true,
}

func ruleText(s *StateInline, silent bool) bool {
	pos := s.Pos
	max := s.PosMax
	src := s.Src

	for pos < max && !terminatorCharTable[src[pos]] {
		pos++
	}
	if pos == s.Pos {
		return false
	}

	if !silent {
		s.Pending.WriteString(src[s.Pos:pos])
	}

	s.Pos = pos

	return true
}