3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2013 *
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);
64 $t = preg_replace('/»| --?,|(?::(?!:)| %)(?:\W|$)/S', '~$0', $t);
67 $t = preg_replace('/[!?][!?\.]*/S', "$pro~$0", $t, -1, $c);
69 $t = preg_replace("/([\[<\(!\?\.])$pro~/S", '$1', $t);
70 $t = str_replace("$pro", '', $t);
74 $t = preg_replace('/«|M(?:M?\.|mes?|r\.?|°) |[nN]° /S', '$0~', $t);
76 if (strpos($t, '~') !== false)
77 $t = preg_replace("/ *~+ */S", "~", $t);
79 $t = preg_replace("/--([^-]|$)/S", "$pro—$1", $t, -1, $c);
81 $t = preg_replace("/([-\n])$pro—/S", "$1--", $t);
82 $t = str_replace($pro, '', $t);
85 $t = preg_replace(',(https?|ftp|mailto)~((://[^"\'\s\[\]\}\)<>]+)~([?]))?,S', '$1$3$4', $t);
86 $t = str_replace('~', ' ', $t);