1
1
from contextlib import contextmanager
2
- from typing import Any , Callable , Dict , List , Optional , Union
2
+ from typing import Any , Callable , Dict , List , Mapping , Optional , Union
3
3
4
4
from . import helpers , presets # noqa F401
5
5
from .common import utils # noqa F401
23
23
24
24
class MarkdownIt :
25
25
def __init__ (
26
- self , config : Union [str , AttrDict ] = "commonmark" , renderer_cls = RendererHTML
26
+ self , config : Union [str , Mapping ] = "commonmark" , renderer_cls = RendererHTML
27
27
):
28
28
"""Main parser class
29
29
@@ -65,7 +65,7 @@ def set(self, options):
65
65
"""
66
66
self .options = options
67
67
68
- def configure (self , presets : Union [str , AttrDict ]):
68
+ def configure (self , presets : Union [str , Mapping ]):
69
69
"""Batch load of all options and component settings.
70
70
This is an internal method, and you probably will not need it.
71
71
But if you will - see available presets and data structure
@@ -83,13 +83,13 @@ def configure(self, presets: Union[str, AttrDict]):
83
83
)
84
84
if not presets :
85
85
raise ValueError ("Wrong `markdown-it` preset, can't be empty" )
86
- presets = AttrDict (presets )
86
+ attr_presets = AttrDict (presets )
87
87
88
- if "options" in presets :
89
- self .set (presets .options )
88
+ if "options" in attr_presets :
89
+ self .set (attr_presets .options )
90
90
91
- if "components" in presets :
92
- for name , component in presets .components .items ():
91
+ if "components" in attr_presets :
92
+ for name , component in attr_presets .components .items ():
93
93
rules = component .get ("rules" , None )
94
94
if rules :
95
95
self [name ].ruler .enableOnly (rules )
0 commit comments