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

Method run

markdown/extensions/abbr.py:127–137  ·  view source on GitHub ↗

Step through tree to find known abbreviations.

(self, root: etree.Element)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

iter_elementMethod · 0.95

Tested by

no test coverage detected