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

Method __init__

markdown_it/main.py:34–66  ·  view source on GitHub ↗

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,
    )

Source from the content-addressed store, hash-verified

32
33class 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__}()"

Callers

nothing calls this directly

Calls 4

configureMethod · 0.95
ParserInlineClass · 0.85
ParserBlockClass · 0.85
ParserCoreClass · 0.85

Tested by

no test coverage detected