3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2016 *
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($t) {
26 "»" => '»',
27 "«" => '«',
28 "”" => '”',
29 "“" => '“',
33 $charset = isset($GLOBALS['meta']['charset']) ?
$GLOBALS['meta']['charset'] : '';
36 $trans["\xc2\xa0"] = '~';
37 $trans["\xc2\xbb"] = '»';
38 $trans["\xc2\xab"] = '«';
39 $trans["\xe2\x80\x94"] = '--';
40 $trans["\xe2\x80\x9d"] = '”';
41 $trans["\xe2\x80\x9c"] = '“';
42 $trans["\xc2\xb0"] = '°';
43 $trans["\xe2\x80\x89"] = '~'; # &finesp;
47 $trans["\xab"] = '«';
48 $trans["\xbb"] = '»';
49 $trans["\xb0"] = '°';
54 # cette chaine ne peut pas exister,
55 # cf. TYPO_PROTECTEUR dans inc/texte
58 $t = str_replace(array_keys($trans), array_values($trans), $t);
60 # la typo du ; risque de clasher avec les entites &xxx;
61 if (strpos($t, ';') !== false) {
62 $t = str_replace(';', '~;', $t);
63 $t = preg_replace(',(&#?[0-9a-z]+)~;,iS', '$1;', $t);
67 $t = preg_replace('/»| --?,|(?::(?!:)| %)(?:\W|$)/S', '~$0', $t);
70 $t = preg_replace('/[!?][!?\.]*/S', "$pro~$0", $t, -1, $c);
72 $t = preg_replace("/([\[<\(!\?\.])$pro~/S", '$1', $t);
73 $t = str_replace("$pro", '', $t);
77 $t = preg_replace('/«|M(?:M?\.|mes?|r\.?|°) |[nN]° /S', '$0~', $t);
79 if (strpos($t, '\~') !== false) {
80 $t = str_replace('\~', "\x1\x14", $t);
83 if (strpos($t, '~') !== false) {
84 $t = preg_replace("/ *~+ */S", "~", $t);
87 $t = preg_replace("/--([^-]|$)/S", "$pro—$1", $t, -1, $c);
89 $t = preg_replace("/([-\n])$pro—/S", "$1--", $t);
90 $t = str_replace($pro, '', $t);
93 $t = preg_replace(',(' . _PROTOCOLES_STD
. ')~((://[^"\'\s\[\]\}\)<>]+)~([?]))?,S', '$1$3$4', $t);
94 $t = str_replace('~', ' ', $t);
96 if (strpos($t, "\x1") !== false) {
97 $t = str_replace("\x1\x14", '~', $t);