A dictionary, with attribute access to core markdownit configuration options.
| 61 | |
| 62 | |
| 63 | class OptionsDict(MutableMappingABC): # type: ignore |
| 64 | """A dictionary, with attribute access to core markdownit configuration options.""" |
| 65 | |
| 66 | # Note: ideally we would probably just remove attribute access entirely, |
| 67 | # but we keep it for backwards compatibility. |
| 68 | |
| 69 | def __init__(self, options: OptionsType) -> None: |
| 70 | self._options = cast(OptionsType, dict(options)) |
| 71 | |
| 72 | def __getitem__(self, key: str) -> Any: |
| 73 | return self._options[key] # type: ignore[literal-required] |
| 74 | |
| 75 | def __setitem__(self, key: str, value: Any) -> None: |
| 76 | self._options[key] = value # type: ignore[literal-required] |
| 77 | |
| 78 | def __delitem__(self, key: str) -> None: |
| 79 | del self._options[key] # type: ignore |
| 80 | |
| 81 | def __iter__(self) -> Iterable[str]: # type: ignore |
| 82 | return iter(self._options) |
| 83 | |
| 84 | def __len__(self) -> int: |
| 85 | return len(self._options) |
| 86 | |
| 87 | def __repr__(self) -> str: |
| 88 | return repr(self._options) |
| 89 | |
| 90 | def __str__(self) -> str: |
| 91 | return str(self._options) |
| 92 | |
| 93 | @property |
| 94 | def maxNesting(self) -> int: |
| 95 | """Internal protection, recursion limit.""" |
| 96 | return self._options["maxNesting"] |
| 97 | |
| 98 | @maxNesting.setter |
| 99 | def maxNesting(self, value: int) -> None: |
| 100 | self._options["maxNesting"] = value |
| 101 | |
| 102 | @property |
| 103 | def html(self) -> bool: |
| 104 | """Enable HTML tags in source.""" |
| 105 | return self._options["html"] |
| 106 | |
| 107 | @html.setter |
| 108 | def html(self, value: bool) -> None: |
| 109 | self._options["html"] = value |
| 110 | |
| 111 | @property |
| 112 | def linkify(self) -> bool: |
| 113 | """Enable autoconversion of URL-like texts to links.""" |
| 114 | return self._options["linkify"] |
| 115 | |
| 116 | @linkify.setter |
| 117 | def linkify(self, value: bool) -> None: |
| 118 | self._options["linkify"] = value |
| 119 | |
| 120 | @property |
no outgoing calls
no test coverage detected
searching dependent graphs…