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

Class InlineProcessor

markdown/inlinepatterns.py:283–328  ·  view source on GitHub ↗

Base class that inline processors subclass. This is the newer style inline processor that uses a more efficient and flexible search approach.

Source from the content-addressed store, hash-verified

281
282
283class InlineProcessor(Pattern):
284 """
285 Base class that inline processors subclass.
286
287 This is the newer style inline processor that uses a more
288 efficient and flexible search approach.
289
290 """
291
292 def __init__(self, pattern: str, md: Markdown | None = None):
293 """
294 Create an instant of an inline processor.
295
296 Arguments:
297 pattern: A regular expression that matches a pattern.
298 md: An optional pointer to the instance of `markdown.Markdown` and is available as
299 `self.md` on the class instance.
300
301 """
302 self.pattern = pattern
303 self.compiled_re = re.compile(pattern, re.DOTALL | re.UNICODE)
304
305 # API for Markdown to pass `safe_mode` into instance
306 self.safe_mode = False
307 self.md = md
308
309 def handleMatch(self, m: re.Match[str], data: str) -> tuple[etree.Element | str | None, int | None, int | None]:
310 """Return a ElementTree element from the given match and the
311 start and end index of the matched text.
312
313 If `start` and/or `end` are returned as `None`, it will be
314 assumed that the processor did not find a valid region of text.
315
316 Subclasses should override this method.
317
318 Arguments:
319 m: A re match object containing a match of the pattern.
320 data: The buffer currently under analysis.
321
322 Returns:
323 el: The ElementTree element, text or None.
324 start: The start of the region that has been matched or None.
325 end: The end of the region that has been matched or None.
326
327 """
328 pass # pragma: no cover
329
330
331class SimpleTextPattern(Pattern): # pragma: no cover

Callers 1

extendMarkdownMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected