|
|
|
@ -629,9 +629,9 @@ class Parsedown
|
|
|
|
|
|
|
|
|
|
$index = 0;
|
|
|
|
|
|
|
|
|
|
# inline link or image (recursive)
|
|
|
|
|
# inline link / inline image (recursive)
|
|
|
|
|
|
|
|
|
|
if (strpos($text, '](') !== FALSE and preg_match_all('/(!?)(\[((?:[^\[\]]|(?2))*)\])\((.*?)\)/', $text, $matches, PREG_SET_ORDER)) # inline
|
|
|
|
|
if (strpos($text, '](') !== FALSE and preg_match_all('/(!?)(\[((?:[^\[\]]|(?2))*)\])\((.*?)\)/', $text, $matches, PREG_SET_ORDER))
|
|
|
|
|
{
|
|
|
|
|
foreach ($matches as $matches)
|
|
|
|
|
{
|
|
|
|
@ -643,7 +643,7 @@ class Parsedown
|
|
|
|
|
{
|
|
|
|
|
$element = '<img alt="'.$matches[3].'" src="'.$url.'">';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
else # link
|
|
|
|
|
{
|
|
|
|
|
$element_text = $this->parse_span_elements($matches[3]);
|
|
|
|
|
|
|
|
|
@ -662,7 +662,7 @@ class Parsedown
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# reference link or image (recursive)
|
|
|
|
|
# reference link / reference image (recursive)
|
|
|
|
|
|
|
|
|
|
if ($this->reference_map and strpos($text, '[') !== FALSE and preg_match_all('/(!?)\[(.+?)\](?:\n?[ ]?\[(.*?)\])?/ms', $text, $matches, PREG_SET_ORDER))
|
|
|
|
|
{
|
|
|
|
@ -684,7 +684,7 @@ class Parsedown
|
|
|
|
|
{
|
|
|
|
|
$element = '<img alt="'.$matches[2].'" src="'.$url.'">';
|
|
|
|
|
}
|
|
|
|
|
else # anchor
|
|
|
|
|
else # link
|
|
|
|
|
{
|
|
|
|
|
$element_text = $this->parse_span_elements($matches[2]);
|
|
|
|
|
|
|
|
|
@ -784,18 +784,15 @@ class Parsedown
|
|
|
|
|
if (strpos($text, '_') !== FALSE)
|
|
|
|
|
{
|
|
|
|
|
$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', '$1<em>$2</em>$3', $text);
|
|
|
|
|
$text = preg_replace('/__(?=\S)([^_]+?)(?<=\S)__/s', '<strong>$1</strong>', $text, -1, $count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strpos($text, '*') !== FALSE)
|
|
|
|
|
{
|
|
|
|
|
$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('/\*(?=\S)([^*]+?)(?<=\S)\*/s', '<em>$1</em>', $text, -1, $count);
|
|
|
|
|
$count or $text = preg_replace('/\*(?=\S)(.+?)(?<=\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 = preg_replace('/\*\*(?=\S)([^*]+?)(?<=\S)\*\*/s', '<strong>$1</strong>', $text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$text = strtr($text, $map);
|
|
|
|
|