1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

Merge pull request #10 from hkdobrev/emphasis

Better parsing of emphasis and strong elements
This commit is contained in:
Emanuil Rusev
2013-07-23 00:52:41 -07:00
3 changed files with 16 additions and 13 deletions

View File

@@ -605,19 +605,13 @@ class Parsedown
$index ++;
}
}
if (strpos($text, '*') !== FALSE)
if (strpos($text, '*') !== FALSE or strpos($text, '_') !== FALSE)
{
$text = preg_replace('/\*{2}(.*?)\*{2}/', '<strong>$1</strong>', $text);
$text = preg_replace('/\*(.*?)\*/', '<em>$1</em>', $text);
$text = preg_replace('/(\*\*|__)(.+?[*_]*)(?<=\S)\1/', '<strong>$2</strong>', $text);
$text = preg_replace('/(\*|_)(.+?)(?<=\S)\1/', '<em>$2</em>', $text);
}
if (strpos($text, '_') !== FALSE)
{
$text = preg_replace('/_{2}(\S.*?\S)_{2}/', '<strong>$1</strong>', $text);
$text = preg_replace('/_(\S.*?\S)_/', '<em>$1</em>', $text);
}
$text = strtr($text, $map);
return $text;