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

Method parse

markdown_it/main.py:252–273  ·  view source on GitHub ↗

Parse the source string to a token stream :param src: source string :param env: environment sandbox Parse input string and return list of block tokens (special token type "inline" will contain list of inline tokens). `env` is used to pass data between "dist

(self, src: str, env: EnvType | None = None)

Source from the content-addressed store, hash-verified

250 return self
251
252 def parse(self, src: str, env: EnvType | None = None) -> list[Token]:
253 """Parse the source string to a token stream
254
255 :param src: source string
256 :param env: environment sandbox
257
258 Parse input string and return list of block tokens (special token type
259 "inline" will contain list of inline tokens).
260
261 `env` is used to pass data between "distributed" rules and return additional
262 metadata like reference info, needed for the renderer. It also can be used to
263 inject data in specific cases. Usually, you will be ok to pass `{}`,
264 and then pass updated object to renderer.
265 """
266 env = {} if env is None else env
267 if not isinstance(env, MutableMapping):
268 raise TypeError(f"Input data should be a MutableMapping, not {type(env)}")
269 if not isinstance(src, str):
270 raise TypeError(f"Input data should be a string, not {type(src)}")
271 state = StateCore(src, self, env)
272 self.core.process(state)
273 return state.tokens
274
275 def render(self, src: str, env: EnvType | None = None) -> Any:
276 """Render markdown string into html. It does all magic for you :).

Callers 15

renderMethod · 0.95
test_fuzzingFunction · 0.95
test_prettyFunction · 0.95
test_pretty_text_specialFunction · 0.95
test_ordered_list_infoFunction · 0.95
test_ref_definitionsFunction · 0.95
test_use_existing_envFunction · 0.95
test_store_labelsFunction · 0.95
test_inline_definitionsFunction · 0.95

Calls 2

StateCoreClass · 0.85
processMethod · 0.80

Tested by 15

test_fuzzingFunction · 0.76
test_prettyFunction · 0.76
test_pretty_text_specialFunction · 0.76
test_ordered_list_infoFunction · 0.76
test_ref_definitionsFunction · 0.76
test_use_existing_envFunction · 0.76
test_store_labelsFunction · 0.76
test_inline_definitionsFunction · 0.76