Skip to content

Commit 5a2b945

Browse files
authoredMar 19, 2025··
Merge pull request #622 from Crozzers/expand-block-elements-regex
Add missing block tags to regex (#620)
2 parents b1c26b2 + 3f13999 commit 5a2b945

5 files changed

+35
-3
lines changed
 

‎CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## python-markdown2 2.5.4 (not yet released)
44

55
- [pull #617] Add MarkdownFileLinks extra (#528)
6+
- [pull #622] Add missing block tags to regex (#620)
67

78

89
## python-markdown2 2.5.3

‎lib/markdown2.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -859,9 +859,9 @@ def _detab(self, text: str) -> str:
859859

860860
# I broke out the html5 tags here and add them to _block_tags_a and
861861
# _block_tags_b. This way html5 tags are easy to keep track of.
862-
_html5tags = '|article|aside|header|hgroup|footer|nav|section|figure|figcaption'
862+
_html5tags = '|address|article|aside|canvas|figcaption|figure|footer|header|main|nav|section|video'
863863

864-
_block_tags_a = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del|style|html|head|body'
864+
_block_tags_a = 'blockquote|body|dd|del|div|dl|dt|fieldset|form|h[1-6]|head|hr|html|iframe|ins|li|math|noscript|ol|p|pre|script|style|table|tfoot|ul'
865865
_block_tags_a += _html5tags
866866

867867
_strict_tag_block_re = re.compile(r"""
@@ -877,7 +877,7 @@ def _detab(self, text: str) -> str:
877877
""" % _block_tags_a,
878878
re.X | re.M)
879879

880-
_block_tags_b = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math'
880+
_block_tags_b = 'blockquote|div|dl|fieldset|form|h[1-6]|iframe|math|noscript|ol|p|pre|script|table|ul'
881881
_block_tags_b += _html5tags
882882

883883
_span_tags = (
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<p>Some HTML5 block level elements that should be hashed so that smarty-pants doesn&#8217;t interfere</p>
2+
3+
<address>
4+
<a href="mailto:jim@example.com">jim@example.com</a><br />
5+
<a href="tel:+14155550132">+1 (415) 555‑0132</a>
6+
</address>
7+
8+
<canvas width="120" height="120">
9+
An alternative text describing what your canvas displays.
10+
</canvas>
11+
12+
<video height="640" width="382" controls loop>
13+
<source src="images/door.mp4" type="video/mp4"/>
14+
Test
15+
</video>
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"extras": ["smarty-pants"]}
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Some HTML5 block level elements that should be hashed so that smarty-pants doesn't interfere
2+
3+
<address>
4+
<a href="mailto:jim@example.com">jim@example.com</a><br />
5+
<a href="tel:+14155550132">+1 (415) 555‑0132</a>
6+
</address>
7+
8+
<canvas width="120" height="120">
9+
An alternative text describing what your canvas displays.
10+
</canvas>
11+
12+
<video height="640" width="382" controls loop>
13+
<source src="images/door.mp4" type="video/mp4"/>
14+
Test
15+
</video>

0 commit comments

Comments
 (0)
Please sign in to comment.