[PLUGINS] ~maj globale
[lhc/web/www.git] / www / plugins / enluminures_typographiques_v3 / typoenluminee.php
index 377da47..68f8788 100644 (file)
-<?php\r
-if (!defined("_ECRIRE_INC_VERSION")) return;\r
-\r
-/*\r
-  * Ce plugin rajoute des raccourcis typographique et ameliore les possibilites de la barre typographique pour les redacteurs\r
-*/\r
-\r
-       /*\r
-        *    Fonctions de ces filtres :\r
-        *     Ils rajoutent quelques racourcis typo a SPIP\r
-        *\r
-        *     Syntaxe des raccourcis :\r
-        *           [/texte/] : aligner le texte a droite\r
-        *           [!texte!] : aligner le texte a gauche\r
-        *           [|texte|] : centrer le texte\r
-        *           [(texte)] : encadrer le texte (occupe toute la largeur de la page, a mettre autour d'un paragraphe)\r
-        *           [*texte*] : encadrer/surligner le texte (une partie a l'interieur d'un paragraphe)\r
-        *           [**texte*] : variante encadrer/surligner le texte (une partie a l'interieur d'un paragraphe)\r
-        *           <sup>texte</sup> : mettre en exposant le texte selectionne\r
-        *           <sub>texte</sub> : mettre en indice le texte selectionne\r
-        *\r
-        *     Styles pour les encadrements a rajouter dans votre feuille de style :\r
-        *            .texteencadre-spip {\r
-        *              background: #FFE;\r
-        *              border-bottom: 2px solid #999999;\r
-        *              border-left: 1px solid #EEEEEE;\r
-        *              border-right: 2px solid #999999;\r
-        *              border-top: 1px solid #EEEEEE;\r
-        *              padding: .25em;\r
-        *           }\r
-        *           .caractencadre-spip {\r
-        *              border: 1px solid #666;\r
-        *              padding: 0px .5em 0px .5em;\r
-        *           }\r
-        *\r
-       */\r
-\r
-// Gerer les variables de personnalisation, fonction depreciee sous SPIP 2.0\r
-// A suivre sur la methode...\r
-if(!function_exists('tester_variable')) {\r
-       function tester_variable($var, $val){\r
-               if (!isset($GLOBALS[$var]))     $GLOBALS[$var] = $val;\r
-       }\r
-}\r
-\r
-function typoenluminee_pre_propre($texte) {\r
-       if(!$texte) return $texte;\r
-\r
-       static $chercher_raccourcis=NULL;\r
-       static $remplacer_raccourcis=NULL;\r
-       \r
-       if ($chercher_raccourcis===NULL) {\r
-       \r
-               // tous les elements block doivent etre introduits ici\r
-               // pour etre pris en charge par paragrapher\r
-       \r
-               // Definition des differents intertitres possibles, si pas deja definies\r
-               if ((!function_exists('lire_config')) OR (isset($GLOBALS['config_intertitre']))) {\r
-                       tester_variable('debut_intertitre', '<h3 class="spip">');\r
-                       tester_variable('fin_intertitre', '</h3>');\r
-                       tester_variable('debut_intertitre_2', '<h4 class="spip">');\r
-                       tester_variable('fin_intertitre_2', '</h4>');\r
-                       tester_variable('debut_intertitre_3', '<h5 class="spip">');\r
-                       tester_variable('fin_intertitre_3', '</h5>');\r
-                       tester_variable('debut_intertitre_4', '<h6 class="spip">');\r
-                       tester_variable('fin_intertitre_4', '</h6>');\r
-                       tester_variable('debut_intertitre_5', '<strong class="spip titraille5">');\r
-                       tester_variable('fin_intertitre_5', '</strong>');\r
-               } else {\r
-                       $GLOBALS['debut_intertitre'] = lire_config('bte/titraille1open','<h3 class="spip">');\r
-                       $GLOBALS['fin_intertitre'] = lire_config('bte/titraille1close','</h3>');\r
-                       $GLOBALS['debut_intertitre_2'] = lire_config('bte/titraille2open','<h4 class="spip">');\r
-                       $GLOBALS['fin_intertitre_2'] = lire_config('bte/titraille2close','</h4>');\r
-                       $GLOBALS['debut_intertitre_3'] = lire_config('bte/titraille3open','<h5 class="spip">');\r
-                       $GLOBALS['fin_intertitre_3'] = lire_config('bte/titraille3close','</h5>');\r
-                       $GLOBALS['debut_intertitre_4'] = lire_config('bte/titraille4open','<h6 class="spip">');\r
-                       $GLOBALS['fin_intertitre_4'] = lire_config('bte/titraille4close','</h6>');\r
-                       $GLOBALS['debut_intertitre_5'] = lire_config('bte/titraille5open','<strong class="spip titraille5">');\r
-                       $GLOBALS['fin_intertitre_5'] = lire_config('bte/titraille5close','</strong>');\r
-               }\r
-       \r
-               tester_variable('toujours_paragrapher', false);\r
-       \r
-               global $debut_intertitre, $fin_intertitre;\r
-               global $debut_intertitre_2, $fin_intertitre_2;\r
-               global $debut_intertitre_3, $fin_intertitre_3;\r
-               global $debut_intertitre_4, $fin_intertitre_4;\r
-               global $debut_intertitre_5, $fin_intertitre_5;\r
-       \r
-               $chercher_raccourcis=array();\r
-               $remplacer_raccourcis=array();\r
-       \r
-               /* 9b */        $chercher_raccourcis[]="/(^|[^{])[{][{][{]\*\*\*\*\*(.*)[}][}][}]($|[^}])/SUms";\r
-               /* 9 */         $chercher_raccourcis[]="/(^|[^{])[{][{][{]\*\*\*\*(.*)[}][}][}]($|[^}])/SUms";\r
-               /* 7 */         $chercher_raccourcis[]="/(^|[^{])[{][{][{]\*\*\*(.*)[}][}][}]($|[^}])/SUms";\r
-               /* 5 */         $chercher_raccourcis[]="/(^|[^{])[{][{][{]\*\*(.*)[}][}][}]($|[^}])/SUms";\r
-               /* 3 */         $chercher_raccourcis[]="/(^|[^{])[{][{][{]\*(.*)[}][}][}]($|[^}])/SUms";\r
-               /* 1 */         $chercher_raccourcis[]="/(^|[^{])[{][{][{](.*)[}][}][}]($|[^}])/SUms";\r
-               /* 11 */        $chercher_raccourcis[]="/\{(�|§)\{/S"; # § Pour gerer l'unicode aussi !\r
-               /* 12 */        $chercher_raccourcis[]="/\}(�|§)\}/S"; # ne pas sauvergarder ce fichier en utf8 !\r
-\r
-               /* 9b */        $remplacer_raccourcis[]="\$1\n\n$debut_intertitre_5\$2$fin_intertitre_5\n\n\$3";\r
-               /*  9 */        $remplacer_raccourcis[]="\$1\n\n$debut_intertitre_4\$2$fin_intertitre_4\n\n\$3";\r
-               /*  7 */        $remplacer_raccourcis[]="\$1\n\n$debut_intertitre_3\$2$fin_intertitre_3\n\n\$3";\r
-               /*  5 */        $remplacer_raccourcis[]="\$1\n\n$debut_intertitre_2\$2$fin_intertitre_2\n\n\$3";\r
-               /*  3 */        $remplacer_raccourcis[]="\$1\n\n$debut_intertitre\$2$fin_intertitre\n\n\$3";\r
-               /*  1 */        $remplacer_raccourcis[]="\$1\n\n$debut_intertitre\$2$fin_intertitre\n\n\$3";\r
-               /* 11 */        $remplacer_raccourcis[]="<sc>";\r
-               /* 12 */        $remplacer_raccourcis[]="</sc>";\r
-       }\r
-\r
-       // Conversion des intertitres d'enluminures type {n{titre}n}\r
-       // ou n est un nombre en intertitres avec des etoiles type {{{* (avec n etoiles)\r
-       // {1{ sera converti en {{{* ; {2{ sera converti en {{{** ; etc.\r
-       // Ne faire la recherche que s'il y a au moins un titre ancienne mode a convertir\r
-       if (strpos($texte, '{1{')!==false\r\r
-               OR strpos($texte, '{2{')!==false\r
-               OR strpos($texte, '{3{')!==false\r
-               OR strpos($texte, '{4{')!==false\r
-               OR strpos($texte, '{5{')!==false) {\r
-                       $texte=preg_replace_callback ("/\{(\d)\{(.*)\}(\\1)\}/Ums",\r
-                                                       create_function (\r
-                                                               '$matches',\r
-                                                               'return "{{{".str_repeat("*",$matches[1]).trim($matches[2])."}}}";'\r
-                                                       ),\r
-                                                       $texte);\r
-       }\r
-       $texte = preg_replace($chercher_raccourcis, $remplacer_raccourcis, $texte);\r
-\r
-       return $texte;\r
-}\r
-\r
-function typoenluminee_post_propre($texte) {\r
-       if(!$texte) return $texte;\r
-       static $cherche1 = NULL;\r
-       static $remplace1 = NULL;\r
-       if ($cherche1===NULL) {\r
-               # Le remplacement des intertitres de premier niveau a deja ete effectue dans inc/texte.php\r
-               $cherche1 = array();\r
-               $remplace1 = array();\r
-               $cherche1[] = /* 15 */  ",\[/(.*)/\],Ums";\r
-               $cherche1[] = /* 16 */  ",\[!(.*)!\],Ums";\r
-               $cherche1[] = /* 17 */  ",\[\|(.*)\|\],Ums";\r
-               $cherche1[] = /* 19 */  ",\[\((.*)\)\],Ums";\r
-               $cherche1[] = /* 21 */  "/\[\*\*/S";\r
-               $cherche1[] = /* 21b */         "/\[\*/S";\r
-               $cherche1[] = /* 22 */  "/\*\]/S";\r
-       \r
-               $remplace1[] = /* 15 */         "<div class=\"spip\" style=\"text-align:right;\">$1</div>";\r
-               $remplace1[] = /* 16 */         "<div class=\"spip\" style=\"text-align:left;\">$1</div>";\r
-               $remplace1[] = /* 17 */         "<div class=\"spip\" style=\"text-align:center;\">$1</div>";\r
-               $remplace1[] = /* 19 */         "<div class=\"texteencadre-spip spip\">$1</div>";\r
-               $remplace1[] = /* 21 */         "<strong class=\"caractencadre2-spip spip\">";\r
-               $remplace1[] = /* 21b */        "<strong class=\"caractencadre-spip spip\">";\r
-               $remplace1[] = /* 22 */ "</strong>";\r
-       }\r
-       $texte = preg_replace($cherche1, $remplace1, $texte);\r
-       $texte = paragrapher($texte,$GLOBALS['toujours_paragrapher']); // il faut reparagrapher a cause des raccourcis typo que l'on a ajoute (block div)\r
-       return $texte;\r
-}\r
-\r
-function typoenluminee_pre_liens($texte) {\r
-       if (!isset($GLOBALS['barre_typo_pas_de_fork_typo']) OR $GLOBALS['barre_typo_pas_de_fork_typo'] === true)\r
-               return $texte;\r
-\r
-       $texte = str_replace('<-->','&harr;',$texte);\r
-       $texte = str_replace('-->','&rarr;',$texte);\r
-\r
-       return $texte;\r
-}\r
-\r
-function typoenluminee_pre_typo($texte) {\r
-       if(!$texte) return $texte;\r
-       static $local_barre_typo_pas_de_fausses_puces = null;\r
-       static $chercher_raccourcis;\r
-       static $remplacer_raccourcis;\r
-       global $debut_italique, $fin_italique;\r
-       if (!isset($GLOBALS['barre_typo_pas_de_fork_typo']) OR $GLOBALS['barre_typo_pas_de_fork_typo'] === true)\r
-               return $texte;\r
-\r
-       if ($local_barre_typo_pas_de_fausses_puces===null){\r
-               // remplace les fausses listes a puce par de vraies ?\r
-               // (recherche en debut de lignes - suivi d'un ou plusieurs caracteres blancs, en mode multiligne)\r
-               // Mettre $GLOBALS['barre_typo_pas_de_fausses_puces'] = true; dans mes_options.php pour avoir ce comportement\r
-               if (isset($GLOBALS['barre_typo_pas_de_fausses_puces'])) {\r
-                       $local_barre_typo_pas_de_fausses_puces = $GLOBALS['barre_typo_pas_de_fausses_puces'];\r
-               } else {\r
-                       if (function_exists('lire_config')) {\r
-                               $local_barre_typo_pas_de_fausses_puces = (lire_config('bte/puces','Non') == 'Oui')?true:false;\r
-                       }\r
-               }\r
-               global $class_spip;\r
-               tester_variable('debut_italique', "<i$class_spip>");\r
-               tester_variable('fin_italique', '</i>');\r
-               \r
-               $chercher_raccourcis = array(\r
-                       /* 9 */         "/(?<![{\d])[{](?![{\d])/S", // Expressions complexes car on n'a pas encore traite les titres ici\r
-                       /* 10 */        "/(?<![}\d])[}](?![}\d])/S", // puisque italique utilisent les memes caracteres en nombre inferieur\r
-               );\r
-       \r
-               $remplacer_raccourcis = array(\r
-                       /* 9 */         $debut_italique,\r
-                       /* 10 */        $fin_italique,\r
-               );\r
-       }\r
-       if ($local_barre_typo_pas_de_fausses_puces === true) {\r
-               $texte =  preg_replace('/^-\s+/m','-* ',$texte);\r
-       }\r
-\r
-       $texte = str_replace('<--','&larr;',$texte);\r
-       $texte = str_replace('<==>','&hArr;',$texte);\r
-       $texte = str_replace('==>','&rArr;',$texte);\r
-       $texte = str_replace('<==','&lArr;',$texte);\r
-       $texte = str_ireplace('(c)','&copy;',$texte);\r
-       $texte = str_ireplace('(r)','&reg;',$texte);\r
-       $texte = str_ireplace('(tm)','&trade;',$texte);\r
-       $texte = str_replace('...','&hellip;',$texte);\r
-       $texte = preg_replace($chercher_raccourcis, $remplacer_raccourcis, $texte);\r
-       /*\r
-               Cas particulier pour le gras\r
-               Il ne faut pas traiter la mise en gras ici si le texte contient un tableau\r
-       */\r
-       if (!preg_match(',.(\|([[:space:]]*{{[^}]+}}[[:space:]]*|<))+.,sS', $texte)) {\r
-               $chercher_raccourcisg = array(\r
-                       /* 7 */         "/(?<![{])[{][{](?![{])/S", // Expressions complexes car on n'a pas encore traite les titres ici\r
-                       /* 8 */         "/(?<![}])[}][}](?![}])/S" // En gros, verification qu'on n'est pas a l'interieur d'un titre\r
-               );\r
-               $remplacer_raccourcisg = array(\r
-                       /* 7 */         "<strong class=\"spip\">",\r
-                       /* 8 */         "</strong>"\r
-               );\r
-               $texte = preg_replace($chercher_raccourcisg, $remplacer_raccourcisg, $texte);\r
-       }\r
-       return $texte;\r
-}\r
-\r
-function typoenluminee_post_typo($texte) {\r
-       if(!$texte) return $texte;\r
-       if (!isset($GLOBALS['barre_typo_pas_de_fork_typo']) OR $GLOBALS['barre_typo_pas_de_fork_typo'] === true)\r
-               return $texte;\r
-       $texte = str_replace('[^','<sup>',$texte);\r
-       $texte = str_replace('^]','</sup>',$texte);\r
-       $texte = str_replace('[**','<strong class="caractencadre2-spip spip">',$texte);\r
-       $texte = str_replace('[*','<strong class="caractencadre-spip spip">',$texte);\r
-       $texte = str_replace('*]','</strong>',$texte);\r
-       \r
-       // Correction des & en &amp;\r
-       $texte = preg_replace('/&([A-Za-z#0-9]*);/','@@@amp:\1:amp@@@',$texte); // echapement des entites html deja presentes\r
-       $texte = str_replace('&','&amp;',$texte);\r
-       $texte = preg_replace('/@@@amp:([A-Za-z#0-9]*):amp@@@/','&\1;',$texte);\r
-       // Raccourci typographique <sc></sc>\r
-       $texte = str_replace('<sc>', '<span class="caps">', $texte);\r
-       $texte = str_replace('</sc>', '</span>', $texte);\r
-       $texte = acronymes_traiter_raccourcis($texte);\r
-       return $texte;\r
-}\r
-\r
-function typoenluminee_nettoyer_raccourcis_typo($texte){\r
-       $texte = preg_replace(',\{[1-5]\{,','',$texte);\r
-       $texte = preg_replace(',\}[1-5]\},','',$texte);\r
-       $texte = preg_replace(',\{\{\{\*+,','{{{',$texte);\r
-       $texte = str_replace('&hellip;','...',$texte);\r
-       return $texte;\r
-}\r
-\r
-// traite les raccourcis de la forme [SNCF|societe nationale...]\r
-// reprise du plugin acronymes\r
-if (!function_exists('acronymes_traiter_raccourcis')) {\r
-       function acronymes_traiter_raccourcis($letexte){\r
-               $pattern="{\[([^\|\]-]+)\|([^\|\]-]+)\]}";\r
-               preg_match_all ($pattern, $letexte, $tagMatches, PREG_SET_ORDER);\r
-               $textMatches = preg_split ($pattern, $letexte);\r
-\r
-               $tag_attr=array();\r
-               foreach ($tagMatches as $key => $value) {\r
-                       $tag_attr[]="<acronym title='".texte_backend($value[2])."'>".$value[1]."</acronym>";\r
-               }\r
-               for ($i = 0; $i < count ($textMatches); $i ++) {\r
-                       $textMatches [$i] = $textMatches [$i] . $tag_attr [$i];\r
-               }\r
-               return implode ("", $textMatches);\r
-       }\r
-}\r
-\r
-\r
-?>
\ No newline at end of file
+<?php
+
+if (!defined('_ECRIRE_INC_VERSION')) {
+       return;
+}
+
+/**
+ * Ce plugin rajoute des raccourcis typographique et ameliore les possibilites de la barre typographique pour les redacteurs
+ *
+ *
+ *    Fonctions de ces filtres :
+ *     Ils rajoutent quelques racourcis typo a SPIP
+ *
+ *     Syntaxe des raccourcis :
+ *           [/texte/] : aligner le texte a droite
+ *           [!texte!] : aligner le texte a gauche
+ *           [|texte|] : centrer le texte
+ *           [(texte)] : encadrer le texte (occupe toute la largeur de la page, a mettre autour d'un paragraphe)
+ *           [*texte*] : encadrer/surligner le texte (une partie a l'interieur d'un paragraphe)
+ *           [**texte*] : variante encadrer/surligner le texte (une partie a l'interieur d'un paragraphe)
+ *           <sup>texte</sup> : mettre en exposant le texte selectionne
+ *           <sub>texte</sub> : mettre en indice le texte selectionne
+ *
+ *     Styles pour les encadrements a rajouter dans votre feuille de style :
+ *            .texteencadre-spip {
+ *             background: #FFE;
+ *             border-bottom: 2px solid #999999;
+ *             border-left: 1px solid #EEEEEE;
+ *             border-right: 2px solid #999999;
+ *             border-top: 1px solid #EEEEEE;
+ *             padding: .25em;
+ *           }
+ *           .caractencadre-spip {
+ *             border: 1px solid #666;
+ *             padding: 0px .5em 0px .5em;
+ *           }
+ */
+
+// Gerer les variables de personnalisation, fonction depreciee sous SPIP 2.0
+// A suivre sur la methode...
+if (!function_exists('tester_variable')) {
+       function tester_variable($var, $val) {
+               if (!isset($GLOBALS[$var])) {
+                       $GLOBALS[$var] = $val;
+               }
+       }
+}
+
+function typoenluminee_pre_propre($texte) {
+       if (!$texte) {
+               return $texte;
+       }
+
+       static $chercher_raccourcis = null;
+       static $remplacer_raccourcis = null;
+
+       if ($chercher_raccourcis === null) {
+               // tous les elements block doivent etre introduits ici
+               // pour etre pris en charge par paragrapher
+
+               // Definition des differents intertitres possibles, si pas deja definies
+               if ((!function_exists('lire_config')) or (isset($GLOBALS['config_intertitre']))) {
+                       tester_variable('debut_intertitre', '<h3 class="spip">');
+                       tester_variable('fin_intertitre', '</h3>');
+                       tester_variable('debut_intertitre_2', '<h4 class="spip">');
+                       tester_variable('fin_intertitre_2', '</h4>');
+                       tester_variable('debut_intertitre_3', '<h5 class="spip">');
+                       tester_variable('fin_intertitre_3', '</h5>');
+                       tester_variable('debut_intertitre_4', '<h6 class="spip">');
+                       tester_variable('fin_intertitre_4', '</h6>');
+                       tester_variable('debut_intertitre_5', '<strong class="spip titraille5">');
+                       tester_variable('fin_intertitre_5', '</strong>');
+               } else {
+                       $GLOBALS['debut_intertitre'] = lire_config('bte/titraille1open', '<h3 class="spip">');
+                       $GLOBALS['fin_intertitre'] = lire_config('bte/titraille1close', '</h3>');
+                       $GLOBALS['debut_intertitre_2'] = lire_config('bte/titraille2open', '<h4 class="spip">');
+                       $GLOBALS['fin_intertitre_2'] = lire_config('bte/titraille2close', '</h4>');
+                       $GLOBALS['debut_intertitre_3'] = lire_config('bte/titraille3open', '<h5 class="spip">');
+                       $GLOBALS['fin_intertitre_3'] = lire_config('bte/titraille3close', '</h5>');
+                       $GLOBALS['debut_intertitre_4'] = lire_config('bte/titraille4open', '<h6 class="spip">');
+                       $GLOBALS['fin_intertitre_4'] = lire_config('bte/titraille4close', '</h6>');
+                       $GLOBALS['debut_intertitre_5'] = lire_config('bte/titraille5open', '<strong class="spip titraille5">');
+                       $GLOBALS['fin_intertitre_5'] = lire_config('bte/titraille5close', '</strong>');
+               }
+
+               tester_variable('toujours_paragrapher', false);
+
+               global $debut_intertitre, $fin_intertitre;
+               global $debut_intertitre_2, $fin_intertitre_2;
+               global $debut_intertitre_3, $fin_intertitre_3;
+               global $debut_intertitre_4, $fin_intertitre_4;
+               global $debut_intertitre_5, $fin_intertitre_5;
+
+               $chercher_raccourcis=array();
+               $remplacer_raccourcis=array();
+
+               /* 9b */        $chercher_raccourcis[] = '/(^|[^{])[{][{][{]\*\*\*\*\*(.*)[}][}][}]($|[^}])/SUms';
+               /* 9 */         $chercher_raccourcis[] = '/(^|[^{])[{][{][{]\*\*\*\*(.*)[}][}][}]($|[^}])/SUms';
+               /* 7 */         $chercher_raccourcis[] = '/(^|[^{])[{][{][{]\*\*\*(.*)[}][}][}]($|[^}])/SUms';
+               /* 5 */         $chercher_raccourcis[] = '/(^|[^{])[{][{][{]\*\*(.*)[}][}][}]($|[^}])/SUms';
+               /* 3 */         $chercher_raccourcis[] = '/(^|[^{])[{][{][{]\*(.*)[}][}][}]($|[^}])/SUms';
+               /* 1 */         $chercher_raccourcis[] = '/(^|[^{])[{][{][{](.*)[}][}][}]($|[^}])/SUms';
+               /* 11 */        $chercher_raccourcis[] = '/\{(�|§)\{/S'; # § Pour gerer l'unicode aussi !
+               /* 12 */        $chercher_raccourcis[] = '/\}(�|§)\}/S'; # ne pas sauvergarder ce fichier en utf8 !
+
+               /* 9b */        $remplacer_raccourcis[] = "\$1\n\n$debut_intertitre_5\$2$fin_intertitre_5\n\n\$3";
+               /*  9 */        $remplacer_raccourcis[] = "\$1\n\n$debut_intertitre_4\$2$fin_intertitre_4\n\n\$3";
+               /*  7 */        $remplacer_raccourcis[] = "\$1\n\n$debut_intertitre_3\$2$fin_intertitre_3\n\n\$3";
+               /*  5 */        $remplacer_raccourcis[] = "\$1\n\n$debut_intertitre_2\$2$fin_intertitre_2\n\n\$3";
+               /*  3 */        $remplacer_raccourcis[] = "\$1\n\n$debut_intertitre\$2$fin_intertitre\n\n\$3";
+               /*  1 */        $remplacer_raccourcis[] = "\$1\n\n$debut_intertitre\$2$fin_intertitre\n\n\$3";
+               /* 11 */        $remplacer_raccourcis[] = '<sc>';
+               /* 12 */        $remplacer_raccourcis[] = '</sc>';
+       }
+
+       // Conversion des intertitres d'enluminures type {n{titre}n}
+       // ou n est un nombre en intertitres avec des etoiles type {{{* (avec n etoiles)
+       // {1{ sera converti en {{{* ; {2{ sera converti en {{{** ; etc.
+       // Ne faire la recherche que s'il y a au moins un titre ancienne mode a convertir
+       if (strpos($texte, '{1{') !== false
+               or strpos($texte, '{2{') !== false
+               or strpos($texte, '{3{') !== false
+               or strpos($texte, '{4{') !== false
+               or strpos($texte, '{5{') !== false) {
+                       $texte = preg_replace_callback(
+                               '/\{(\d)\{(.*)\}(\\1)\}/Ums',
+                               create_function(
+                                       '$matches',
+                                       'return "{{{".str_repeat("*",$matches[1]).trim($matches[2])."}}}";'
+                               ),
+                               $texte
+                       );
+       }
+       $texte = preg_replace($chercher_raccourcis, $remplacer_raccourcis, $texte);
+
+       return $texte;
+}
+
+/**
+ * Insertion dans le pipeline post_propre (SPIP)
+ *
+ * Remplacement de caracteres apres le passage de propre
+ *
+ * @param $texte string
+ *     Le texte a modifier
+ * @return $texte string
+ */
+function typoenluminee_post_propre($texte) {
+       if (!$texte) {
+               return $texte;
+       }
+       static $cherche1 = null;
+       static $remplace1 = null;
+       if ($cherche1=== null) {
+               # Le remplacement des intertitres de premier niveau a deja ete effectue dans inc/texte.php
+               $cherche1 = array();
+               $remplace1 = array();
+               $cherche1[] = /* 15 */  ',\[/(.*)/\],Ums';
+               $cherche1[] = /* 16 */  ',\[!(.*)!\],Ums';
+               $cherche1[] = /* 17 */  ',\[\|(.*)\|\],Ums';
+               $cherche1[] = /* 19 */  ',\[\((.*)\)\],Ums';
+               $cherche1[] = /* 21 */  '/\[\*\*/S';
+               $cherche1[] = /* 21b */ '/\[\*/S';
+               $cherche1[] = /* 22 */  '/\*\]/S';
+
+               $remplace1[] = /* 15 */         '<div class="spip" style="text-align:right;">$1</div>';
+               $remplace1[] = /* 16 */         '<div class="spip" style="text-align:left;">$1</div>';
+               $remplace1[] = /* 17 */         '<div class="spip" style="text-align:center;">$1</div>';
+               $remplace1[] = /* 19 */         '<div class="texteencadre-spip spip">$1</div>';
+               $remplace1[] = /* 21 */         '<strong class="caractencadre2-spip spip">';
+               $remplace1[] = /* 21b */        '<strong class="caractencadre-spip spip">';
+               $remplace1[] = /* 22 */ '</strong>';
+       }
+       $texte = preg_replace($cherche1, $remplace1, $texte);
+       $texte = paragrapher($texte, $GLOBALS['toujours_paragrapher']); // il faut reparagrapher a cause des raccourcis typo que l'on a ajoute (block div)
+       return $texte;
+}
+
+function typoenluminee_pre_liens($texte) {
+       if (!isset($GLOBALS['barre_typo_pas_de_fork_typo']) or $GLOBALS['barre_typo_pas_de_fork_typo'] === true) {
+               return $texte;
+       }
+
+       $texte = str_replace('<-->', '&harr;', $texte);
+       $texte = str_replace('-->', '&rarr;', $texte);
+
+       return $texte;
+}
+
+function typoenluminee_pre_typo($texte) {
+       if (!$texte) {
+               return $texte;
+       }
+       static $local_barre_typo_pas_de_fausses_puces = null;
+       static $chercher_raccourcis;
+       static $remplacer_raccourcis;
+
+       if (!isset($GLOBALS['barre_typo_pas_de_fork_typo']) or $GLOBALS['barre_typo_pas_de_fork_typo'] === true) {
+               return $texte;
+       }
+
+       if ($local_barre_typo_pas_de_fausses_puces === null) {
+               // remplace les fausses listes a puce par de vraies ?
+               // (recherche en debut de lignes - suivi d'un ou plusieurs caracteres blancs, en mode multiligne)
+               // Mettre $GLOBALS['barre_typo_pas_de_fausses_puces'] = true; dans mes_options.php pour avoir ce comportement
+               if (isset($GLOBALS['barre_typo_pas_de_fausses_puces'])) {
+                       $local_barre_typo_pas_de_fausses_puces = $GLOBALS['barre_typo_pas_de_fausses_puces'];
+               } else {
+                       if (function_exists('lire_config')) {
+                               $local_barre_typo_pas_de_fausses_puces = (lire_config('bte/puces', 'Non') == 'Oui') ? true : false;
+                       }
+               }
+       }
+
+       if ($local_barre_typo_pas_de_fausses_puces === true) {
+               $texte =  preg_replace('/^-\s+/m', '-* ', $texte);
+       }
+
+       $texte = str_replace('<--', '&larr;', $texte);
+       $texte = str_replace('<==>', '&hArr;', $texte);
+       $texte = str_replace('==>', '&rArr;', $texte);
+       $texte = str_replace('<==', '&lArr;', $texte);
+       $texte = str_ireplace('(c)', '&copy;', $texte);
+       $texte = str_ireplace('(r)', '&reg;', $texte);
+       $texte = str_ireplace('(tm)', '&trade;', $texte);
+       $texte = str_replace('...', '&hellip;', $texte);
+
+       global $debut_italique, $fin_italique,$class_spip;
+       /*
+               Cas particulier pour le gras
+               Il ne faut pas traiter la mise en gras ici si le texte contient un tableau
+       */
+       if (!preg_match(',.(\|([[:space:]]*{{[^}]+}}[[:space:]]*|<))+.,sS', $texte)) {
+               $chercher_raccourcisg = array(
+                       /* 7 */         '/(?<![{])[{][{](?![{])/S', // Expressions complexes car on n'a pas encore traite les titres ici
+                       /* 8 */         '/(?<![}])[}][}](?![}])/S' // En gros, verification qu'on n'est pas a l'interieur d'un titre
+               );
+               $remplacer_raccourcisg = array(
+                       /* 7 */         "<strong$class_spip>",
+                       /* 8 */         '</strong>'
+               );
+               $texte = preg_replace($chercher_raccourcisg, $remplacer_raccourcisg, $texte);
+       }
+
+
+       /**
+        * Remplacer les { ... } par <i> </i>
+        * On passe après les gras pour que la regexp ne matche pas {{ ... }}
+        */
+       tester_variable('debut_italique', "<i$class_spip>");
+       tester_variable('fin_italique', '</i>');
+       $chercher_raccourcis = array(
+               /* 9 */         '/(?<![{])[{](?![{])/S', // Expressions complexes car on n'a pas encore traite les titres ici
+               /* 10 */        '/(?<![}])[}](?![}])/S' // En gros, verification qu'on n'est pas a l'interieur d'un titre
+       );
+       $remplacer_raccourcis = array(
+               /* 9 */         $debut_italique,
+               /* 10 */        $fin_italique,
+       );
+       $texte = preg_replace($chercher_raccourcis, $remplacer_raccourcis, $texte);
+
+       return $texte;
+}
+
+function typoenluminee_post_typo($texte) {
+       if (!$texte) {
+               return $texte;
+       }
+       if (!isset($GLOBALS['barre_typo_pas_de_fork_typo']) or $GLOBALS['barre_typo_pas_de_fork_typo'] === true) {
+               return $texte;
+       }
+       $texte = str_replace('[^', '<sup>', $texte);
+       $texte = str_replace('^]', '</sup>', $texte);
+       $texte = str_replace('[**', '<strong class="caractencadre2-spip spip">', $texte);
+       $texte = str_replace('[*', '<strong class="caractencadre-spip spip">', $texte);
+       $texte = str_replace('*]', '</strong>', $texte);
+
+       // Correction des & en &amp;
+       $texte = preg_replace('/&([A-Za-z#0-9]*);/', '@@@amp:\1:amp@@@', $texte); // echapement des entites html deja presentes
+       $texte = str_replace('&', '&amp;', $texte);
+       $texte = preg_replace('/@@@amp:([A-Za-z#0-9]*):amp@@@/', '&\1;', $texte);
+       // Raccourci typographique <sc></sc>
+       $texte = str_replace('<sc>', '<span class="caps">', $texte);
+       $texte = str_replace('</sc>', '</span>', $texte);
+       $texte = acronymes_traiter_raccourcis($texte);
+       return $texte;
+}
+
+function typoenluminee_nettoyer_raccourcis_typo($texte) {
+       $texte = preg_replace(',\{[1-5]\{,', '', $texte);
+       $texte = preg_replace(',\}[1-5]\},', '', $texte);
+       $texte = preg_replace(',\{\{\{\*+,', '{{{', $texte);
+       $texte = str_replace('&hellip;', '...', $texte);
+       return $texte;
+}
+
+// traite les raccourcis de la forme [SNCF|societe nationale...]
+// reprise du plugin acronymes
+if (!function_exists('acronymes_traiter_raccourcis')) {
+       function acronymes_traiter_raccourcis($letexte) {
+               $pattern = '{\[([^\|\]-]+)\|([^\|\]-]+)\]}';
+               if (preg_match_all($pattern, $letexte, $tagMatches, PREG_SET_ORDER)) {
+                       $textMatches = preg_split($pattern, $letexte);
+
+                       $tag_attr=array();
+                       foreach ($tagMatches as $key => $value) {
+                               $tag_attr[] = "<acronym title='".texte_backend($value[2])."'>".$value[1].'</acronym>';
+                       }
+                       for ($i = 0; $i < count($tag_attr); $i ++) {
+                               $textMatches [$i] = $textMatches [$i] . $tag_attr [$i];
+                       }
+                       return implode('', $textMatches);
+               } else {
+                       return $letexte;
+               }
+       }
+}