Plugin Directory

Changeset 141803


Ignore:
Timestamp:
08/01/2009 04:46:06 PM (17 years ago)
Author:
enivid
Message:
 
Location:
post-typographer/trunk
Files:
2 edited

Legend:

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

    r140847 r141803  
    33Requires at least: 2.5
    44Tested up to: 2.8.2
    5 Stable tag: 2
     5Stable tag: 3
    66
    7 Adds non-breaking spaces and dashes where needed. Works with English texts only.
     7Adds non-breaking spaces, common spaces and dashes where needed. Works with English texts only.
    88
    99== Description ==
     
    14141. All hyphens between two words (surrounded by spaces) will be transformed to
    1515m-dashes with the non-breaking spaces ahead of them.
    16 2. All hyphens between digits (without spaces) will be transformed to n-dashes.
     162. All hyphens between digits (without spaces) will be transformed to n-dashes.
     17But it tries to preserve phone numbers.
    17183. All spaces following these words will be replaced with the non-breaking
    1819spaces:
     
    3233* or
    3334* my
     354. Double and more spaces are replaced with the single ones.
     365. All misplaced spaces near dots, commas, semicolons, colons, exclamation
     37marks and question marks are fixed, where possible.
    3438
    3539Porblems:
     
    4347`
    4448
    45 2. The n-dash thing will mess up with the phone numbers. They are not the value
    46 ranges and should use hyphens, but I don't know how to make this plugin skip
    47 hyphens in the phone numbers exclusively.
     492. The n-dash thing will mess up with the phone numbers that have only one
     50hyphen in them. They will be confused with the value ranges.
    4851
    4952== Installation ==
     
    5356
    5457== Changelog ==
     58
     59= 3 =
     60* Added: Replaces misplaced spaces near punctuation marks.
     61* Fixed: Phone numbers and dates are now avoided (except single-hyphen phone
     62numbers) when the hyphens in the value ranges are transformed into n-dashes.
    5563
    5664= 2 =
  • post-typographer/trunk/typopost.php

    r140506 r141803  
    33Plugin Name: Post Typographer
    44Plugin URI: http://wordpress.org/extend/plugins/post-typographer/
    5 Description: Adds non-breaking spaces and dashes where needed, replaces double (and more) spaces with single. Works with English texts only.
     5Description: Formats the text according to typography rules. Works with English texts only.
    66Author: Andriy Moraru
    7 Version: 2
     7Version: 3
    88Author URI: http://www.topforexnews.com
    99*/
     
    3535    $content = preg_replace('@ {2,}@', ' ', $content);
    3636
    37     //Add m-dashes with a preceeding non-breaking space in place of the hyphens where neeeded
    38     $content = str_replace(' - ', ' — ', $content);
     37        //Replace double (and more) spaces with single spaces
     38    $content = preg_replace('@ {2,}@', ' ', $content);
    3939
    4040    //Get the array of strings made of text without HTML tags
     
    4646    for ($i = 0; $i <= $amount; $i++)
    4747    {
    48             //Add n-dashes in place of hyphens in the numeric ranges
    49         $without_html[$i] = preg_replace('@([0-9])-([0-9])@', "\$1&#8211;\$2", $without_html[$i]);
     48        //Remove space before the punctuation marks that are placed directly after the words
     49        $without_html[$i] = preg_replace('@ (\.|,|;|:|!|\?)@', "\$1", $without_html[$i]);
     50        //Add space after the punctuation marks where needed
     51        $without_html[$i] = preg_replace('@(,|;|!|\?)([a-z]+)@i', "\$1 \$2", $without_html[$i]);
     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&#8211;\$2", $without_html[$i]);
    5054        //Add non-breaking spaces
    5155        $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.