mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
a4fb0651d5 | |||
50a58eab16 | |||
1f347e17eb |
@ -678,14 +678,14 @@ class Parsedown
|
|||||||
|
|
||||||
if (strpos($text, '_') !== FALSE)
|
if (strpos($text, '_') !== FALSE)
|
||||||
{
|
{
|
||||||
$text = preg_replace('/__(?=\S)(.+?)(?<=\S)__/', '<strong>$1</strong>', $text);
|
$text = preg_replace('/__(?=\S)(.+?)(?<=\S)__(?!_)/s', '<strong>$1</strong>', $text);
|
||||||
$text = preg_replace('/_(?=\S)(.+?)(?<=\S)_/', '<em>$1</em>', $text);
|
$text = preg_replace('/_(?=\S)(.+?)(?<=\S)_/s', '<em>$1</em>', $text);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($text, '*') !== FALSE)
|
if (strpos($text, '*') !== FALSE)
|
||||||
{
|
{
|
||||||
$text = preg_replace('/\*\*(?=\S)(.+?)(?<=\S)\*\*/', '<strong>$1</strong>', $text);
|
$text = preg_replace('/\*\*(?=\S)(.+?)(?<=\S)\*\*(?!\*)/s', '<strong>$1</strong>', $text);
|
||||||
$text = preg_replace('/\*(?=\S)(.+?)(?<=\S)\*/', '<em>$1</em>', $text);
|
$text = preg_replace('/\*(?=\S)(.+?)(?<=\S)\*/s', '<em>$1</em>', $text);
|
||||||
}
|
}
|
||||||
|
|
||||||
$text = strtr($text, $map);
|
$text = strtr($text, $map);
|
||||||
|
@ -5,3 +5,7 @@
|
|||||||
<p>Here's <strong>a strong one that uses underscores</strong>.</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>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>
|
@ -11,3 +11,9 @@ Here's __a strong one that uses underscores__.
|
|||||||
This is not _ one _ neither is * this * neither is _ this_ neither is _this _.
|
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**
|
5
tests/data/emphasis_-_em_strong.html
Normal file
5
tests/data/emphasis_-_em_strong.html
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<p><strong><em>em strong</em></strong></p>
|
||||||
|
<p><strong><em>one</em> at the start</strong></p>
|
||||||
|
<p><strong>one at the <em>end</em></strong></p>
|
||||||
|
<p><strong>one <em>in the</em> middle</strong></p>
|
||||||
|
<p><strong>one with <em>asterisks</em></strong></p>
|
9
tests/data/emphasis_-_em_strong.md
Normal file
9
tests/data/emphasis_-_em_strong.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
___em strong___
|
||||||
|
|
||||||
|
___one_ at the start__
|
||||||
|
|
||||||
|
__one at the _end___
|
||||||
|
|
||||||
|
__one _in the_ middle__
|
||||||
|
|
||||||
|
**one with *asterisks***
|
Reference in New Issue
Block a user