diff --git a/CHANGES.md b/CHANGES.md index 3f2ce150..1798e3d5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ - [pull #622] Add missing block tags to regex (#620) - [pull #623] Don't escape plus signs in URLs (#621) - [pull #626] Fix XSS when encoding incomplete tags (#625) +- [pull #628] Fix TypeError in MiddleWordEm extra when options was None (#627) ## python-markdown2 2.5.3 diff --git a/lib/markdown2.py b/lib/markdown2.py index 8d268c33..19cfca61 100755 --- a/lib/markdown2.py +++ b/lib/markdown2.py @@ -2460,7 +2460,7 @@ class ItalicAndBoldProcessor(Extra): strong_re = Markdown._strong_re em_re = Markdown._em_re - def __init__(self, md: Markdown, options: dict): + def __init__(self, md: Markdown, options: Optional[dict]): super().__init__(md, options) self.hash_table = {} @@ -3293,7 +3293,7 @@ class MiddleWordEm(ItalicAndBoldProcessor): name = 'middle-word-em' order = (CodeFriendly,), (Stage.ITALIC_AND_BOLD,) - def __init__(self, md: Markdown, options: Union[dict, bool]): + def __init__(self, md: Markdown, options: Union[dict, bool, None]): ''' Args: md: the markdown instance @@ -3304,6 +3304,8 @@ def __init__(self, md: Markdown, options: Union[dict, bool]): ''' if isinstance(options, bool): options = {'allowed': options} + else: + options = options or {} options.setdefault('allowed', True) super().__init__(md, options) diff --git a/test/tm-cases/middle_word_em_issue627.html b/test/tm-cases/middle_word_em_issue627.html new file mode 100644 index 00000000..66aa95bb --- /dev/null +++ b/test/tm-cases/middle_word_em_issue627.html @@ -0,0 +1 @@ +
abcdefghi
diff --git a/test/tm-cases/middle_word_em_issue627.opts b/test/tm-cases/middle_word_em_issue627.opts new file mode 100644 index 00000000..47407860 --- /dev/null +++ b/test/tm-cases/middle_word_em_issue627.opts @@ -0,0 +1 @@ +{'extras': {'middle-word-em': None}} \ No newline at end of file diff --git a/test/tm-cases/middle_word_em_issue627.text b/test/tm-cases/middle_word_em_issue627.text new file mode 100644 index 00000000..462861e6 --- /dev/null +++ b/test/tm-cases/middle_word_em_issue627.text @@ -0,0 +1 @@ +abc_def_ghi \ No newline at end of file