[SPIP][PLUGINS] v3.0-->v3.2
[lhc/web/www.git] / www / ecrire / typographie / fr.php
index 8de98d1..a9fa189 100644 (file)
@@ -3,14 +3,16 @@
 /***************************************************************************\
  *  SPIP, Systeme de publication pour l'internet                           *
  *                                                                         *
- *  Copyright (c) 2001-2016                                                *
+ *  Copyright (c) 2001-2017                                                *
  *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
  *                                                                         *
  *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
  *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
 \***************************************************************************/
 
-if (!defined('_ECRIRE_INC_VERSION')) return;
+if (!defined('_ECRIRE_INC_VERSION')) {
+       return;
+}
 
 // Correction typographique francaise
 
@@ -22,44 +24,53 @@ function typographie_fr_dist($letexte) {
        // 147 = ldquo; 148 = rdquo; ' = zouli apostrophe
        if (!$trans) {
                $trans = array(
-                       "'" => "’",
-                       " " => "~",
-                       "»" => "»",
-                       "«" => "«",
-                       "”" => "”",
-                       "“" => "“",
-                       "°" => "°"
+                       "'" => '’',
+                       ' ' => '~',
+                       '»' => '»',
+                       '«' => '«',
+                       '”' => '”',
+                       '“' => '“',
+                       '°' => '°'
                );
                $chars = array(160 => '~', 187 => '»', 171 => '«', 148 => '”', 147 => '“', 176 => '°');
                $chars_trans = array_keys($chars);
                $chars = array_values($chars);
-               $chars_trans = implode(' ',array_map('chr',$chars_trans));
+               $chars_trans = implode(' ', array_map('chr', $chars_trans));
                $chars_trans = unicode2charset(charset2unicode($chars_trans, 'iso-8859-1', 'forcer'));
-               $chars_trans = explode(" ",$chars_trans);
-               foreach($chars as $k=>$r)
+               $chars_trans = explode(' ', $chars_trans);
+               foreach ($chars as $k => $r) {
                        $trans[$chars_trans[$k]] = $r;
+               }
        }
 
        $letexte = strtr($letexte, $trans);
 
        $cherche1 = array(
-               /* 1 */         '/((?:^|[^\#0-9a-zA-Z\&])[\#0-9a-zA-Z]*)\;/S',
-               /* 2 */         '/»| --?,|(?::(?!:)| %)(?:\W|$)/S',
-               /* 3 */         '/([^[<(!?.])([!?][!?\.]*)/iS',
-               /* 4 */         '/&#171;|(?:M(?:M?\.|mes?|r\.?)|[MnN]&#176;) /S'
+               /* 1 */
+               '/((?:^|[^\#0-9a-zA-Z\&])[\#0-9a-zA-Z]*)\;/S',
+               /* 2 */
+               '/&#187;| --?,|(?::(?!:)| %)(?:\W|$)/S',
+               /* 3 */
+               '/([^[<(!?.])([!?][!?\.]*)/iS',
+               /* 4 */
+               '/&#171;|(?:M(?:M?\.|mes?|r\.?)|[MnN]&#176;) /S'
        );
        $remplace1 = array(
-               /* 1 */         '\1~;',
-               /* 2 */         '~\0',
-               /* 3 */         '\1~\2',
-               /* 4 */         '\0~'
+               /* 1 */
+               '\1~;',
+               /* 2 */
+               '~\0',
+               /* 3 */
+               '\1~\2',
+               /* 4 */
+               '\0~'
        );
        $letexte = preg_replace($cherche1, $remplace1, $letexte);
-       $letexte = preg_replace("/ *~+ */S", "~", $letexte);
+       $letexte = preg_replace('/ *~+ */S', '~', $letexte);
 
        $cherche2 = array(
                '/([^-\n]|^)--([^-]|$)/S',
-               ',(' ._PROTOCOLES_STD . ')~((://[^"\'\s\[\]\}\)<>]+)~([?]))?,S',
+               ',(' . _PROTOCOLES_STD . ')~((://[^"\'\s\[\]\}\)<>]+)~([?]))?,S',
                '/~/'
        );
        $remplace2 = array(