Skip to content

Commit

Permalink
Merge pull request #545 from Crozzers/fix-consecutive-bold
Browse files Browse the repository at this point in the history
Fix bad handling of consecutive bold words (#541)
  • Loading branch information
nicholasserra committed Dec 10, 2023
2 parents bef9a20 + 078f76a commit 0fa9739
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/markdown2.py
Expand Up @@ -2406,9 +2406,9 @@ def _do_tg_spoiler(self, text):
text = self._tg_spoiler_re.sub(r"<tg-spoiler>\1</tg-spoiler>", text)
return text

_strong_re = re.compile(r"(\*\*|__)(?=\S)(.*\S)\1", re.S)
_strong_re = re.compile(r"(\*\*|__)(?=\S)(.+?[*_]?)(?<=\S)\1", re.S)
_em_re = r"(\*|_)(?=\S)(.*?\S)\1"
_code_friendly_strong_re = re.compile(r"\*\*(?=\S)(.*\S)\*\*", re.S)
_code_friendly_strong_re = re.compile(r"\*\*(?=\S)(.+?[*_]?)(?<=\S)\*\*", re.S)
_code_friendly_em_re = r"\*(?=\S)(.+?)\*"
def _do_italics_and_bold(self, text):
if self.extras.get('middle-word-em', True) is False:
Expand Down
7 changes: 7 additions & 0 deletions test/tm-cases/consecutive_strong_em.html
@@ -0,0 +1,7 @@
<p><strong>a</strong> b <strong>c</strong></p>

<p><em>a</em> b <em>c</em></p>

<p><strong>a</strong> b <strong>c</strong></p>

<p><em>a</em> b <em>c</em></p>
7 changes: 7 additions & 0 deletions test/tm-cases/consecutive_strong_em.text
@@ -0,0 +1,7 @@
**a** b **c**

*a* b *c*

__a__ b __c__

_a_ b _c_

0 comments on commit 0fa9739

Please sign in to comment.