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:
Aidan Woods 2018-04-08 20:39:20 +01:00
parent 70f5c02d47
commit dc5cf8770b
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9
1 changed files with 7 additions and 19 deletions

View File

@ -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;