X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=www%2Fplugins-dist%2Ftextwheel%2Ftypographie%2Ffr.php;h=6673ea482a106341aebd1fae4b33db37f9117e95;hb=4f443dce95ff6f8221c189880a70c74ce1c1f238;hp=8ec2f982641f67d59fa449a517750b9d209897bc;hpb=4a628e9b277d3617535f99d663ca79fa2e891177;p=lhc%2Fweb%2Fwww.git diff --git a/www/plugins-dist/textwheel/typographie/fr.php b/www/plugins-dist/textwheel/typographie/fr.php index 8ec2f982..6673ea48 100644 --- a/www/plugins-dist/textwheel/typographie/fr.php +++ b/www/plugins-dist/textwheel/typographie/fr.php @@ -10,7 +10,9 @@ * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * \***************************************************************************/ -if (!defined("_ECRIRE_INC_VERSION")) return; +if (!defined("_ECRIRE_INC_VERSION")) { + return; +} // Correction typographique francaise @@ -20,15 +22,16 @@ function typographie_fr($t) { if (!isset($trans)) { $trans = array( - " " => '~', - "»" => '»', - "«" => '«', - "”" => '”', - "“" => '“', - "°" => '°', - "'" => '’' + " " => '~', + "»" => '»', + "«" => '«', + "”" => '”', + "“" => '“', + "°" => '°', + "'" => '’' ); - switch ($GLOBALS['meta']['charset']) { + $charset = isset($GLOBALS['meta']['charset']) ? $GLOBALS['meta']['charset'] : ''; + switch ($charset) { case 'utf-8': $trans["\xc2\xa0"] = '~'; $trans["\xc2\xbb"] = '»'; @@ -60,13 +63,8 @@ function typographie_fr($t) { $t = preg_replace(',(&#?[0-9a-z]+)~;,iS', '$1;', $t); } - /* 2 ; ajout d'insecable */ - $t = preg_replace('/»| --?,|(?::| %)(?:\W|$)/S', '~$0', $t); - - // {»} guillemet en italiques : ne pas doubler l'insecable - $t = str_replace('~{~', '~{', $t); - $t = str_replace('~}~', '}~', $t); - + /* 2 */ + $t = preg_replace('/»| --?,|(?::(?!:)| %)(?:\W|$)/S', '~$0', $t); /* 3 */ $t = preg_replace('/[!?][!?\.]*/S', "$pro~$0", $t, -1, $c); @@ -78,8 +76,13 @@ function typographie_fr($t) { /* 4 */ $t = preg_replace('/«|M(?:M?\.|mes?|r\.?|°) |[nN]° /S', '$0~', $t); - if (strpos($t, '~') !== false) + if (strpos($t, '\~') !== false) { + $t = str_replace('\~', "\x1\x14", $t); + } + + if (strpos($t, '~') !== false) { $t = preg_replace("/ *~+ */S", "~", $t); + } $t = preg_replace("/--([^-]|$)/S", "$pro—$1", $t, -1, $c); if ($c) { @@ -87,8 +90,12 @@ function typographie_fr($t) { $t = str_replace($pro, '', $t); } - $t = preg_replace(',(' ._PROTOCOLES_STD . ')~((://[^"\'\s\[\]\}\)<>]+)~([?]))?,S', '$1$3$4', $t); + $t = preg_replace(',(' . _PROTOCOLES_STD . ')~((://[^"\'\s\[\]\}\)<>]+)~([?]))?,S', '$1$3$4', $t); $t = str_replace('~', ' ', $t); + if (strpos($t, "\x1") !== false) { + $t = str_replace("\x1\x14", '~', $t); + } + return $t; }