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