diff --git a/.upgradenotes/MDL-85233-2025122207154958.yml b/.upgradenotes/MDL-85233-2025122207154958.yml
new file mode 100644
index 00000000000..92cfd1f14da
--- /dev/null
+++ b/.upgradenotes/MDL-85233-2025122207154958.yml
@@ -0,0 +1,9 @@
+issueNumber: MDL-85233
+notes:
+ core_filters:
+ - message: >-
+ MimeTeX support has been removed from both `filter_tex` and
+ `filter_algebra`. These filters now depend on LaTeX tools (`latex`,
+ `dvips`, and `convert`/`dvisvgm`), and as a result, the `pathmimetex`
+ setting has been removed.
+ type: removed
diff --git a/public/filter/algebra/algebradebug.php b/public/filter/algebra/algebradebug.php
index 047bf873ce8..690ff9c3066 100644
--- a/public/filter/algebra/algebradebug.php
+++ b/public/filter/algebra/algebradebug.php
@@ -1,7 +1,7 @@
libdir.'/filelib.php');
require_once($CFG->dirroot.'/filter/tex/lib.php');
+ require_once($CFG->dirroot . '/filter/algebra/lib.php');
+ require_once($CFG->dirroot . '/filter/tex/latex.php');
$action = optional_param('action', '', PARAM_ALPHANUM);
$algebra = optional_param('algebra', '', PARAM_RAW);
@@ -203,9 +205,8 @@ function tex2image($texexp, $md5, $return=false) {
return;
}
- $texexp = '\Large ' . $texexp;
- $image = $md5 . ".gif";
- $filetype = 'image/gif';
+ $convertformat = get_config('filter_algebra', 'convertformat');
+ $image = $md5 . ".{$convertformat}";
if (!file_exists("$CFG->dataroot/filter/algebra")) {
make_upload_directory("filter/algebra");
}
@@ -213,42 +214,22 @@ function tex2image($texexp, $md5, $return=false) {
if (file_exists($pathname)) {
unlink($pathname);
}
- $commandpath = filter_tex_get_executable(true);
- $cmd = filter_tex_get_cmd($pathname, $texexp);
- system($cmd, $status);
+
+ // Render with LaTeX.
+ $latex = new latex('filter_algebra');
+ $density = get_config('filter_algebra', 'density');
+ $background = get_config('filter_algebra', 'latexbackground');
+ $lateximage = $latex->render($texexp, $image, 12, $density, $background);
if ($return) {
return $image;
}
- if (file_exists($pathname)) {
+ if ($lateximage) {
+ copy($lateximage, $pathname);
send_file($pathname, $image);
-
} else {
- $ecmd = "$cmd 2>&1";
- echo `$ecmd` . "
\n";
- echo "The shell command
$cmd
returned status = $status
\n";
- if ($status == 4) {
- echo "Status corresponds to illegal instruction
\n";
- } else if ($status == 11) {
- echo "Status corresponds to bus error
\n";
- } else if ($status == 22) {
- echo "Status corresponds to abnormal termination
\n";
- }
- if (file_exists($commandpath)) {
- echo "File size of mimetex executable $commandpath is " . filesize($commandpath) . "
";
- echo "The file permissions are: " . decoct(fileperms($commandpath)) . "
";
- if (function_exists("md5_file")) {
- echo "The md5 checksum of the file is " . md5_file($commandpath) . "
";
- } else {
- $handle = fopen($commandpath,"rb");
- $contents = fread($handle,16384);
- fclose($handle);
- echo "The md5 checksum of the first 16384 bytes is " . md5($contents) . "
";
- }
- } else {
- echo "mimetex executable $commandpath not found!
";
- }
- echo "Image not found!";
+ echo "Image not found!
";
+ echo "Please check that LaTeX tools are properly configured in the filter settings.";
}
}
@@ -314,7 +295,7 @@ looks for the TeX translation in the Moodle database in the table cache_filters
in the field rawtext. If not found, it passes the algebraic expression to the
Perl script algebra2tex.pl, which also uses the Perl library AlgParser.pm.
It then saves the TeX translation in the database for subsequent uses and
-passes the TeX to the mimetex executable to be converted to a gif image.
+passes the TeX to the LaTeX renderer to be converted to a png/gif/svg image.
Here are a few common things that can go wrong and some suggestions on how
you might try to fix them.