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)
| 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 :). |