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

Allow multi-line emphasis. Fix #28.

This commit is contained in:
Haralan Dobrev 2013-11-12 19:22:17 +02:00
parent df3db71698
commit 1f347e17eb
3 changed files with 16 additions and 6 deletions

View File

@ -678,14 +678,14 @@ class Parsedown
if (strpos($text, '_') !== FALSE)
{
$text = preg_replace('/__(?=\S)(.+?)(?<=\S)__/', '<strong>$1</strong>', $text);
$text = preg_replace('/_(?=\S)(.+?)(?<=\S)_/', '<em>$1</em>', $text);
$text = preg_replace('/__(?=\S)(.+?)(?<=\S)__/s', '<strong>$1</strong>', $text);
$text = preg_replace('/_(?=\S)(.+?)(?<=\S)_/s', '<em>$1</em>', $text);
}
if (strpos($text, '*') !== FALSE)
{
$text = preg_replace('/\*\*(?=\S)(.+?)(?<=\S)\*\*/', '<strong>$1</strong>', $text);
$text = preg_replace('/\*(?=\S)(.+?)(?<=\S)\*/', '<em>$1</em>', $text);
$text = preg_replace('/\*\*(?=\S)(.+?)(?<=\S)\*\*/s', '<strong>$1</strong>', $text);
$text = preg_replace('/\*(?=\S)(.+?)(?<=\S)\*/s', '<em>$1</em>', $text);
}
$text = strtr($text, $map);

View File

@ -4,4 +4,8 @@
<p>Here's <em>one that uses underscores</em>. </p>
<p>Here's <strong>a strong one that uses underscores</strong>.</p>
<p>This is not _ one _ neither is * this * neither is _ this_ neither is _this _.</p>
<p>An empty emphasis ** is not __ an emphasis.</p>
<p>An empty emphasis ** is not __ an emphasis.</p>
<p>A <em>multi-line
emphasis</em></p>
<p>A <strong>multi-line
strong emphasis</strong></p>

View File

@ -10,4 +10,10 @@ Here's __a strong one that uses underscores__.
This is not _ one _ neither is * this * neither is _ this_ neither is _this _.
An empty emphasis ** is not __ an emphasis.
An empty emphasis ** is not __ an emphasis.
A *multi-line
emphasis*
A **multi-line
strong emphasis**