3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2019 *
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')) {
17 // Correction typographique francaise
19 function typographie_fr_dist($letexte) {
23 // Nettoyer 160 = nbsp ; 187 = raquo ; 171 = laquo ; 176 = deg ;
24 // 147 = ldquo; 148 = rdquo; ' = zouli apostrophe
29 '»' => '»',
30 '«' => '«',
31 '”' => '”',
32 '“' => '“',
35 $chars = array(160 => '~', 187 => '»', 171 => '«', 148 => '”', 147 => '“', 176 => '°');
36 $chars_trans = array_keys($chars);
37 $chars = array_values($chars);
38 $chars_trans = implode(' ', array_map('chr', $chars_trans));
39 $chars_trans = unicode2charset(charset2unicode($chars_trans, 'iso-8859-1', 'forcer'));
40 $chars_trans = explode(' ', $chars_trans);
41 foreach ($chars as $k => $r) {
42 $trans[$chars_trans[$k]] = $r;
46 $letexte = strtr($letexte, $trans);
50 '/((?:^|[^\#0-9a-zA-Z\&])[\#0-9a-zA-Z]*)\;/S',
52 '/»| --?,|(?::(?!:)| %)(?:\W|$)/S',
54 '/([^[<(!?.])([!?][!?\.]*)/iS',
56 '/«|(?:M(?:M?\.|mes?|r\.?)|[MnN]°) /S'
68 $letexte = preg_replace($cherche1, $remplace1, $letexte);
69 $letexte = preg_replace('/ *~+ */S', '~', $letexte);
72 '/([^-\n]|^)--([^-]|$)/S',
73 ',(' . _PROTOCOLES_STD
. ')~((://[^"\'\s\[\]\}\)<>]+)~([?]))?,S',
81 $letexte = preg_replace($cherche2, $remplace2, $letexte);