function typo_guillemets_post_typo($texte) { // ... switch ($GLOBALS['spip_lang']) { case 'fr': $guilles="«  »"; //LRTEUIN break; // ... } // escape any " found in the tags; // note is the character chr(1), and represents the tag $texte = preg_replace(',<[^>]*"[^>]*(>|$),msSe', "str_replace('\"','', \"\")", $texte); // We correct any remaining quotes, which are by definition not within tags // A quote is not processed if it follows a non-space character, or // if it is followed by a word (letter, digit) $texte = preg_replace('/(^|\s)"\s?([^"]*?)\s?"(\W|$)/S', ''.$guilles.'', $texte); // and put back the quotes in any tags return str_replace("", '"', $texte); }