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(
|
||||
'extent' => strlen($text),
|
||||
'element' => array(
|
||||
'elements' => array(),
|
||||
),
|
||||
'element' => array(),
|
||||
);
|
||||
|
||||
$safeText = self::escape($text, true);
|
||||
|
||||
if ($this->breaksEnabled)
|
||||
{
|
||||
$Inline['element']['elements'] = self::pregReplaceElements(
|
||||
'/[ ]*\n/',
|
||||
array(
|
||||
array('name' => 'br'),
|
||||
array('text' => "\n"),
|
||||
),
|
||||
$text
|
||||
);
|
||||
$Inline['element']['rawHtml'] = preg_replace('/[ ]*\n/', "<br />\n", $safeText);
|
||||
$Inline['element']['allowRawHtmlInSafeMode'] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$Inline['element']['elements'] = self::pregReplaceElements(
|
||||
'/(?:[ ][ ]+|[ ]*\\\\)\n/',
|
||||
array(
|
||||
array('name' => 'br'),
|
||||
array('text' => "\n"),
|
||||
),
|
||||
$text
|
||||
);
|
||||
$Inline['element']['rawHtml'] = preg_replace('/(?:[ ][ ]+|[ ]*\\\\)\n/', "<br />\n", $safeText);
|
||||
$Inline['element']['allowRawHtmlInSafeMode'] = true;
|
||||
}
|
||||
|
||||
return $Inline;
|
||||
|
Loading…
Reference in New Issue
Block a user