mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
The AST has high complexity here (and so traversal is hard anyway)
We gain quite a bit of a speed boost by working with text here since this is a very common function
This commit is contained in:
parent
70f5c02d47
commit
dc5cf8770b
@ -1211,32 +1211,20 @@ class Parsedown
|
|||||||
{
|
{
|
||||||
$Inline = array(
|
$Inline = array(
|
||||||
'extent' => strlen($text),
|
'extent' => strlen($text),
|
||||||
'element' => array(
|
'element' => array(),
|
||||||
'elements' => array(),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$safeText = self::escape($text, true);
|
||||||
|
|
||||||
if ($this->breaksEnabled)
|
if ($this->breaksEnabled)
|
||||||
{
|
{
|
||||||
$Inline['element']['elements'] = self::pregReplaceElements(
|
$Inline['element']['rawHtml'] = preg_replace('/[ ]*\n/', "<br />\n", $safeText);
|
||||||
'/[ ]*\n/',
|
$Inline['element']['allowRawHtmlInSafeMode'] = true;
|
||||||
array(
|
|
||||||
array('name' => 'br'),
|
|
||||||
array('text' => "\n"),
|
|
||||||
),
|
|
||||||
$text
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$Inline['element']['elements'] = self::pregReplaceElements(
|
$Inline['element']['rawHtml'] = preg_replace('/(?:[ ][ ]+|[ ]*\\\\)\n/', "<br />\n", $safeText);
|
||||||
'/(?:[ ][ ]+|[ ]*\\\\)\n/',
|
$Inline['element']['allowRawHtmlInSafeMode'] = true;
|
||||||
array(
|
|
||||||
array('name' => 'br'),
|
|
||||||
array('text' => "\n"),
|
|
||||||
),
|
|
||||||
$text
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $Inline;
|
return $Inline;
|
||||||
|
Loading…
Reference in New Issue
Block a user