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

Compare commits

...

3 Commits
0.7.1 ... 0.7.3

6 changed files with 34 additions and 15 deletions

View File

@ -779,14 +779,19 @@ class Parsedown
if (strpos($text, '_') !== FALSE) if (strpos($text, '_') !== FALSE)
{ {
$text = preg_replace('/__(?=\S)(.+?)(?<=\S)__(?!_)/s', '<strong>$1</strong>', $text); $text = preg_replace('/__(?=\S)([^_]+?)(?<=\S)__/s', '<strong>$1</strong>', $text, -1, $count);
$count or $text = preg_replace('/__(?=\S)(.+?)(?<=\S)__(?!_)/s', '<strong>$1</strong>', $text);
$text = preg_replace('/\b_(?=\S)(.+?)(?<=\S)_\b/s', '<em>$1</em>', $text); $text = preg_replace('/\b_(?=\S)(.+?)(?<=\S)_\b/s', '<em>$1</em>', $text);
} }
if (strpos($text, '*') !== FALSE) if (strpos($text, '*') !== FALSE)
{ {
$text = preg_replace('/\*\*(?=\S)(.+?)(?<=\S)\*\*(?!\*)/s', '<strong>$1</strong>', $text); $text = preg_replace('/\*\*(?=\S)([^*]+?)(?<=\S)\*\*/s', '<strong>$1</strong>', $text, -1, $count);
$text = preg_replace('/\*(?=\S)(.+?)(?<=\S)\*/s', '<em>$1</em>', $text); $count or $text = preg_replace('/\*\*(?=\S)(.+?)(?<=\S)\*\*(?!\*)/s', '<strong>$1</strong>', $text);
$text = preg_replace('/\*(?=\S)([^*]+?)(?<=\S)\*/s', '<em>$1</em>', $text, -1, $count);
$count or $text = preg_replace('/\*(?=\S)(.+?)(?<=\S)\*(?!\*)/s', '<em>$1</em>', $text);
} }
$text = strtr($text, $map); $text = strtr($text, $map);

View File

@ -1,6 +1,6 @@
## Parsedown ## Parsedown
Fast, consistent and easy to use [Markdown][1] parser for PHP. Fast and consistent [Markdown][1] parser for PHP.
[Home](http://parsedown.org) &middot; [Demo](http://parsedown.org/explorer/) &middot; [Tests](http://parsedown.org/tests/) [Home](http://parsedown.org) &middot; [Demo](http://parsedown.org/explorer/) &middot; [Tests](http://parsedown.org/tests/)

View File

@ -1,5 +1,4 @@
<p><strong><em>em strong</em></strong></p> <p><strong><em>em strong</em> strong</strong></p>
<p><strong><em>one</em> at the start</strong></p> <p><strong>strong <em>em strong</em></strong></p>
<p><strong>one at the <em>end</em></strong></p> <p><strong>strong <em>em strong</em> strong</strong></p>
<p><strong>one <em>in the</em> middle</strong></p> <p><strong>strong <em>em strong</em></strong></p>
<p><strong>one with <em>asterisks</em></strong></p>

View File

@ -1,9 +1,7 @@
___em strong___ ___em strong_ strong__
___one_ at the start__ __strong _em strong___
__one at the _end___ __strong _em strong_ strong__
__one _in the_ middle__ **strong *em strong***
**one with *asterisks***

View File

@ -0,0 +1,6 @@
<p><em><strong>strong em</strong></em> </p>
<p><em>em <strong>strong em</strong></em></p>
<p><em><strong>strong em</strong> em</em></p>
<p><em><strong>strong em</strong></em></p>
<p><em>em <strong>strong em</strong></em></p>
<p><em><strong>strong em</strong> em</em></p>

11
tests/data/strong_em.md Normal file
View File

@ -0,0 +1,11 @@
***strong em***
*em **strong em***
***strong em** em*
___strong em___
_em __strong em___
___strong em__ em_