Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Curly Quote Maker (See related posts)

// Run text through this function to make curly quotes


        function curl_me($curlme) {
        // This should take care of the single quotes
        $curlme = preg_replace("/'([dmst])([ .,?!\)\/<])/i","’$1$2",$curlme);
        $curlme = preg_replace("/'([lrv])([el])([ .,?!\)\/<])/i","’$1$2$3",$curlme);
        $curlme = preg_replace("/(?\s+)'((?:[^ >])?(?:.*?)(?:[^=]))'(\s*[^>&])/Ss","$1‘$2’$3",$curlme);

        // time for the doubles
        $curlme = preg_replace('/(?]])((?:.*?)(?:[^=])?)"(\s*[^>&])/Ss',"$1“$2”$3",$curlme);
        // multi-paragraph
        $curlme = preg_replace('/

"(.*)<\/p>/U',"

“$1

",$curlme); // not a quote, but whatever $curlme = str_replace('Ñ','',$curlme); $curlme = str_replace('Ð','',$curlme); return $curlme; }

You need to create an account or log in to post comments to this site.


Related Posts