Skip to content
Extraits de code Groupes Projets
Valider 3537f8bc rédigé par Fil's avatar Fil
Parcourir les fichiers

raccourci <math>...</math> en client-serveur + semi-cadratin --

parent cee52713
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -587,6 +587,7 @@ function post_autobr($texte, $delim="\n_ ") { ...@@ -587,6 +587,7 @@ function post_autobr($texte, $delim="\n_ ") {
return $texte; return $texte;
} }
// //
// Gestion des blocs multilingues // Gestion des blocs multilingues
// //
...@@ -668,4 +669,38 @@ function ajoute_popup_multi($langue_demandee, $trads, $texte) { ...@@ -668,4 +669,38 @@ function ajoute_popup_multi($langue_demandee, $trads, $texte) {
return $texte; return $texte;
} }
//
// Gestion du raccourci <math>...</math> en client-serveur
//
function image_math($tex) {
// Regarder dans le repertoire local des images TeX
$dir = ($GLOBALS['flag_ecrire'] ? '../' : '').'IMG/TeX';
if (!@is_dir($dir))
@mkdir ($dir);
$fichier = "$dir/".md5(trim($tex)).'.png';
if (!@file_exists($fichier)) {
// Aller chercher l'image sur le serveur
if ($server = $GLOBALS['spip_server']['math']) {
spip_log($url = $server.'?'.urlencode($tex));
include_ecrire('inc_sites.php3');
if ($image = recuperer_page($url)) {
if ($f = @fopen($fichier, 'w')) {
@fwrite($f, $image);
@fclose($f);
}
}
}
}
// Composer la reponse selon presence ou non de l'image
$tex = entites_html($tex);
if (@file_exists($fichier)) {
list(,,,$size) = @getimagesize($fichier);
$alt = "alt=\"$tex\" title=\"$tex\"";
return "<img src=\"$fichier\" align=\"middle\" $size $alt />";
} else
return "<tt><span class='spip_code' dir='ltr'>$tex</span></tt>";
}
?> ?>
...@@ -135,14 +135,16 @@ function echappe_html($letexte, $source, $no_transform=false) { ...@@ -135,14 +135,16 @@ function echappe_html($letexte, $source, $no_transform=false) {
$regexp_echap_code = "<code>((.*?))<\/code>"; $regexp_echap_code = "<code>((.*?))<\/code>";
$regexp_echap_cadre = "<(cadre|frame)>((.*?))<\/(cadre|frame)>"; $regexp_echap_cadre = "<(cadre|frame)>((.*?))<\/(cadre|frame)>";
$regexp_echap_poesie = "<(poesie|poetry)>((.*?))<\/(poesie|poetry)>"; $regexp_echap_poesie = "<(poesie|poetry)>((.*?))<\/(poesie|poetry)>";
$regexp_echap = "/($regexp_echap_html)|($regexp_echap_code)|($regexp_echap_cadre)|($regexp_echap_poesie)/si"; $regexp_echap_math = "<math>((.*?))<\/math>";
$regexp_echap = "/($regexp_echap_html)|($regexp_echap_code)|($regexp_echap_cadre)|($regexp_echap_poesie)|($regexp_echap_math)/si";
} else { } else {
//echo creer_echappe_sans_pcre("cadre"); //echo creer_echappe_sans_pcre("cadre");
$regexp_echap_html = "<html>(([^<]|<[^/]|</[^h]|</h[^t]|</ht[^m]|</htm[^l]|<\/html[^>])*)<\/html>"; $regexp_echap_html = "<html>(([^<]|<[^/]|</[^h]|</h[^t]|</ht[^m]|</htm[^l]|<\/html[^>])*)<\/html>";
$regexp_echap_code = "<code>(([^<]|<[^/]|</[^c]|</c[^o]|</co[^d]|</cod[^e]|<\/code[^>])*)<\/code>"; $regexp_echap_code = "<code>(([^<]|<[^/]|</[^c]|</c[^o]|</co[^d]|</cod[^e]|<\/code[^>])*)<\/code>";
$regexp_echap_cadre = "(<[cf][ar][da][rm]e>(([^<]|<[^/]|</[^cf]|</[cf][^ar]|</[cf][ar][^da]|</[cf][ar][da][^rm]|</[cf][ar][da][rm][^e]|<\/[cf][ar][da][rm]e[^>])*)<\/[cf][ar][da][rm]e>)()"; // parentheses finales pour obtenir meme nombre de regs que pcre $regexp_echap_cadre = "(<[cf][ar][da][rm]e>(([^<]|<[^/]|</[^cf]|</[cf][^ar]|</[cf][ar][^da]|</[cf][ar][da][^rm]|</[cf][ar][da][rm][^e]|<\/[cf][ar][da][rm]e[^>])*)<\/[cf][ar][da][rm]e>)()"; // parentheses finales pour obtenir meme nombre de regs que pcre
$regexp_echap_poesie = "(<poe[st][ir][ey]>(([^<]|<[^/]|</[^p]|</p[^o]|</po[^e]|</poe[^st]|</poe[st][^ir]|</poe[st][ir][^[ey]]|<\/poe[st][ir][ey][^>])*)<\/poe[st][ir][ey]>)()"; $regexp_echap_poesie = "(<poe[st][ir][ey]>(([^<]|<[^/]|</[^p]|</p[^o]|</po[^e]|</poe[^st]|</poe[st][^ir]|</poe[st][ir][^[ey]]|<\/poe[st][ir][ey][^>])*)<\/poe[st][ir][ey]>)()";
$regexp_echap = "($regexp_echap_html)|($regexp_echap_code)|($regexp_echap_cadre)|($regexp_echap_poesie)"; $regexp_echap_math = "<math>(([^<]|<[^/]|</[^m]|</m[^a]|</ma[^t]|</mat[^h]|<\/math[^>])*)<\/math>";
$regexp_echap = "($regexp_echap_html)|($regexp_echap_code)|($regexp_echap_cadre)|($regexp_echap_poesie)|($regexp_echap_math)";
} }
while (($flag_pcre && preg_match($regexp_echap, $letexte, $regs)) while (($flag_pcre && preg_match($regexp_echap, $letexte, $regs))
...@@ -191,6 +193,10 @@ function echappe_html($letexte, $source, $no_transform=false) { ...@@ -191,6 +193,10 @@ function echappe_html($letexte, $source, $no_transform=false) {
$lecode = "<div class=\"spip_poesie\"><div>".ereg_replace("\n+", "</div>\n<div>", $lecode)."</div></div>"; $lecode = "<div class=\"spip_poesie\"><div>".ereg_replace("\n+", "</div>\n<div>", $lecode)."</div></div>";
$les_echap[$num_echap] = "</p>".propre($lecode)."<p class=\"spip\">"; $les_echap[$num_echap] = "</p>".propre($lecode)."<p class=\"spip\">";
} else
if ($regs[17]) {
$lecode = $regs[19];
$les_echap[$num_echap] = image_math($lecode);
} }
$pos = strpos($letexte, $regs[0]); $pos = strpos($letexte, $regs[0]);
...@@ -386,7 +392,7 @@ function typo_fr($letexte) { ...@@ -386,7 +392,7 @@ function typo_fr($letexte) {
$cherche1 = array( $cherche1 = array(
/* 1 '/{([^}]+)}/', */ /* 1 '/{([^}]+)}/', */
/* 2 */ '/((^|[^\#0-9a-zA-Z\&])[\#0-9a-zA-Z]*)\;/', /* 2 */ '/((^|[^\#0-9a-zA-Z\&])[\#0-9a-zA-Z]*)\;/',
/* 3 */ '/&#187;| -,|:([^0-9]|$)/', /* 3 */ '/&#187;| --?,|:([^0-9]|$)/',
/* 4 */ '/([^<!?])([!?])/', /* 4 */ '/([^<!?])([!?])/',
/* 5 */ '/&#171;|(M(M?\.|mes?|r\.?)|[MnN]&#176;) /' /* 5 */ '/&#171;|(M(M?\.|mes?|r\.?)|[MnN]&#176;) /'
); );
...@@ -401,10 +407,12 @@ function typo_fr($letexte) { ...@@ -401,10 +407,12 @@ function typo_fr($letexte) {
$letexte = ereg_replace(" *~+ *", "~", $letexte); $letexte = ereg_replace(" *~+ *", "~", $letexte);
$cherche2 = array( $cherche2 = array(
'/--/',
'/(http|https|ftp|mailto)~:/', '/(http|https|ftp|mailto)~:/',
'/~/' '/~/'
); );
$remplace2 = array( $remplace2 = array(
'&mdash;',
'\1:', '\1:',
'&nbsp;' '&nbsp;'
); );
...@@ -413,20 +421,32 @@ function typo_fr($letexte) { ...@@ -413,20 +421,32 @@ function typo_fr($letexte) {
return $letexte; return $letexte;
} }
// rien sauf les ~ {} // rien sauf les "~" et "-,"
function typo_en($letexte) { function typo_en($letexte) {
$cherche1 = array( $cherche1 = array(
/* 1 */ '/{([^}]+)}/' '/ --?,/'
); );
$remplace1 = array( $remplace1 = array(
/* 1 */ '<i class="spip">\1</i>' '~\0'
); );
// $letexte = ereg_remplace($cherche1, $remplace1, $letexte); $letexte = ereg_remplace($cherche1, $remplace1, $letexte);
$letexte = str_replace("&nbsp;", "~", $letexte); $letexte = str_replace("&nbsp;", "~", $letexte);
$letexte = ereg_replace(" *~+ *", "~", $letexte);
$cherche2 = array(
'/--/',
'/~/'
);
$remplace2 = array(
'&mdash;',
'&nbsp;'
);
return ereg_replace(" *~+ *", "&nbsp;", $letexte); $letexte = ereg_remplace($cherche2, $remplace2, $letexte);
return $letexte;
} }
// Typographie generale : francaise si la langue est 'cpf', 'fr' ou 'eo', // Typographie generale : francaise si la langue est 'cpf', 'fr' ou 'eo',
......
...@@ -150,6 +150,12 @@ $champs_extra_proposes = false; ...@@ -150,6 +150,12 @@ $champs_extra_proposes = false;
$ignore_auth_http = false; $ignore_auth_http = false;
$ignore_remote_user = false; $ignore_remote_user = false;
// serveurs externes
$spip_server = array (
'math' => 'http://math.spip.org/tex.php',
'ortho' => 'http://ortho.spip.net/ortho_serveur.php'
);
// //
// *** Fin du parametrage *** // *** Fin du parametrage ***
// //
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter