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

Method run

markdown/extensions/abbr.py:128–138  ·  view source on GitHub ↗

Step through tree to find known abbreviations.

(self, root: etree.Element)

Source from the content-addressed store, hash-verified

126 el.tail = tail
127
128 def run(self, root: etree.Element) -> etree.Element | None:
129 ''' Step through tree to find known abbreviations. '''
130 if not self.abbrs:
131 # No abbreviations defined. Skip running processor.
132 return
133 # Build and compile regex
134 abbr_list = list(self.abbrs.keys())
135 abbr_list.sort(key=len, reverse=True)
136 self.RE = re.compile(f"\\b(?:{ '|'.join(re.escape(key) for key in abbr_list) })\\b")
137 # Step through tree and modify on matches
138 self.iter_element(root)
139
140
141class AbbrBlockprocessor(BlockProcessor):

Callers

nothing calls this directly

Calls 1

iter_elementMethod · 0.95

Tested by

no test coverage detected