function _typogrify_number_replacer in Typogrify 7
Internal: wraps and inserts space in numbers.
Parameters
array $hit: matcher-array from preg_replace_callback.
string $thbl: kind of whitespace to add.
4 calls to _typogrify_number_replacer()
- _typogrify_number_just_span in ./
smartypants.php - Wrapping numbers and adding whitespace by setting margin-left in a span.
- _typogrify_number_narrownbsp in ./
smartypants.php - Wrapping numbers and adding whitespace '&narrownbsp;'.
- _typogrify_number_span in ./
smartypants.php - Wrapping numbers and adding whitespace by setting margin-left in a span.
- _typogrify_number_thinsp in ./
smartypants.php - Wrapping numbers and adding whitespace ' '.
File
- ./
smartypants.php, line 626 - SmartyPants - Smart punctuation for web sites
Code
function _typogrify_number_replacer($hit, $thbl) {
if ($hit[1] != '') {
// Html-entity number: don't touch.
return $hit[1];
}
elseif ($hit[2] != '') {
// Html-entity number: don't touch.
return $hit[2];
}
elseif ($hit[3] != '') {
// Don't format german phone-numbers.
return $hit[3];
}
elseif ($hit[4] != '') {
// Date -`iso don't touch.
return $hit[4];
}
elseif ($hit[5] != '') {
// Date -`dd.mm.yyyy don't touch.
return $hit[5];
}
if (preg_match('/[+-]?\\d{5,}/', $hit[6]) == 1) {
$dec = preg_replace('/[+-]?\\d{1,3}(?=(\\d{3})+(?!\\d))/', '\\0' . $thbl, $hit[6]);
}
else {
$dec = $hit[6];
}
$frac = preg_replace('/\\d{3}/', '\\0' . $thbl, $hit[7]);
return '<span class="number">' . $dec . $frac . '</span>';
}