Skip to content

Commit dd759eb

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

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

markdown/util.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@
4747
# TODO: Raise errors from list methods in the future.
4848
# Later, remove this class entirely and use a regular set.
4949
class _BlockLevelElements:
50+
# This hybrid list/set container exists for backwards compatibility reasons,
51+
# to support using both the `BLOCK_LEVEL_ELEMENTS` global variable (soft-deprecated)
52+
# and the `Markdown.block_level_elements` instance attribute (preferred) as a list or a set.
53+
# When we stop supporting list methods on these objects, we can remove the container
54+
# as well as the `test_block_level_elements` test module.
55+
5056
def __init__(self, elements: list[str], /) -> None:
5157
self._list = elements.copy()
5258
self._set = set(self._list)

tests/test_block_level_elements.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
===============================
2323
2424
Tests specific to the hybrid list/set container for block level elements.
25+
26+
The hybrid list/set container exists for backwards compatibility reasons,
27+
to support using both the `BLOCK_LEVEL_ELEMENTS` global variable (soft-deprecated)
28+
and the `Markdown.block_level_elements` instance attribute (preferred) as a list or a set.
29+
When we stop supporting list methods on these objects, we can remove the container
30+
as well as this test module.
2531
"""
2632

2733
import unittest

0 commit comments

Comments
 (0)