A context manager, that will reset the current enabled rules on exit.
(self)
| 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" |