mirror of
https://github.com/erusev/parsedown.git
synced 2024-09-20 03:51:29 +02:00
no need for a separate method for every special character
This commit is contained in:
parent
e5e8d02934
commit
21a3e8790a
@ -968,12 +968,12 @@ class Parsedown
|
|||||||
#
|
#
|
||||||
|
|
||||||
protected $InlineTypes = array(
|
protected $InlineTypes = array(
|
||||||
'"' => array('QuotationMark'),
|
'"' => array('SpecialCharacter'),
|
||||||
'!' => array('Image'),
|
'!' => array('Image'),
|
||||||
'&' => array('Ampersand'),
|
'&' => array('SpecialCharacter'),
|
||||||
'*' => array('Emphasis'),
|
'*' => array('Emphasis'),
|
||||||
'<' => array('Url', 'Email', 'Markup', 'LessThan'),
|
'<' => array('Url', 'Email', 'Markup', 'SpecialCharacter'),
|
||||||
'>' => array('GreaterThan'),
|
'>' => array('SpecialCharacter'),
|
||||||
'[' => array('Link'),
|
'[' => array('Link'),
|
||||||
'_' => array('Emphasis'),
|
'_' => array('Emphasis'),
|
||||||
'`' => array('Code'),
|
'`' => array('Code'),
|
||||||
@ -1043,17 +1043,6 @@ class Parsedown
|
|||||||
# ~
|
# ~
|
||||||
#
|
#
|
||||||
|
|
||||||
protected function inlineAmpersand($excerpt)
|
|
||||||
{
|
|
||||||
if ( ! preg_match('/^&#?\w+;/', $excerpt))
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
'markup' => '&',
|
|
||||||
'extent' => 1,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function inlineCode($excerpt)
|
protected function inlineCode($excerpt)
|
||||||
{
|
{
|
||||||
$marker = $excerpt[0];
|
$marker = $excerpt[0];
|
||||||
@ -1141,14 +1130,6 @@ class Parsedown
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function inlineGreaterThan()
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
'markup' => '>',
|
|
||||||
'extent' => 1,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function inlineImage($excerpt)
|
protected function inlineImage($excerpt)
|
||||||
{
|
{
|
||||||
if ( ! isset($excerpt[1]) or $excerpt[1] !== '[')
|
if ( ! isset($excerpt[1]) or $excerpt[1] !== '[')
|
||||||
@ -1296,14 +1277,27 @@ class Parsedown
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function inlineQuotationMark()
|
protected function inlineSpecialCharacter($excerpt)
|
||||||
|
{
|
||||||
|
if ($excerpt[0] === '&' and ! preg_match('/^&#?\w+;/', $excerpt))
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'markup' => '"',
|
'markup' => '&',
|
||||||
'extent' => 1,
|
'extent' => 1,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$SpecialCharacter = array('>' => 'gt', '<' => 'lt', '"' => 'quot');
|
||||||
|
|
||||||
|
if (isset($SpecialCharacter[$excerpt[0]]))
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'markup' => '&'.$SpecialCharacter[$excerpt[0]].';',
|
||||||
|
'extent' => 1,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function inlineStrikethrough($excerpt)
|
protected function inlineStrikethrough($excerpt)
|
||||||
{
|
{
|
||||||
if ( ! isset($excerpt[1]))
|
if ( ! isset($excerpt[1]))
|
||||||
|
Loading…
Reference in New Issue
Block a user