Skip to content

Make markdown_it.common.entities.entities a dict. Remove AttrDict #153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions markdown_it/common/entities.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
"""HTML5 entities map: { name -> characters }."""
import html.entities

from markdown_it.utils import AttrDict


DATA = {name.rstrip(";"): chars for name, chars in html.entities.html5.items()}

entities = AttrDict(DATA)
entities = {name.rstrip(";"): chars for name, chars in html.entities.html5.items()}
17 changes: 1 addition & 16 deletions markdown_it/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pathlib import Path
from typing import TYPE_CHECKING, Any, Callable, List, Optional, Union
from typing import Callable, List, Optional, Union


class OptionsDict(dict):
Expand Down Expand Up @@ -87,21 +87,6 @@ def highlight(self, value: Optional[Callable[[str, str, str], str]]):
self["highlight"] = value


if TYPE_CHECKING:
AttrDict = Any
else:

class AttrDict(dict):
def __init__(self, *args, **kwargs):
super(AttrDict, self).__init__(*args, **kwargs)
self.__dict__ = self

# recursively apply to all nested dictionaries
for key, item in list(self.items()):
if isinstance(item, dict):
self[key] = AttrDict(item)


def read_fixture_file(path: Union[str, Path]) -> List[list]:
text = Path(path).read_text(encoding="utf-8")
tests = []
Expand Down