Main parser class :param config: name of configuration to load or a pre-defined dictionary :param options_update: dictionary that will be merged into ``config["options"]`` :param renderer_cls: the class to load as the renderer: ``self.renderer = renderer_cls(self
(
self,
config: str | PresetType = "commonmark",
options_update: Mapping[str, Any] | None = None,
*,
renderer_cls: Callable[[MarkdownIt], RendererProtocol] = RendererHTML,
)
| 32 | |
| 33 | class MarkdownIt: |
| 34 | def __init__( |
| 35 | self, |
| 36 | config: str | PresetType = "commonmark", |
| 37 | options_update: Mapping[str, Any] | None = None, |
| 38 | *, |
| 39 | renderer_cls: Callable[[MarkdownIt], RendererProtocol] = RendererHTML, |
| 40 | ): |
| 41 | """Main parser class |
| 42 | |
| 43 | :param config: name of configuration to load or a pre-defined dictionary |
| 44 | :param options_update: dictionary that will be merged into ``config["options"]`` |
| 45 | :param renderer_cls: the class to load as the renderer: |
| 46 | ``self.renderer = renderer_cls(self) |
| 47 | """ |
| 48 | # add modules |
| 49 | self.utils = utils |
| 50 | self.helpers = helpers |
| 51 | |
| 52 | # initialise classes |
| 53 | self.inline = ParserInline() |
| 54 | self.block = ParserBlock() |
| 55 | self.core = ParserCore() |
| 56 | self.renderer = renderer_cls(self) |
| 57 | self.linkify = linkify_it.LinkifyIt() if linkify_it else None |
| 58 | |
| 59 | # set the configuration |
| 60 | if options_update and not isinstance(options_update, Mapping): |
| 61 | # catch signature change where renderer_cls was not used as a key-word |
| 62 | raise TypeError( |
| 63 | f"options_update should be a mapping: {options_update}" |
| 64 | "\n(Perhaps you intended this to be the renderer_cls?)" |
| 65 | ) |
| 66 | self.configure(config, options_update=options_update) |
| 67 | |
| 68 | def __repr__(self) -> str: |
| 69 | return f"{self.__class__.__module__}.{self.__class__.__name__}()" |
nothing calls this directly
no test coverage detected