WordPress.org

Plugin Directory

Changeset 179822


Ignore:
Timestamp:
12/05/09 05:32:14 (4 years ago)
Author:
rmccue
Message:

Put Unicode characters in correctly this time! v1.0.2

Location:
to-title-case/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • to-title-case/trunk/readme.txt

    r179792 r179822  
    4848== Changelog == 
    4949 
     50= 1.0.2 
     51Ryan: Use Unicode characters correctly. 
     52 
    5053= 1.0.1 = 
    5154Kroc: Add `\p{L}` to get accented letters working. 
  • to-title-case/trunk/to-title-case.php

    r179792 r179822  
    44Plugin URL: http://ryanmccue.info/projects/wordpress/to-title-case/ 
    55Description: Automatically converts post titles on-the-fly, using <a href="http://camendesign.com/code/title-case">Kroc Camen's port</a> of John Gruber's title case. 
    6 Version: 1.0.1 
     6Version: 1.0.2 
    77Author: Ryan McCue 
    88Author URI: http://ryanmccue.info/ 
     
    2323     
    2424    //find each word (including punctuation attached) 
    25     preg_match_all ('/[\w\p{L}&`\'?"?.@:\/\{\(\[<>_]+-? */u', $title, $m1, PREG_OFFSET_CAPTURE); 
     25    preg_match_all ('/[\w\p{L}&`\'‘’"“\.@:\/\{\(\[<>_]+-? */u', $title, $m1, PREG_OFFSET_CAPTURE); 
    2626    foreach ($m1[0] as &$m2) { 
    2727        //shorthand these- "match" and "index" 
     
    3232        $i = mb_strlen (substr ($title, 0, $i), 'UTF-8'); 
    3333         
    34         //find words that should always be lowercase?       //(never on the first word, and never if preceded by a colon) 
     34        //find words that should always be lowercase… 
     35        //(never on the first word, and never if preceded by a colon) 
    3536        $m = $i>0 && mb_substr ($title, max (0, $i-2), 1, 'UTF-8') !== ':' && preg_match ( 
    3637            '/^(a(nd?|s|t)?|b(ut|y)|en|for|i[fn]|o[fnr]|t(he|o)|vs?\.?|via)[ \-]/i', $m 
    37         ) ? //ond convert them to lowercase 
     38        ) ? //…and convert them to lowercase 
    3839            mb_strtolower ($m, 'UTF-8') 
    3940             
    4041        //else: brackets and other wrappers 
    41         : ( preg_match ('/[\'"_{(\[?]/u', mb_substr ($title, max (0, $i-1), 3, 'UTF-8')) 
     42        : ( preg_match ('/[\'"_{(\[‘“]/u', mb_substr ($title, max (0, $i-1), 3, 'UTF-8')) 
    4243        ?   //convert first letter within wrapper to uppercase 
    4344            mb_substr ($m, 0, 1, 'UTF-8'). 
Note: See TracChangeset for help on using the changeset viewer.