3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2014 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
13 if (!defined('_ECRIRE_INC_VERSION')) return;
15 // Correction typographique francaise
17 function typographie_fr_dist($letexte) {
19 static $trans, $cherche1, $remplace1, $cherche2, $remplace2;
20 // Nettoyer 160 = nbsp ; 187 = raquo ; 171 = laquo ; 176 = deg ;
21 // 147 = ldquo; 148 = rdquo; ' = zouli apostrophe
26 "»" => "»",
27 "«" => "«",
28 "”" => "”",
29 "“" => "“",
32 $chars = array(160 => '~', 187 => '»', 171 => '«', 148 => '”', 147 => '“', 176 => '°');
33 $chars_trans = array_keys($chars);
34 $chars = array_values($chars);
35 $chars_trans = implode(' ',array_map('chr',$chars_trans));
36 $chars_trans = unicode2charset(charset2unicode($chars_trans, 'iso-8859-1', 'forcer'));
37 $chars_trans = explode(" ",$chars_trans);
38 foreach($chars as $k=>$r)
39 $trans[$chars_trans[$k]] = $r;
43 /* 1 */ '/((?:^|[^\#0-9a-zA-Z\&])[\#0-9a-zA-Z]*)\;/S',
44 /* 2 */ '/»| --?,|(?::| %)(?:\W|$)/S',
45 /* 3 */ '/([^[<(!?.])([!?][!?\.]*)/iS',
46 /* 4 */ '/«|(?:M(?:M?\.|mes?|r\.?)|[MnN]°) /S'
55 '/([^-\n]|^)--([^-]|$)/S',
56 ',(' ._PROTOCOLES_STD
. ')~((://[^"\'\s\[\]\}\)<>]+)~([?]))?,S',
65 $letexte = strtr($letexte, $trans);
66 $letexte = preg_replace($cherche1, $remplace1, $letexte);
67 $letexte = preg_replace("/ *~+ */S", "~", $letexte);
68 $letexte = preg_replace($cherche2, $remplace2, $letexte);