Apply the en dash to number ranges in stories.
A typo ($stort) threw the result away.
This commit is contained in:
@@ -237,8 +237,12 @@ function sanitise($story) {
|
|||||||
$story = preg_replace("#<script[^>]*?>.*?</script>#si", "", $story);
|
$story = preg_replace("#<script[^>]*?>.*?</script>#si", "", $story);
|
||||||
// No comments please!
|
// No comments please!
|
||||||
$story = preg_replace("#<!--.*?-->#si", "", $story);
|
$story = preg_replace("#<!--.*?-->#si", "", $story);
|
||||||
// Replace number ranges with n-dashes
|
// Replace number ranges with n-dashes, in the text only (not in tags,
|
||||||
$stort = preg_replace("#(\d)-+(\d)#si", "$1–$2", $story);
|
// where the digits can be part of a link or an attribute)
|
||||||
|
$parts = preg_split("#(<[^>]*>)#", $story, -1, PREG_SPLIT_DELIM_CAPTURE);
|
||||||
|
for ($i = 0; $i < count($parts); $i += 2)
|
||||||
|
$parts[$i] = preg_replace("#(\d)-+(?=\d)#", "$1–", $parts[$i]);
|
||||||
|
$story = implode('', $parts);
|
||||||
// Replace " -- " and "--" with m-dashes
|
// Replace " -- " and "--" with m-dashes
|
||||||
$story = preg_replace("#(\s?)--(\s?)#si", "$1—$2", $story);
|
$story = preg_replace("#(\s?)--(\s?)#si", "$1—$2", $story);
|
||||||
// Replace ellipses
|
// Replace ellipses
|
||||||
|
|||||||
Reference in New Issue
Block a user