function SmartEllipses in Typogrify 6
Same name and namespace in other branches
- 5 smartypants.php \SmartEllipses()
- 7 smartypants.php \SmartEllipses()
File
- ./
smartypants.php, line 334 - smartypants.php SmartyPants - Smart punctuation for web sites
Code
function SmartEllipses($text, $attr = NULL, $ctx = NULL) {
# Paramaters:
$text;
# text to be parsed
$attr;
# value of the smart_ellipses="" attribute
$ctx;
# MT context object (unused)
if ($attr == NULL) {
$attr = $_typogrify_smartypants_attr;
}
if ($attr == 0) {
# do nothing;
return $text;
}
$tokens;
$tokens = _TokenizeHTML($text);
$result = '';
$in_pre = 0;
# Keep track of when we're inside <pre> or <code> tags
foreach ($tokens as $cur_token) {
if ($cur_token[0] == "tag") {
# Don't mess with quotes inside tags
$result .= $cur_token[1];
if (preg_match(SMARTYPANTS_TAGS_TO_SKIP, $cur_token[1], $matches)) {
$in_pre = isset($matches[1]) && $matches[1] == '/' ? 0 : 1;
}
}
else {
$t = $cur_token[1];
if (!$in_pre) {
$t = ProcessEscapes($t);
$t = EducateEllipses($t);
}
$result .= $t;
}
}
return $result;
}