diff --git a/Parsedown.php b/Parsedown.php index 506c608..96c33e2 100755 --- a/Parsedown.php +++ b/Parsedown.php @@ -968,12 +968,12 @@ class Parsedown # protected $InlineTypes = array( - '"' => array('QuotationMark'), + '"' => array('SpecialCharacter'), '!' => array('Image'), - '&' => array('Ampersand'), + '&' => array('SpecialCharacter'), '*' => array('Emphasis'), - '<' => array('Url', 'Email', 'Markup', 'LessThan'), - '>' => array('GreaterThan'), + '<' => array('Url', 'Email', 'Markup', 'SpecialCharacter'), + '>' => array('SpecialCharacter'), '[' => array('Link'), '_' => array('Emphasis'), '`' => 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) { $marker = $excerpt[0]; @@ -1141,14 +1130,6 @@ class Parsedown } } - protected function inlineGreaterThan() - { - return array( - 'markup' => '>', - 'extent' => 1, - ); - } - protected function inlineImage($excerpt) { if ( ! isset($excerpt[1]) or $excerpt[1] !== '[') @@ -1296,12 +1277,25 @@ class Parsedown } } - protected function inlineQuotationMark() + protected function inlineSpecialCharacter($excerpt) { - return array( - 'markup' => '"', - 'extent' => 1, - ); + if ($excerpt[0] === '&' and ! preg_match('/^&#?\w+;/', $excerpt)) + { + return array( + 'markup' => '&', + 'extent' => 1, + ); + } + + $SpecialCharacter = array('>' => 'gt', '<' => 'lt', '"' => 'quot'); + + if (isset($SpecialCharacter[$excerpt[0]])) + { + return array( + 'markup' => '&'.$SpecialCharacter[$excerpt[0]].';', + 'extent' => 1, + ); + } } protected function inlineStrikethrough($excerpt)