Debian Codegraph @

third_party/python/markdown_it_py/markdown_it/rules_inline/text.py

raw
1 # Skip text characters for text token, place those to pending buffer
2 # and increment current pos
3 from .state_inline import StateInline
4
5 # Rule to skip pure text
6 # '{}$%@~+=:' reserved for extensions
7
8 # !!!! Don't confuse with "Markdown ASCII Punctuation" chars
9 # http://spec.commonmark.org/0.15/#ascii-punctuation-character
10
11
12 _TerminatorChars = {
13 "\n",
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 def text(state: StateInline, silent: bool) -> bool:
40 pos = state.pos
41 posMax = state.posMax
42 while (pos < posMax) and state.src[pos] not in _TerminatorChars:
43 pos += 1
44
45 if pos == state.pos:
46 return False
47
48 if not silent:
49 state.pending += state.src[state.pos : pos]
50
51 state.pos = pos
52
53 return True