MCPcopy Create free account
hub / github.com/executablebooks/markdown-it-py / tokenize

Function tokenize

markdown_it/rules_inline/emphasis.py:8–37  ·  view source on GitHub ↗

Insert each marker as a separate text token, and add it to delimiter list

(state: StateInline, silent: bool)

Source from the content-addressed store, hash-verified

6
7
8def tokenize(state: StateInline, silent: bool) -> bool:
9 """Insert each marker as a separate text token, and add it to delimiter list"""
10 start = state.pos
11 marker = state.src[start]
12
13 if silent:
14 return False
15
16 if marker not in ("_", "*"):
17 return False
18
19 scanned = state.scanDelims(state.pos, marker == "*")
20
21 for _ in range(scanned.length):
22 token = state.push("text", "", 0)
23 token.content = marker
24 state.delimiters.append(
25 Delimiter(
26 marker=ord(marker),
27 length=scanned.length,
28 token=len(state.tokens) - 1,
29 end=-1,
30 open=scanned.can_open,
31 close=scanned.can_close,
32 )
33 )
34
35 state.pos += scanned.length
36
37 return True
38
39
40def _postProcess(state: StateInline, delimiters: list[Delimiter]) -> None:

Callers

nothing calls this directly

Calls 3

DelimiterClass · 0.85
scanDelimsMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…