We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9616588 commit 50c9f07Copy full SHA for 50c9f07
markdown_it/rules_inline/text.py
@@ -1,3 +1,4 @@
1
+import functools
2
import re
3
4
# Skip text characters for text token, place those to pending buffer
@@ -36,14 +37,18 @@
36
37
"}",
38
"~",
39
}
-_RE_TERMINATOR_CHAR = re.compile("[" + re.escape("".join(_TerminatorChars)) + "]")
40
+
41
42
+@functools.cache
43
+def _terminator_char_regex() -> re.Pattern[str]:
44
+ return re.compile("[" + re.escape("".join(_TerminatorChars)) + "]")
45
46
47
def text(state: StateInline, silent: bool) -> bool:
48
pos = state.pos
49
posMax = state.posMax
50
- terminator_char = _RE_TERMINATOR_CHAR.search(state.src, pos)
51
+ terminator_char = _terminator_char_regex().search(state.src, pos)
52
pos = terminator_char.start() if terminator_char else posMax
53
54
if pos == state.pos:
0 commit comments