Bonjour
Comme l’information a pu se noyer dans un long fil de discussion, j’ouvre un sujet uniquement dédié à ce point.
Pour les réactions annexes, vous pouvez toujours continuer sur le fil initial : Migration du service git
Le service principal, qui justifiait une infrastructure en propre de mon coté, va être stoppé dans les prochains jours. Cela va avoir pour effet de bord de stopper certains autres services secondaires. Cela concerne https://math.spip.org / https://latex.spip.net
Le futur à proprement parler de ce service est déjà discuté sur #4653 - <math> : remplacer le webservice en image fixe par MathJax en local ? - spip - SPIP on GIT
Toutefois il n’y a pas encore de visibilité sur les dates annoncées, il est donc probable qu’une phase de transition soit à proposer maintenant.
Je vous laisse voir comment la transition sera assurée. Cela ne devrait pas être trop compliqué à gérer au quotidien.
Je reste à disposition si besoin.
Le code du service est ici :
<?php
//
// Serveur d'images TeX developpe pour SPIP par
// Philippe Riviere <fil@rezo.net>
// Benjamin Sonntag <benjamin@sonntag.fr>
// Camille Lafitte <cam.lafit@azerttyu.net>
// Distribue sous licence GNU/GPL
// © 2004 - v0.2
// [->ChangeLog] : ajout d'une box
// 2018 - v1.0.1
// On préfère le paquet mimetex et gm (imagick convert)
// 2019 - v1.0.2
// Support de php7 preg_match remplace ereg
// Pour v0.2
// Nécessite l'installation de TeX, [->ImageMagick] , et du script
// qui fait la colle entre les deux : tex2im, lui-même étant
// disponible a http://www.nought.de/tex2im.php sous GNU/GPL
// Cache du serveur
$cache_dir = "CACHE/spiTeX";
if (!is_dir($cache_dir))
mkdir ($cache_dir);
$content_type="Content-Type: image/png";
// Supprimer les codes dangereux pour [->551] ;
// extrait de http://www.mayer.dial.pipex.com/tex.htm
function math_ignore_dangerous($texte) {
$danger = "include|def|command|loop|repeat|open|toks|".
"output|input|catcode|name|\^\^|every|errhelp|".
"errorstopmode|scrollmode|nonstopmode|batchmode|read|".
"write|csname|newhelp|uppercase|lowercase|relax|".
"aftergroup|afterassignment|expandafter|noexpand|".
"special";
if (preg_match("($danger)",$texte,$regs))
return "\\textrm{\color{red}Don't ``$regs[1]'' me.}";
return $texte;
}
function math_enhance($tex) {
// Correction pour forcer la ligne de base
/*
$tex = "\\setbox1=\\hbox{\$\\displaystyle ".$tex."\$}\n"
."\\newdimen\\haut\n\\newdimen\prof\n"
."\\haut=\\ht1\n\\prof=\\dp1\n"
."\\ifdim\\haut>\\prof\\prof=\\haut\\else\\haut=\\prof\\fi\n"
."\\advance\haut by .5em\n"
."\\color{white}\\vrule height \\haut depth \\prof width 0.1pt\\color{black}\\box1";
*/
return $tex;
}
function math_($texte) {
// Options de tex2im
// -z = fond transparent ; -r = resolution
$options = "-r 300x300 -z -f png";
$texte = urldecode(trim($texte));
$cmd_output=null;
$cmd_result=0;
global $cache_dir;
global $content_type;
$fichier = "$cache_dir/".md5($texte).'.png';
if (!file_exists($fichier) OR (filemtime($fichier)<filemtime("index.php"))) {
$texte = math_ignore_dangerous($texte);
$texte = escapeshellarg(math_enhance($texte));
//$cmd = "/usr/local/bin/tex2im $options -o $fichier $texte";
$cmd = "mimetex -e '$fichier' $texte ; convert $fichier $fichier";
exec($cmd,$cmd_output,$cmd_result);
if (!empty($cmd_result)) {
$content_type = null;
$fichier = $cmd_output;
}
}
return $fichier;
}
// Retourner l'image demandee
$content_to_display=urldecode($_SERVER['QUERY_STRING']);
if (empty($content_to_display)) {
$content_to_display="I Love SPIP !!!";
}
$content = math_($content_to_display);
if (!empty($content_type)) {
header($content_type);
readfile($content);
} else {
echo "Unexpected Error";
var_dump($content);
}