Changeset 142371
- Timestamp:
- 08/03/2009 08:51:39 AM (17 years ago)
- Location:
- post-typographer/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (1 diff)
-
typopost.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
post-typographer/trunk/readme.txt
r141803 r142371 57 57 == Changelog == 58 58 59 = 4 = 60 * Fixed: Nasty double-space bug on post-updating. 61 * Fixed: M-dash placement didn't work in version 3. 62 * Fixed: N-dashes are now placed correctly even if the value ranges are near the 63 beginning or the end of the text. 64 59 65 = 3 = 60 66 * Added: Replaces misplaced spaces near punctuation marks. -
post-typographer/trunk/typopost.php
r141803 r142371 5 5 Description: Formats the text according to typography rules. Works with English texts only. 6 6 Author: Andriy Moraru 7 Version: 37 Version: 4 8 8 Author URI: http://www.topforexnews.com 9 9 */ … … 35 35 $content = preg_replace('@ {2,}@', ' ', $content); 36 36 37 //Replace double (and more) spaces with single spaces 38 $content = preg_replace('@ {2,}@', '', $content);37 //Add m-dashes with a preceeding non-breaking space in place of the hyphens where neeeded 38 $content = str_replace(' - ', ' — ', $content); 39 39 40 40 //Get the array of strings made of text without HTML tags … … 49 49 $without_html[$i] = preg_replace('@ (\.|,|;|:|!|\?)@', "\$1", $without_html[$i]); 50 50 //Add space after the punctuation marks where needed 51 $without_html[$i] = preg_replace('@(,| ;|!|\?)([a-z]+)@i', "\$1 \$2", $without_html[$i]);51 $without_html[$i] = preg_replace('@(,|!|\?)([a-z]+)@i', "\$1 \$2", $without_html[$i]); 52 52 //Add n-dashes in place of hyphens in the numeric ranges, skipping the supposed phone numbers 53 $without_html[$i] = preg_replace('@( [^\-^0-9][0-9]+)-([0-9]+[^0-9^\-])@', "\$1–\$2", $without_html[$i]);53 $without_html[$i] = preg_replace('@((^|[^\-^0-9])[0-9]+)-([0-9]+([^0-9^\-]|$))@', "\$1–\$3", $without_html[$i]); 54 54 //Add non-breaking spaces 55 55 $new_content .= preg_replace("@(?<!')\b(at|or|and|the|a|an|in|on|of|for|to|as|i|or|my) @i", "\$1 ", $without_html[$i]);
Note: See TracChangeset
for help on using the changeset viewer.