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

Method rule_of_3

markdown/inlinepatterns.py:816–823  ·  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

814
815 @staticmethod
816 def rule_of_3(opener: int, closer: int) -> bool:
817 """
818 Check the "rule of 3" which prevents an open delimiter from pairing with an ambiguous one.
819
820 The original lengths of the delimiter must be used, not what is left of them after partial pairing.
821 """
822
823 return (opener + closer) % 3 == 0 and (opener % 3 != 0 or closer % 3 != 0)
824
825 def get_match(self, data: str, start: int) -> re.Match[str] | None:
826 """Get match."""

Callers 1

handleMatchMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected