From a98a3aa137797cbf7a060fbfd4a0777b85fe3f9b Mon Sep 17 00:00:00 2001 From: Michel Fortin Date: Fri, 6 Jun 2008 07:47:04 -0400 Subject: [PATCH] Made encodeAmpsAndAngles not try anymore to see if `<` is part of tags or not. (This is no longer needed since all tags are "hashed".) --- markdown.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/markdown.php b/markdown.php index 13dbd0a..6ef0ad0 100644 --- a/markdown.php +++ b/markdown.php @@ -1255,20 +1255,21 @@ class Markdown_Parser { function encodeAmpsAndAngles($text) { - # Smart processing for ampersands and angle brackets that need to be encoded. + # + # Smart processing for ampersands and angle brackets that need to + # be encoded. Valid character entities are left alone unless the + # no-entities mode is set. + # if ($this->no_entities) { $text = str_replace('&', '&', $text); - $text = str_replace('<', '<', $text); - return $text; + } else { + # Ampersand-encoding based entirely on Nat Irons's Amputator + # MT plugin: + $text = preg_replace('/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/', + '&', $text);; } - - # Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin: - # http://bumppo.net/projects/amputator/ - $text = preg_replace('/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/', - '&', $text);; - - # Encode naked <'s - $text = preg_replace('{<(?![a-z/?\$!%])}i', '<', $text); + # Encode remaining <'s + $text = str_replace('<', '<', $text); return $text; }