Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions markdown_it/rules_inline/text.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import functools
import re

# Skip text characters for text token, place those to pending buffer
# and increment current pos
from .state_inline import StateInline
Expand Down Expand Up @@ -36,11 +39,17 @@
}


@functools.cache
def _terminator_char_regex() -> re.Pattern[str]:
return re.compile("[" + re.escape("".join(_TerminatorChars)) + "]")


def text(state: StateInline, silent: bool) -> bool:
pos = state.pos
posMax = state.posMax
while (pos < posMax) and state.src[pos] not in _TerminatorChars:
pos += 1

terminator_char = _terminator_char_regex().search(state.src, pos)
pos = terminator_char.start() if terminator_char else posMax

if pos == state.pos:
return False
Expand Down
Loading