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

Method handleMatch

markdown/inlinepatterns.py:898–919  ·  view source on GitHub ↗

Parse delimiter pattern.

(  # type: ignore[override]
        self,
        m: re.Match[str],
        data: str
    )

Source from the content-addressed store, hash-verified

896 break
897
898 def handleMatch( # type: ignore[override]
899 self,
900 m: re.Match[str],
901 data: str
902 ) -> tuple[etree.Element | None, int | None, int | None]:
903 """Parse delimiter pattern."""
904
905 remainder = self.remainder
906 self.remainder = None
907 el, start, end = self._handle_match(m, data, remainder)
908
909 # If the element did not consume the entire closing delimiter run, the rest of the run directly follows
910 # the placeholder that will replace the element. The placeholder will hide what preceded the run, which
911 # is needed to correctly classify the rest of the run, so save it for the next match.
912 if el is not None and end is not None and end < len(data) and data[end] == data[end - 1]:
913 run = end - 1
914 while run > 0 and data[run - 1] == data[end]:
915 run -= 1
916 if run > 0:
917 self.remainder = (data[end], data[run - 1])
918
919 return el, start, end
920
921 def _handle_match(
922 self,

Callers

nothing calls this directly

Calls 1

_handle_matchMethod · 0.95

Tested by

no test coverage detected