Skip to content

Commit fcc2494

Browse files
committed
fixup! Use set instead of list for block level elements
1 parent dd759eb commit fcc2494

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

markdown/core.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ def __init__(self, **kwargs):
113113
]
114114
""" List of characters which get the backslash escape treatment. """
115115

116+
117+
# `BLOCK_LEVEL_ELEMENTS` is actually a hybrid list/set container.
118+
# It supports list methods for backwards compatibility.
119+
# We expliclitly lie here, so that users running type checkers will get
120+
# warnings when they use the container as a list. This is a very effective
121+
# way of communicating the change, and deprecating list-like usage.
116122
self.block_level_elements: set[str] = BLOCK_LEVEL_ELEMENTS.copy()
117123

118124
self.registeredExtensions: list[Extension] = []

markdown/util.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,9 @@ def update(self, *others: set[str]) -> None:
312312

313313

314314
# Type it as `set[str]` to express our intent for it to be used as such.
315+
# We expliclitly lie here, so that users running type checkers will get
316+
# warnings when they use the container as a list. This is a very effective
317+
# way of communicating the change, and deprecating list-like usage.
315318
BLOCK_LEVEL_ELEMENTS: set[str] = _BlockLevelElements([
316319
# Elements which are invalid to wrap in a `<p>` tag.
317320
# See https://w3c.github.io/html/grouping-content.html#the-p-element

0 commit comments

Comments
 (0)