mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Use rawHtml to provide conditional escaping for specialChars
This commit is contained in:
parent
adcba80502
commit
011465bca6
@ -964,13 +964,11 @@ class Parsedown
|
|||||||
#
|
#
|
||||||
|
|
||||||
protected $InlineTypes = array(
|
protected $InlineTypes = array(
|
||||||
'"' => array('SpecialCharacter'),
|
|
||||||
'!' => array('Image'),
|
'!' => array('Image'),
|
||||||
'&' => array('SpecialCharacter'),
|
'&' => array('SpecialCharacter'),
|
||||||
'*' => array('Emphasis'),
|
'*' => array('Emphasis'),
|
||||||
':' => array('Url'),
|
':' => array('Url'),
|
||||||
'<' => array('UrlTag', 'EmailTag', 'Markup', 'SpecialCharacter'),
|
'<' => array('UrlTag', 'EmailTag', 'Markup'),
|
||||||
'>' => array('SpecialCharacter'),
|
|
||||||
'[' => array('Link'),
|
'[' => array('Link'),
|
||||||
'_' => array('Emphasis'),
|
'_' => array('Emphasis'),
|
||||||
'`' => array('Code'),
|
'`' => array('Code'),
|
||||||
@ -980,7 +978,7 @@ class Parsedown
|
|||||||
|
|
||||||
# ~
|
# ~
|
||||||
|
|
||||||
protected $inlineMarkerList = '!"*_&[:<>`~\\';
|
protected $inlineMarkerList = '!*_&[:<`~\\';
|
||||||
|
|
||||||
#
|
#
|
||||||
# ~
|
# ~
|
||||||
@ -1337,23 +1335,15 @@ class Parsedown
|
|||||||
|
|
||||||
protected function inlineSpecialCharacter($Excerpt)
|
protected function inlineSpecialCharacter($Excerpt)
|
||||||
{
|
{
|
||||||
if ($Excerpt['text'][0] === '&' and ! preg_match('/^&#?\w+;/', $Excerpt['text']))
|
if (preg_match('/^&(#?+[0-9a-zA-Z]++);/', $Excerpt['text'], $matches))
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'markup' => '&',
|
'element' => array('rawHtml' => '&'.$matches[1].';'),
|
||||||
'extent' => 1,
|
'extent' => strlen($matches[0]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$SpecialCharacter = array('>' => 'gt', '<' => 'lt', '"' => 'quot');
|
return;
|
||||||
|
|
||||||
if (isset($SpecialCharacter[$Excerpt['text'][0]]))
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
'markup' => '&'.$SpecialCharacter[$Excerpt['text'][0]].';',
|
|
||||||
'extent' => 1,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function inlineStrikethrough($Excerpt)
|
protected function inlineStrikethrough($Excerpt)
|
||||||
|
Loading…
Reference in New Issue
Block a user