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

introduce more structure to parsing of unmarked inlines

This commit is contained in:
Emanuil Rusev 2015-01-08 15:19:43 +02:00
parent b1be886d65
commit fd0d8125e7

View File

@ -1087,7 +1087,7 @@ class Parsedown
$plainText = substr($text, 0, $markerPosition);
$markup .= $this->readUnmarkedText($plainText);
$markup .= $this->unmarkedText($plainText);
$markup .= isset($Inline['markup']) ? $Inline['markup'] : $this->element($Inline['element']);
@ -1105,7 +1105,7 @@ class Parsedown
$markerPosition ++;
}
$markup .= $this->readUnmarkedText($text);
$markup .= $this->unmarkedText($text);
return $markup;
}
@ -1397,17 +1397,28 @@ class Parsedown
#
# ~
protected function readUnmarkedText($text)
{
$text = $this->linkUrls($text);
protected $unmarkedInlineTypes = array(
" \n" => 'Break',
'://' => 'Url',
);
# ~
if (strpos($text, "\n") === false)
protected function unmarkedText($text)
{
foreach ($this->unmarkedInlineTypes as $snippet => $inlineType)
{
if (strpos($text, $snippet) !== false)
{
$text = $this->{'unmarkedInline'.$inlineType}($text);
}
}
return $text;
}
protected function unmarkedInlineBreak($text)
{
if ($this->breaksEnabled)
{
$text = preg_replace('/[ ]*\n/', "<br />\n", $text);
@ -1421,9 +1432,7 @@ class Parsedown
return $text;
}
# ~
protected function linkUrls($text)
protected function unmarkedInlineUrl($text)
{
$re = '/\bhttps?:[\/]{2}[^\s<]+\b\/*/ui';