function Markdown_Parser::encodeAmpsAndAngles in Markdown 6
Same name and namespace in other branches
- 5 markdown.php \Markdown_Parser::encodeAmpsAndAngles()
1 call to Markdown_Parser::encodeAmpsAndAngles()
File
- ./
markdown.php, line 1437
Class
Code
function encodeAmpsAndAngles($text) {
#
# 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);
}
else {
# 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 remaining <'s
$text = str_replace('<', '<', $text);
return $text;
}