Batch load of all options and component settings. This is an internal method, and you probably will not need it. But if you will - see available presets and data structure [here](https://github.com/markdown-it/markdown-it/tree/master/lib/presets) We strongly recommen
(
self, presets: str | PresetType, options_update: Mapping[str, Any] | None = None
)
| 102 | self.options = OptionsDict(options) |
| 103 | |
| 104 | def configure( |
| 105 | self, presets: str | PresetType, options_update: Mapping[str, Any] | None = None |
| 106 | ) -> MarkdownIt: |
| 107 | """Batch load of all options and component settings. |
| 108 | This is an internal method, and you probably will not need it. |
| 109 | But if you will - see available presets and data structure |
| 110 | [here](https://github.com/markdown-it/markdown-it/tree/master/lib/presets) |
| 111 | |
| 112 | We strongly recommend to use presets instead of direct config loads. |
| 113 | That will give better compatibility with next versions. |
| 114 | """ |
| 115 | if isinstance(presets, str): |
| 116 | if presets not in _PRESETS: |
| 117 | raise KeyError(f"Wrong `markdown-it` preset '{presets}', check name") |
| 118 | config = _PRESETS[presets] |
| 119 | else: |
| 120 | config = presets |
| 121 | |
| 122 | if not config: |
| 123 | raise ValueError("Wrong `markdown-it` config, can't be empty") |
| 124 | |
| 125 | options = config.get("options", {}) or {} |
| 126 | if options_update: |
| 127 | options = {**options, **options_update} # type: ignore |
| 128 | |
| 129 | self.set(options) |
| 130 | |
| 131 | if "components" in config: |
| 132 | for name, component in config["components"].items(): |
| 133 | rules = component.get("rules", None) |
| 134 | if rules: |
| 135 | self[name].ruler.enableOnly(rules) |
| 136 | rules2 = component.get("rules2", None) |
| 137 | if rules2: |
| 138 | self[name].ruler2.enableOnly(rules2) |
| 139 | |
| 140 | return self |
| 141 | |
| 142 | def get_all_rules(self) -> dict[str, list[str]]: |
| 143 | """Return the names of all active rules.""" |
no test coverage detected