Changeset 141803
- Timestamp:
- 08/01/2009 04:46:06 PM (17 years ago)
- Location:
- post-typographer/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (5 diffs)
-
typopost.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
post-typographer/trunk/readme.txt
r140847 r141803 3 3 Requires at least: 2.5 4 4 Tested up to: 2.8.2 5 Stable tag: 25 Stable tag: 3 6 6 7 Adds non-breaking spaces and dashes where needed. Works with English texts only.7 Adds non-breaking spaces, common spaces and dashes where needed. Works with English texts only. 8 8 9 9 == Description == … … 14 14 1. All hyphens between two words (surrounded by spaces) will be transformed to 15 15 m-dashes with the non-breaking spaces ahead of them. 16 2. All hyphens between digits (without spaces) will be transformed to n-dashes. 16 2. All hyphens between digits (without spaces) will be transformed to n-dashes. 17 But it tries to preserve phone numbers. 17 18 3. All spaces following these words will be replaced with the non-breaking 18 19 spaces: … … 32 33 * or 33 34 * my 35 4. Double and more spaces are replaced with the single ones. 36 5. All misplaced spaces near dots, commas, semicolons, colons, exclamation 37 marks and question marks are fixed, where possible. 34 38 35 39 Porblems: … … 43 47 ` 44 48 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. 49 2. The n-dash thing will mess up with the phone numbers that have only one 50 hyphen in them. They will be confused with the value ranges. 48 51 49 52 == Installation == … … 53 56 54 57 == 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 62 numbers) when the hyphens in the value ranges are transformed into n-dashes. 55 63 56 64 = 2 = -
post-typographer/trunk/typopost.php
r140506 r141803 3 3 Plugin Name: Post Typographer 4 4 Plugin 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.5 Description: Formats the text according to typography rules. Works with English texts only. 6 6 Author: Andriy Moraru 7 Version: 27 Version: 3 8 8 Author URI: http://www.topforexnews.com 9 9 */ … … 35 35 $content = preg_replace('@ {2,}@', ' ', $content); 36 36 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); 39 39 40 40 //Get the array of strings made of text without HTML tags … … 46 46 for ($i = 0; $i <= $amount; $i++) 47 47 { 48 //Add n-dashes in place of hyphens in the numeric ranges 49 $without_html[$i] = preg_replace('@([0-9])-([0-9])@', "\$1–\$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–\$2", $without_html[$i]); 50 54 //Add non-breaking spaces 51 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.