From a4fb0651d54e66f705fec3194e8c42f2a4d9ea6b Mon Sep 17 00:00:00 2001 From: Emanuil Rusev Date: Wed, 13 Nov 2013 01:07:39 +0200 Subject: [PATCH] resolve #27 --- Parsedown.php | 4 ++-- tests/data/emphasis_-_em_strong.html | 5 +++++ tests/data/emphasis_-_em_strong.md | 9 +++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 tests/data/emphasis_-_em_strong.html create mode 100644 tests/data/emphasis_-_em_strong.md 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