diff --git a/Parsedown.php b/Parsedown.php index 4e07a15..fad7739 100755 --- a/Parsedown.php +++ b/Parsedown.php @@ -678,13 +678,13 @@ class Parsedown if (strpos($text, '_') !== FALSE) { - $text = preg_replace('/__(?=\S)(.+?)(?<=\S)__/s', '$1', $text); + $text = preg_replace('/__(?=\S)(.+?)(?<=\S)__(?!_)/s', '$1', $text); $text = preg_replace('/_(?=\S)(.+?)(?<=\S)_/s', '$1', $text); } if (strpos($text, '*') !== FALSE) { - $text = preg_replace('/\*\*(?=\S)(.+?)(?<=\S)\*\*/s', '$1', $text); + $text = preg_replace('/\*\*(?=\S)(.+?)(?<=\S)\*\*(?!\*)/s', '$1', $text); $text = preg_replace('/\*(?=\S)(.+?)(?<=\S)\*/s', '$1', $text); } diff --git a/tests/data/emphasis_-_em_strong.html b/tests/data/emphasis_-_em_strong.html new file mode 100644 index 0000000..6d8da9c --- /dev/null +++ b/tests/data/emphasis_-_em_strong.html @@ -0,0 +1,5 @@ +

em strong

+

one at the start

+

one at the end

+

one in the middle

+

one with asterisks

\ No newline at end of file diff --git a/tests/data/emphasis_-_em_strong.md b/tests/data/emphasis_-_em_strong.md new file mode 100644 index 0000000..32effdc --- /dev/null +++ b/tests/data/emphasis_-_em_strong.md @@ -0,0 +1,9 @@ +___em strong___ + +___one_ at the start__ + +__one at the _end___ + +__one _in the_ middle__ + +**one with *asterisks*** \ No newline at end of file