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

Method test

markdown/blockprocessors.py:108–124  ·  view source on GitHub ↗

Test for block type. Must be overridden by subclasses. As the parser loops through processors, it will call the `test` method on each to determine if the given block of text is of that type. This method must return a boolean `True` or `False`. The actual method of t

(self, parent: etree.Element, block: str)

Source from the content-addressed store, hash-verified

106 return '\n'.join(lines)
107
108 def test(self, parent: etree.Element, block: str) -> bool:
109 """ Test for block type. Must be overridden by subclasses.
110
111 As the parser loops through processors, it will call the `test`
112 method on each to determine if the given block of text is of that
113 type. This method must return a boolean `True` or `False`. The
114 actual method of testing is left to the needs of that particular
115 block type. It could be as simple as `block.startswith(some_string)`
116 or a complex regular expression. As the block type may be different
117 depending on the parent of the block (i.e. inside a list), the parent
118 `etree` element is also provided and may be used as part of the test.
119
120 Keyword arguments:
121 parent: An `etree` element which will be the parent of the block.
122 block: A block of text from the source which has been split at blank lines.
123 """
124 pass # pragma: no cover
125
126 def run(self, parent: etree.Element, blocks: list[str]) -> bool | None:
127 """ Run processor. Must be overridden by subclasses.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected