MCPcopy Create free account
hub / github.com/executablebooks/markdown-it-py / disable

Method disable

markdown_it/ruler.py:231–253  ·  view source on GitHub ↗

Disable rules with given names. :param names: name or list of rule names to enable. :param ignoreInvalid: ignore errors when rule not found :raises: KeyError if name not found and not ignoreInvalid :return: list of found rule names

(
        self, names: str | Iterable[str], ignoreInvalid: bool = False
    )

Source from the content-addressed store, hash-verified

229 return self.enable(names, ignoreInvalid)
230
231 def disable(
232 self, names: str | Iterable[str], ignoreInvalid: bool = False
233 ) -> list[str]:
234 """Disable rules with given names.
235
236 :param names: name or list of rule names to enable.
237 :param ignoreInvalid: ignore errors when rule not found
238 :raises: KeyError if name not found and not ignoreInvalid
239 :return: list of found rule names
240 """
241 if isinstance(names, str):
242 names = [names]
243 result = []
244 for name in names:
245 idx = self.__find__(name)
246 if (idx < 0) and ignoreInvalid:
247 continue
248 if (idx < 0) and not ignoreInvalid:
249 raise KeyError(f"Rules manager: invalid rule name {name}")
250 self.__rules__[idx].enabled = False
251 result.append(name)
252 self.__cache__ = None
253 return result
254
255 def getRules(self, chainName: str = "") -> list[RuleFuncTv]:
256 """Return array of active functions (rules) for given chain name.

Callers 2

test_disable_code_blockFunction · 0.45
test_disableFunction · 0.45

Calls 1

__find__Method · 0.95

Tested by 2

test_disable_code_blockFunction · 0.36
test_disableFunction · 0.36