X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=www%2Fplugins%2Fenluminures_typographiques_v3%2Ftypoenluminee.php;fp=www%2Fplugins%2Fenluminures_typographiques_v3%2Ftypoenluminee.php;h=68f8788d0874508aeb1b93ffebc63d47669551e0;hb=c0f18416f529232b5555c6410a8765a5125ebcd3;hp=377da47f01c03e47f36eec302555b5f021b47d93;hpb=50522c53acc9e61a4a7de3a1890c4ba93e2f61b4;p=lhc%2Fweb%2Fwww.git
diff --git a/www/plugins/enluminures_typographiques_v3/typoenluminee.php b/www/plugins/enluminures_typographiques_v3/typoenluminee.php
index 377da47f..68f8788d 100644
--- a/www/plugins/enluminures_typographiques_v3/typoenluminee.php
+++ b/www/plugins/enluminures_typographiques_v3/typoenluminee.php
@@ -1,286 +1,317 @@
-texte : mettre en exposant le texte selectionne
- * texte : 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', '
');
- tester_variable('fin_intertitre', '
');
- tester_variable('debut_intertitre_2', '');
- tester_variable('fin_intertitre_2', '
');
- tester_variable('debut_intertitre_3', '');
- tester_variable('fin_intertitre_3', '
');
- tester_variable('debut_intertitre_4', '');
- tester_variable('fin_intertitre_4', '
');
- tester_variable('debut_intertitre_5', '');
- tester_variable('fin_intertitre_5', '');
- } else {
- $GLOBALS['debut_intertitre'] = lire_config('bte/titraille1open','');
- $GLOBALS['fin_intertitre'] = lire_config('bte/titraille1close','
');
- $GLOBALS['debut_intertitre_2'] = lire_config('bte/titraille2open','');
- $GLOBALS['fin_intertitre_2'] = lire_config('bte/titraille2close','
');
- $GLOBALS['debut_intertitre_3'] = lire_config('bte/titraille3open','');
- $GLOBALS['fin_intertitre_3'] = lire_config('bte/titraille3close','
');
- $GLOBALS['debut_intertitre_4'] = lire_config('bte/titraille4open','');
- $GLOBALS['fin_intertitre_4'] = lire_config('bte/titraille4close','
');
- $GLOBALS['debut_intertitre_5'] = lire_config('bte/titraille5open','');
- $GLOBALS['fin_intertitre_5'] = lire_config('bte/titraille5close','');
- }
-
- 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[]="";
- /* 12 */ $remplacer_raccourcis[]="";
- }
-
- // 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;
-}
-
-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 */ "$1
";
- $remplace1[] = /* 16 */ "$1
";
- $remplace1[] = /* 17 */ "$1
";
- $remplace1[] = /* 19 */ "$1
";
- $remplace1[] = /* 21 */ "";
- $remplace1[] = /* 21b */ "";
- $remplace1[] = /* 22 */ "";
- }
- $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('<-->','↔',$texte);
- $texte = str_replace('-->','→',$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;
- global $debut_italique, $fin_italique;
- 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;
- }
- }
- global $class_spip;
- tester_variable('debut_italique', "");
- tester_variable('fin_italique', '');
-
- $chercher_raccourcis = array(
- /* 9 */ "/(?','⇔',$texte);
- $texte = str_replace('==>','⇒',$texte);
- $texte = str_replace('<==','⇐',$texte);
- $texte = str_ireplace('(c)','©',$texte);
- $texte = str_ireplace('(r)','®',$texte);
- $texte = str_ireplace('(tm)','™',$texte);
- $texte = str_replace('...','…',$texte);
- $texte = preg_replace($chercher_raccourcis, $remplacer_raccourcis, $texte);
- /*
- 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 */ "/(?",
- /* 8 */ ""
- );
- $texte = preg_replace($chercher_raccourcisg, $remplacer_raccourcisg, $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('[^','',$texte);
- $texte = str_replace('^]','',$texte);
- $texte = str_replace('[**','',$texte);
- $texte = str_replace('[*','',$texte);
- $texte = str_replace('*]','',$texte);
-
- // Correction des & en &
- $texte = preg_replace('/&([A-Za-z#0-9]*);/','@@@amp:\1:amp@@@',$texte); // echapement des entites html deja presentes
- $texte = str_replace('&','&',$texte);
- $texte = preg_replace('/@@@amp:([A-Za-z#0-9]*):amp@@@/','&\1;',$texte);
- // Raccourci typographique
- $texte = str_replace('', '', $texte);
- $texte = str_replace('', '', $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('…','...',$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="{\[([^\|\]-]+)\|([^\|\]-]+)\]}";
- preg_match_all ($pattern, $letexte, $tagMatches, PREG_SET_ORDER);
- $textMatches = preg_split ($pattern, $letexte);
-
- $tag_attr=array();
- foreach ($tagMatches as $key => $value) {
- $tag_attr[]="".$value[1]."";
- }
- for ($i = 0; $i < count ($textMatches); $i ++) {
- $textMatches [$i] = $textMatches [$i] . $tag_attr [$i];
- }
- return implode ("", $textMatches);
- }
-}
-
-
-?>
\ No newline at end of file
+texte : mettre en exposant le texte selectionne
+ * texte : 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', '');
+ tester_variable('fin_intertitre', '
');
+ tester_variable('debut_intertitre_2', '');
+ tester_variable('fin_intertitre_2', '
');
+ tester_variable('debut_intertitre_3', '');
+ tester_variable('fin_intertitre_3', '
');
+ tester_variable('debut_intertitre_4', '');
+ tester_variable('fin_intertitre_4', '
');
+ tester_variable('debut_intertitre_5', '');
+ tester_variable('fin_intertitre_5', '');
+ } else {
+ $GLOBALS['debut_intertitre'] = lire_config('bte/titraille1open', '');
+ $GLOBALS['fin_intertitre'] = lire_config('bte/titraille1close', '
');
+ $GLOBALS['debut_intertitre_2'] = lire_config('bte/titraille2open', '');
+ $GLOBALS['fin_intertitre_2'] = lire_config('bte/titraille2close', '
');
+ $GLOBALS['debut_intertitre_3'] = lire_config('bte/titraille3open', '');
+ $GLOBALS['fin_intertitre_3'] = lire_config('bte/titraille3close', '
');
+ $GLOBALS['debut_intertitre_4'] = lire_config('bte/titraille4open', '');
+ $GLOBALS['fin_intertitre_4'] = lire_config('bte/titraille4close', '
');
+ $GLOBALS['debut_intertitre_5'] = lire_config('bte/titraille5open', '');
+ $GLOBALS['fin_intertitre_5'] = lire_config('bte/titraille5close', '');
+ }
+
+ 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[] = '';
+ /* 12 */ $remplacer_raccourcis[] = '';
+ }
+
+ // 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 */ '$1
';
+ $remplace1[] = /* 16 */ '$1
';
+ $remplace1[] = /* 17 */ '$1
';
+ $remplace1[] = /* 19 */ '$1
';
+ $remplace1[] = /* 21 */ '';
+ $remplace1[] = /* 21b */ '';
+ $remplace1[] = /* 22 */ '';
+ }
+ $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('<-->', '↔', $texte);
+ $texte = str_replace('-->', '→', $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('<--', '←', $texte);
+ $texte = str_replace('<==>', '⇔', $texte);
+ $texte = str_replace('==>', '⇒', $texte);
+ $texte = str_replace('<==', '⇐', $texte);
+ $texte = str_ireplace('(c)', '©', $texte);
+ $texte = str_ireplace('(r)', '®', $texte);
+ $texte = str_ireplace('(tm)', '™', $texte);
+ $texte = str_replace('...', '…', $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 */ '/(?",
+ /* 8 */ ''
+ );
+ $texte = preg_replace($chercher_raccourcisg, $remplacer_raccourcisg, $texte);
+ }
+
+
+ /**
+ * Remplacer les { ... } par
+ * On passe après les gras pour que la regexp ne matche pas {{ ... }}
+ */
+ tester_variable('debut_italique', "");
+ tester_variable('fin_italique', '');
+ $chercher_raccourcis = array(
+ /* 9 */ '/(?', $texte);
+ $texte = str_replace('^]', '', $texte);
+ $texte = str_replace('[**', '', $texte);
+ $texte = str_replace('[*', '', $texte);
+ $texte = str_replace('*]', '', $texte);
+
+ // Correction des & en &
+ $texte = preg_replace('/&([A-Za-z#0-9]*);/', '@@@amp:\1:amp@@@', $texte); // echapement des entites html deja presentes
+ $texte = str_replace('&', '&', $texte);
+ $texte = preg_replace('/@@@amp:([A-Za-z#0-9]*):amp@@@/', '&\1;', $texte);
+ // Raccourci typographique
+ $texte = str_replace('', '', $texte);
+ $texte = str_replace('', '', $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('…', '...', $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[] = "".$value[1].'';
+ }
+ for ($i = 0; $i < count($tag_attr); $i ++) {
+ $textMatches [$i] = $textMatches [$i] . $tag_attr [$i];
+ }
+ return implode('', $textMatches);
+ } else {
+ return $letexte;
+ }
+ }
+}