1
0
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:
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

View File

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