Base class that inline processors subclass. This is the newer style inline processor that uses a more efficient and flexible search approach.
| 252 | |
| 253 | |
| 254 | class InlineProcessor(Pattern): |
| 255 | """ |
| 256 | Base class that inline processors subclass. |
| 257 | |
| 258 | This is the newer style inline processor that uses a more |
| 259 | efficient and flexible search approach. |
| 260 | |
| 261 | """ |
| 262 | |
| 263 | def __init__(self, pattern: str, md: Markdown | None = None): |
| 264 | """ |
| 265 | Create an instant of an inline processor. |
| 266 | |
| 267 | Arguments: |
| 268 | pattern: A regular expression that matches a pattern. |
| 269 | md: An optional pointer to the instance of `markdown.Markdown` and is available as |
| 270 | `self.md` on the class instance. |
| 271 | |
| 272 | """ |
| 273 | self.pattern = pattern |
| 274 | self.compiled_re = re.compile(pattern, re.DOTALL | re.UNICODE) |
| 275 | |
| 276 | # API for Markdown to pass `safe_mode` into instance |
| 277 | self.safe_mode = False |
| 278 | self.md = md |
| 279 | |
| 280 | def handleMatch(self, m: re.Match[str], data: str) -> tuple[etree.Element | str | None, int | None, int | None]: |
| 281 | """Return a ElementTree element from the given match and the |
| 282 | start and end index of the matched text. |
| 283 | |
| 284 | If `start` and/or `end` are returned as `None`, it will be |
| 285 | assumed that the processor did not find a valid region of text. |
| 286 | |
| 287 | Subclasses should override this method. |
| 288 | |
| 289 | Arguments: |
| 290 | m: A re match object containing a match of the pattern. |
| 291 | data: The buffer currently under analysis. |
| 292 | |
| 293 | Returns: |
| 294 | el: The ElementTree element, text or None. |
| 295 | start: The start of the region that has been matched or None. |
| 296 | end: The end of the region that has been matched or None. |
| 297 | |
| 298 | """ |
| 299 | pass # pragma: no cover |
| 300 | |
| 301 | |
| 302 | class SimpleTextPattern(Pattern): # pragma: no cover |