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

Method run

markdown/extensions/abbr.py:152–177  ·  view source on GitHub ↗

Find and remove all abbreviation references from the text. Each reference is added to the abbreviation collection.

(self, parent: etree.Element, blocks: list[str])

Source from the content-addressed store, hash-verified

150 return True
151
152 def run(self, parent: etree.Element, blocks: list[str]) -> bool:
153 """
154 Find and remove all abbreviation references from the text.
155 Each reference is added to the abbreviation collection.
156
157 """
158 block = blocks.pop(0)
159 m = self.RE.search(block)
160 if m:
161 abbr = m.group('abbr').strip()
162 title = m.group('title').strip()
163 if title and abbr:
164 if title == "''" or title == '""':
165 self.abbrs.pop(abbr)
166 else:
167 self.abbrs[abbr] = title
168 if block[m.end():].strip():
169 # Add any content after match back to blocks as separate block
170 blocks.insert(0, block[m.end():].lstrip('\n'))
171 if block[:m.start()].strip():
172 # Add any content before match back to blocks as separate block
173 blocks.insert(0, block[:m.start()].rstrip('\n'))
174 return True
175 # No match. Restore block.
176 blocks.insert(0, block)
177 return False
178
179
180AbbrPreprocessor = deprecated("This class has been renamed to `AbbrBlockprocessor`.")(AbbrBlockprocessor)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected