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) {
21 // Nettoyer 160 = nbsp ; 187 = raquo ; 171 = laquo ; 176 = deg ;
22 // 147 = ldquo; 148 = rdquo; ' = zouli apostrophe
27 "»" => "»",
28 "«" => "«",
29 "”" => "”",
30 "“" => "“",
33 $chars = array(160 => '~', 187 => '»', 171 => '«', 148 => '”', 147 => '“', 176 => '°');
34 $chars_trans = array_keys($chars);
35 $chars = array_values($chars);
36 $chars_trans = implode(' ',array_map('chr',$chars_trans));
37 $chars_trans = unicode2charset(charset2unicode($chars_trans, 'iso-8859-1', 'forcer'));
38 $chars_trans = explode(" ",$chars_trans);
39 foreach($chars as $k=>$r)
40 $trans[$chars_trans[$k]] = $r;
43 $letexte = strtr($letexte, $trans);
46 /* 1 */ '/((?:^|[^\#0-9a-zA-Z\&])[\#0-9a-zA-Z]*)\;/S',
47 /* 2 */ '/»| --?,|(?::(?!:)| %)(?:\W|$)/S',
48 /* 3 */ '/([^[<(!?.])([!?][!?\.]*)/iS',
49 /* 4 */ '/«|(?:M(?:M?\.|mes?|r\.?)|[MnN]°) /S'
57 $letexte = preg_replace($cherche1, $remplace1, $letexte);
58 $letexte = preg_replace("/ *~+ */S", "~", $letexte);
61 '/([^-\n]|^)--([^-]|$)/S',
62 ',(' ._PROTOCOLES_STD
. ')~((://[^"\'\s\[\]\}\)<>]+)~([?]))?,S',
70 $letexte = preg_replace($cherche2, $remplace2, $letexte);