X-Git-Url: http://git.cyclocoop.org/?p=velocampus%2Fweb%2Fwww.git;a=blobdiff_plain;f=www%2Fecrire%2Ftypographie%2Ffr.php;fp=www%2Fecrire%2Ftypographie%2Ffr.php;h=7101c2d83276794f3fa3a4313dd0f0034ad41228;hp=0000000000000000000000000000000000000000;hb=80b4d3e85f78d402ed2e73f8f5d1bf4c19962eed;hpb=aaf970bf4cdaf76689ecc10609048e18d073820c diff --git a/www/ecrire/typographie/fr.php b/www/ecrire/typographie/fr.php new file mode 100644 index 0000000..7101c2d --- /dev/null +++ b/www/ecrire/typographie/fr.php @@ -0,0 +1,73 @@ + "’", + " " => "~", + "»" => "»", + "«" => "«", + "”" => "”", + "“" => "“", + "°" => "°" + ); + $chars = array(160 => '~', 187 => '»', 171 => '«', 148 => '”', 147 => '“', 176 => '°'); + $chars_trans = array_keys($chars); + $chars = array_values($chars); + $chars_trans = implode(' ',array_map('chr',$chars_trans)); + $chars_trans = unicode2charset(charset2unicode($chars_trans, 'iso-8859-1', 'forcer')); + $chars_trans = explode(" ",$chars_trans); + foreach($chars as $k=>$r) + $trans[$chars_trans[$k]] = $r; + } + + $letexte = strtr($letexte, $trans); + + $cherche1 = array( + /* 1 */ '/((?:^|[^\#0-9a-zA-Z\&])[\#0-9a-zA-Z]*)\;/S', + /* 2 */ '/»| --?,|(?::| %)(?:\W|$)/S', + /* 3 */ '/([^[<(])([!?][!?\.]*)/iS', + /* 4 */ '/«|(?:M(?:M?\.|mes?|r\.?)|[MnN]°) /S' + ); + $remplace1 = array( + /* 1 */ '\1~;', + /* 2 */ '~\0', + /* 3 */ '\1~\2', + /* 4 */ '\0~' + ); + $letexte = preg_replace($cherche1, $remplace1, $letexte); + $letexte = preg_replace("/ *~+ */S", "~", $letexte); + + $cherche2 = array( + '/([^-\n]|^)--([^-]|$)/S', + ',(http|https|ftp|mailto)~((://[^"\'\s\[\]\}\)<>]+)~([?]))?,S', + '/~/' + ); + $remplace2 = array( + '\1—\2', + '\1\3\4', + ' ' + ); + $letexte = preg_replace($cherche2, $remplace2, $letexte); + + return $letexte; +}