Skip to content

Commit 03d2391

Browse files
Merge pull request #628 from Crozzers/fix-typeerror-middle-word-em
Fix TypeError in MiddleWordEm extra when options was None (#627)
2 parents c91007d + 4a37206 commit 03d2391

File tree

5 files changed

+8
-2
lines changed

5 files changed

+8
-2
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- [pull #622] Add missing block tags to regex (#620)
77
- [pull #623] Don't escape plus signs in URLs (#621)
88
- [pull #626] Fix XSS when encoding incomplete tags (#625)
9+
- [pull #628] Fix TypeError in MiddleWordEm extra when options was None (#627)
910

1011

1112
## python-markdown2 2.5.3

lib/markdown2.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -2460,7 +2460,7 @@ class ItalicAndBoldProcessor(Extra):
24602460
strong_re = Markdown._strong_re
24612461
em_re = Markdown._em_re
24622462

2463-
def __init__(self, md: Markdown, options: dict):
2463+
def __init__(self, md: Markdown, options: Optional[dict]):
24642464
super().__init__(md, options)
24652465
self.hash_table = {}
24662466

@@ -3293,7 +3293,7 @@ class MiddleWordEm(ItalicAndBoldProcessor):
32933293
name = 'middle-word-em'
32943294
order = (CodeFriendly,), (Stage.ITALIC_AND_BOLD,)
32953295

3296-
def __init__(self, md: Markdown, options: Union[dict, bool]):
3296+
def __init__(self, md: Markdown, options: Union[dict, bool, None]):
32973297
'''
32983298
Args:
32993299
md: the markdown instance
@@ -3304,6 +3304,8 @@ def __init__(self, md: Markdown, options: Union[dict, bool]):
33043304
'''
33053305
if isinstance(options, bool):
33063306
options = {'allowed': options}
3307+
else:
3308+
options = options or {}
33073309
options.setdefault('allowed', True)
33083310
super().__init__(md, options)
33093311

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<p>abc<em>def</em>ghi</p>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{'extras': {'middle-word-em': None}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
abc_def_ghi

0 commit comments

Comments
 (0)