summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/libraries/Typography.php37
-rw-r--r--user_guide/changelog.html1
2 files changed, 25 insertions, 13 deletions
diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php
index 808a76953..27fa42192 100644
--- a/system/libraries/Typography.php
+++ b/system/libraries/Typography.php
@@ -235,26 +235,37 @@ class CI_Typography {
if ( ! isset($table))
{
- $table = array(
+ $table = array(
// nested smart quotes, opening and closing
// note that rules for grammar (English) allow only for two levels deep
// and that single quotes are _supposed_ to always be on the outside
// but we'll accommodate both
- '/(^|\W|\s)\'"/' => '$1‘“',
- '/\'"(\s|\W|$)/' => '’”$1',
- '/(^|\W|\s)"\'/' => '$1“‘',
- '/"\'(\s|\W|$)/' => '”’$1',
+ // Note that in all cases, whitespace is the primary determining factor
+ // on which direction to curl, with non-word characters like punctuation
+ // being a secondary factor only after whitespace is addressed.
+ '/\'"(\s|$)/' => '’”$1',
+ '/(^|\s)\'"/' => '$1‘“',
+ '/\'"(\W)/' => '’”$1',
+ '/(\W)\'"/' => '$1‘“',
+ '/"\'(\s|$)/' => '”’$1',
+ '/(^|\s)"\'/' => '$1“‘',
+ '/"\'(\W)/' => '”’$1',
+ '/(\W)"\'/' => '$1“‘',
// single quote smart quotes
- '/(^|\W|\s)\'/' => '$1‘',
- '/\'(\s|\W|$)/' => '’$1',
+ '/\'(\s|$)/' => '’$1',
+ '/(^|\s)\'/' => '$1‘',
+ '/\'(\W)/' => '’$1',
+ '/(\W)\'/' => '$1‘',
// double quote smart quotes
- '/(^|\W|\s)"/' => '$1“',
- '/"(\s|\W|$)/' => '”$1',
-
+ '/"(\s|$)/' => '”$1',
+ '/(^|\s)"/' => '$1“',
+ '/"(\W)/' => '”$1',
+ '/(\W)"/' => '$1“',
+
// apostrophes
- "/(\w)'(\w)/" => '$1’$2',
+ "/(\w)'(\w)/" => '$1’$2',
// Em dash and ellipses dots
'/\s?\-\-\s?/' => '—',
@@ -265,8 +276,8 @@ class CI_Typography {
// ampersands, if not a character entity
'/&(?!#?[a-zA-Z0-9]{2,};)/' => '&'
- );
- }
+ );
+ }
return preg_replace(array_keys($table), $table, $str);
}
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index 670e82c38..7aea9a6c9 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -85,6 +85,7 @@ SVN Revision: </p>
<li>Fixed a bug with the regular expression used to protect submitted paragraph tags in auto typography.</li>
<li>Fixed a bug where double dashes within tag attributes were being converted to em dash entities.</li>
<li>Fixed a bug where double spaces within tag attributes were being converted to non-breaking space entities.</li>
+ <li>Fixed some accuracy issues with curly quotes in Typography::format_characters()</li>
<li>Changed a few docblock comments to reflect actual return values.</li>
<li>Fixed a bug with high ascii characters in subject and from email headers.</li>
</ul>