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

Method enable

markdown_it/ruler.py:191–213  ·  view source on GitHub ↗

Enable 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

189 self.__cache__ = None
190
191 def enable(
192 self, names: str | Iterable[str], ignoreInvalid: bool = False
193 ) -> list[str]:
194 """Enable rules with given names.
195
196 :param names: name or list of rule names to enable.
197 :param ignoreInvalid: ignore errors when rule not found
198 :raises: KeyError if name not found and not ignoreInvalid
199 :return: list of found rule names
200 """
201 if isinstance(names, str):
202 names = [names]
203 result: list[str] = []
204 for name in names:
205 idx = self.__find__(name)
206 if (idx < 0) and ignoreInvalid:
207 continue
208 if (idx < 0) and not ignoreInvalid:
209 raise KeyError(f"Rules manager: invalid rule name {name}")
210 self.__rules__[idx].enabled = True
211 result.append(name)
212 self.__cache__ = None
213 return result
214
215 def enableOnly(
216 self, names: str | Iterable[str], ignoreInvalid: bool = False

Callers 10

enableOnlyMethod · 0.95
test_token_levelsFunction · 0.45
test_linkifyFunction · 0.45
test_smartquotesFunction · 0.45
test_typographerFunction · 0.45
test_tableFunction · 0.45
test_fatalFunction · 0.45
test_strikethroughFunction · 0.45
test_disable_code_blockFunction · 0.45
test_enableFunction · 0.45

Calls 1

__find__Method · 0.95

Tested by 9

test_token_levelsFunction · 0.36
test_linkifyFunction · 0.36
test_smartquotesFunction · 0.36
test_typographerFunction · 0.36
test_tableFunction · 0.36
test_fatalFunction · 0.36
test_strikethroughFunction · 0.36
test_disable_code_blockFunction · 0.36
test_enableFunction · 0.36