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

Method tokenize

markdown_it/parser_inline.py:174–204  ·  view source on GitHub ↗

Generate tokens for input range.

(self, state: StateInline)

Source from the content-addressed store, hash-verified

172 cache[pos] = state.pos
173
174 def tokenize(self, state: StateInline) -> None:
175 """Generate tokens for input range."""
176 ok = False
177 rules = self.ruler.getRules("")
178 end = state.posMax
179 maxNesting = state.md.options["maxNesting"]
180
181 while state.pos < end:
182 # Try all possible rules.
183 # On success, rule should:
184 #
185 # - update `state.pos`
186 # - update `state.tokens`
187 # - return true
188
189 if state.level < maxNesting:
190 for rule in rules:
191 ok = rule(state, False)
192 if ok:
193 break
194
195 if ok:
196 if state.pos >= end:
197 break
198 continue
199
200 state.pending += state.src[state.pos]
201 state.pos += 1
202
203 if state.pending:
204 state.pushPending()
205
206 def parse(
207 self, src: str, md: MarkdownIt, env: EnvType, tokens: list[Token]

Callers 1

parseMethod · 0.95

Calls 2

getRulesMethod · 0.80
pushPendingMethod · 0.80

Tested by

no test coverage detected