Skip to content

Commit

Permalink
Fix bad handling of consecutive bold words (trentm#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
Crozzers authored and syntaxsurge committed Dec 9, 2023
1 parent 9178066 commit afc3066
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
Original file line number Diff line number Diff line change
Expand Up @@ -2395,9 +2395,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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
**a** b **c**

*a* b *c*

__a__ b __c__

_a_ b _c_

0 comments on commit afc3066

Please sign in to comment.