X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=www%2Fplugins-dist%2Ftextwheel%2Ftypographie%2Ffr.php;fp=www%2Fplugins-dist%2Ftextwheel%2Ftypographie%2Ffr.php;h=ddf3f337a2921be5eee29d6ffc7adb0cdd5558fe;hb=a33c2ba9d919664b3bb0f565f8e9a8b9d8530cdb;hp=0000000000000000000000000000000000000000;hpb=8945248b3d948385798d9aa355c70e7089aca2b3;p=lhc%2Fweb%2Fclavette_www.git diff --git a/www/plugins-dist/textwheel/typographie/fr.php b/www/plugins-dist/textwheel/typographie/fr.php new file mode 100644 index 0000000..ddf3f33 --- /dev/null +++ b/www/plugins-dist/textwheel/typographie/fr.php @@ -0,0 +1,94 @@ + '~', + "»" => '»', + "«" => '«', + "”" => '”', + "“" => '“', + "°" => '°', + "'" => '’' + ); + switch ($GLOBALS['meta']['charset']) { + case 'utf-8': + $trans["\xc2\xa0"] = '~'; + $trans["\xc2\xbb"] = '»'; + $trans["\xc2\xab"] = '«'; + $trans["\xe2\x80\x94"] = '--'; + $trans["\xe2\x80\x9d"] = '”'; + $trans["\xe2\x80\x9c"] = '“'; + $trans["\xc2\xb0"] = '°'; + $trans["\xe2\x80\x89"] = '~'; # &finesp; + break; + default: + $trans["\xa0"] = '~'; + $trans["\xab"] = '«'; + $trans["\xbb"] = '»'; + $trans["\xb0"] = '°'; + break; + } + } + + # cette chaine ne peut pas exister, + # cf. TYPO_PROTECTEUR dans inc/texte + $pro = "-\x2-"; + + $t = str_replace(array_keys($trans), array_values($trans), $t); + + # la typo du ; risque de clasher avec les entites &xxx; + if (strpos($t, ';') !== false) { + $t = str_replace(';', '~;', $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); + + + /* 3 */ + $t = preg_replace('/[!?][!?\.]*/S', "$pro~$0", $t, -1, $c); + if ($c) { + $t = preg_replace("/([\[<\(!\?\.])$pro~/S", '$1', $t); + $t = str_replace("$pro", '', $t); + } + + /* 4 */ + $t = preg_replace('/«|M(?:M?\.|mes?|r\.?|°) |[nN]° /S', '$0~', $t); + + if (strpos($t, '~') !== false) + $t = preg_replace("/ *~+ */S", "~", $t); + + $t = preg_replace("/--([^-]|$)/S", "$pro—$1", $t, -1, $c); + if ($c) { + $t = preg_replace("/([-\n])$pro—/S", "$1--", $t); + $t = str_replace($pro, '', $t); + } + + $t = preg_replace(',(' ._PROTOCOLES_STD . ')~((://[^"\'\s\[\]\}\)<>]+)~([?]))?,S', '$1$3$4', $t); + $t = str_replace('~', ' ', $t); + + return $t; +}