Skip to content

Commit

Permalink
numeric entities (direction from Gibbo)
Browse files Browse the repository at this point in the history
  • Loading branch information
scoates committed Dec 9, 2009
1 parent 7da0a41 commit 30e4ac3
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions inc/Tokens.php
Expand Up @@ -16,6 +16,12 @@ abstract class Token
'code','pre',
);

protected static $numericEntities = array(
'&' => '&',
'<' => '<',
'>' => '>',
);

protected function __construct($text)
{
$this->text = $text;
Expand Down Expand Up @@ -69,19 +75,11 @@ public function __toString()

public static function ampReplace($str)
{
return str_replace('&','&', htmlentities($str, ENT_NOQUOTES, 'utf-8', false));
/*
if (strpos($str, '&') === false) {
return $str;
}
$ret = '';
foreach (explode('&', $str) as $bit) {
if (strpos($str, ';') === false) {
$ret .= html
}
}
return str_replace('&','&', $str);
*/
return str_replace(
array_keys(self::$numericEntities),
array_values(self::$numericEntities),
htmlentities($str, ENT_NOQUOTES, 'utf-8', false)
);
}
}

Expand Down

0 comments on commit 30e4ac3

Please sign in to comment.