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

Method reset_rules

markdown_it/main.py:216–223  ·  view source on GitHub ↗

A context manager, that will reset the current enabled rules on exit.

(self)

Source from the content-addressed store, hash-verified

214
215 @contextmanager
216 def reset_rules(self) -> Generator[None, None, None]:
217 """A context manager, that will reset the current enabled rules on exit."""
218 chain_rules = self.get_active_rules()
219 yield
220 for chain, rules in chain_rules.items():
221 if chain != "inline2":
222 self[chain].ruler.enableOnly(rules)
223 self.inline.ruler2.enableOnly(chain_rules["inline2"])
224
225 def add_render_rule(
226 self, name: str, function: Callable[..., Any], fmt: str = "html"

Callers 1

test_resetFunction · 0.95

Calls 2

get_active_rulesMethod · 0.95
enableOnlyMethod · 0.80

Tested by 1

test_resetFunction · 0.76