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

Method rule_of_3

markdown/inlinepatterns.py:853–860  ·  view source on GitHub ↗

Check the "rule of 3" which prevents an open delimiter from pairing with an ambiguous one. The original lengths of the delimiter must be used, not what is left of them after partial pairing.

(opener: int, closer: int)

Source from the content-addressed store, hash-verified

851
852 @staticmethod
853 def rule_of_3(opener: int, closer: int) -> bool:
854 """
855 Check the "rule of 3" which prevents an open delimiter from pairing with an ambiguous one.
856
857 The original lengths of the delimiter must be used, not what is left of them after partial pairing.
858 """
859
860 return (opener + closer) % 3 == 0 and (opener % 3 != 0 or closer % 3 != 0)
861
862 def get_match(self, data: str, start: int) -> re.Match[str] | None:
863 """Get match."""

Callers 1

_handle_matchMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected