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($t) {
24 "»" => '»',
25 "«" => '«',
26 "”" => '”',
27 "“" => '“',
31 switch ($GLOBALS['meta']['charset']) {
33 $trans["\xc2\xa0"] = '~';
34 $trans["\xc2\xbb"] = '»';
35 $trans["\xc2\xab"] = '«';
36 $trans["\xe2\x80\x94"] = '--';
37 $trans["\xe2\x80\x9d"] = '”';
38 $trans["\xe2\x80\x9c"] = '“';
39 $trans["\xc2\xb0"] = '°';
40 $trans["\xe2\x80\x89"] = '~'; # &finesp;
44 $trans["\xab"] = '«';
45 $trans["\xbb"] = '»';
46 $trans["\xb0"] = '°';
51 # cette chaine ne peut pas exister,
52 # cf. TYPO_PROTECTEUR dans inc/texte
55 $t = str_replace(array_keys($trans), array_values($trans), $t);
57 # la typo du ; risque de clasher avec les entites &xxx;
58 if (strpos($t, ';') !== false) {
59 $t = str_replace(';', '~;', $t);
60 $t = preg_replace(',(&#?[0-9a-z]+)~;,iS', '$1;', $t);
63 /* 2 ; ajout d'insecable */
64 $t = preg_replace('/»| --?,|(?::| %)(?:\W|$)/S', '~$0', $t);
66 // {»} guillemet en italiques : ne pas doubler l'insecable
67 $t = str_replace('~{~', '~{', $t);
68 $t = str_replace('~}~', '}~', $t);
72 $t = preg_replace('/[!?][!?\.]*/S', "$pro~$0", $t, -1, $c);
74 $t = preg_replace("/([\[<\(!\?\.])$pro~/S", '$1', $t);
75 $t = str_replace("$pro", '', $t);
79 $t = preg_replace('/«|M(?:M?\.|mes?|r\.?|°) |[nN]° /S', '$0~', $t);
81 if (strpos($t, '~') !== false)
82 $t = preg_replace("/ *~+ */S", "~", $t);
84 $t = preg_replace("/--([^-]|$)/S", "$pro—$1", $t, -1, $c);
86 $t = preg_replace("/([-\n])$pro—/S", "$1--", $t);
87 $t = str_replace($pro, '', $t);
90 $t = preg_replace(',(' ._PROTOCOLES_STD
. ')~((://[^"\'\s\[\]\}\)<>]+)~([?]))?,S', '$1$3$4', $t);
91 $t = str_replace('~', ' ', $t);