diff --git a/lib/markdown2.py b/lib/markdown2.py
index 6ea3901e..34a270b3 100755
--- a/lib/markdown2.py
+++ b/lib/markdown2.py
@@ -2406,9 +2406,9 @@ def _do_tg_spoiler(self, text):
text = self._tg_spoiler_re.sub(r"\1", 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:
diff --git a/test/tm-cases/consecutive_strong_em.html b/test/tm-cases/consecutive_strong_em.html
new file mode 100644
index 00000000..b2e92c7b
--- /dev/null
+++ b/test/tm-cases/consecutive_strong_em.html
@@ -0,0 +1,7 @@
+
a b c
+
+a b c
+
+a b c
+
+a b c
diff --git a/test/tm-cases/consecutive_strong_em.text b/test/tm-cases/consecutive_strong_em.text
new file mode 100644
index 00000000..1fde0000
--- /dev/null
+++ b/test/tm-cases/consecutive_strong_em.text
@@ -0,0 +1,7 @@
+**a** b **c**
+
+*a* b *c*
+
+__a__ b __c__
+
+_a_ b _c_