MCPcopy Create free account
hub / github.com/Python-Markdown/markdown / __init__

Method __init__

markdown/extensions/toc.py:264–287  ·  view source on GitHub ↗
(self, md: Markdown, config: dict[str, Any])

Source from the content-addressed store, hash-verified

262 """ Step through document and build TOC. """
263
264 def __init__(self, md: Markdown, config: dict[str, Any]):
265 super().__init__(md)
266
267 self.marker: str = config["marker"]
268 self.title: str = config["title"]
269 self.base_level = int(config["baselevel"]) - 1
270 self.slugify = config["slugify"]
271 self.sep = config["separator"]
272 self.toc_class = config["toc_class"]
273 self.title_class: str = config["title_class"]
274 self.use_anchors: bool = parseBoolValue(config["anchorlink"])
275 self.anchorlink_class: str = config["anchorlink_class"]
276 self.use_permalinks = parseBoolValue(config["permalink"], False)
277 if self.use_permalinks is None:
278 self.use_permalinks = config["permalink"]
279 self.permalink_class: str = config["permalink_class"]
280 self.permalink_title: str = config["permalink_title"]
281 self.permalink_leading: bool | None = parseBoolValue(config["permalink_leading"], False)
282 self.header_rgx = re.compile("[Hh][123456]")
283 if isinstance(config["toc_depth"], str) and '-' in config["toc_depth"]:
284 self.toc_top, self.toc_bottom = [int(x) for x in config["toc_depth"].split('-')]
285 else:
286 self.toc_top = 1
287 self.toc_bottom = int(config["toc_depth"])
288
289 def iterparent(self, node: etree.Element) -> Iterator[tuple[etree.Element, etree.Element]]:
290 """ Iterator wrapper to get allowed parent and child all at once. """

Callers

nothing calls this directly

Calls 2

parseBoolValueFunction · 0.85
__init__Method · 0.45

Tested by

no test coverage detected