Plugin Directory

Changeset 142371


Ignore:
Timestamp:
08/03/2009 08:51:39 AM (17 years ago)
Author:
enivid
Message:
 
Location:
post-typographer/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • post-typographer/trunk/readme.txt

    r141803 r142371  
    5757== Changelog ==
    5858
     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
     63beginning or the end of the text.
     64
    5965= 3 =
    6066* Added: Replaces misplaced spaces near punctuation marks.
  • post-typographer/trunk/typopost.php

    r141803 r142371  
    55Description: Formats the text according to typography rules. Works with English texts only.
    66Author: Andriy Moraru
    7 Version: 3
     7Version: 4
    88Author URI: http://www.topforexnews.com
    99*/
     
    3535    $content = preg_replace('@ {2,}@', ' ', $content);
    3636
    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);
    3939
    4040    //Get the array of strings made of text without HTML tags
     
    4949        $without_html[$i] = preg_replace('@ (\.|,|;|:|!|\?)@', "\$1", $without_html[$i]);
    5050        //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]);
    5252            //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]);
    5454        //Add non-breaking spaces
    5555        $new_content .= preg_replace("@(?<!')\b(at|or|and|the|a|an|in|on|of|for|to|as|i|or|my) @i", "\$1&nbsp;", $without_html[$i]);
Note: See TracChangeset for help on using the changeset viewer.