diff --git a/filter/algebra/filter.php b/filter/algebra/filter.php
index 75e3578e4e4..f4dd3bd7971 100644
--- a/filter/algebra/filter.php
+++ b/filter/algebra/filter.php
@@ -136,6 +136,8 @@ function algebra_filter ($courseid, $text) {
$algebra = $matches[1][$i] . $matches[2][$i];
$algebra = str_replace('','',$algebra);
$algebra = str_replace('','',$algebra);
+ $algebra = str_replace('','',$algebra);
+ $algebra = str_replace('','',$algebra);
$align = "middle";
if (preg_match('/^align=bottom /',$algebra)) {
$align = "text-bottom";
diff --git a/filter/tex/filter.php b/filter/tex/filter.php
index 18df876cf9f..7e076aac97f 100644
--- a/filter/tex/filter.php
+++ b/filter/tex/filter.php
@@ -125,6 +125,8 @@ function tex_filter ($courseid, $text) {
$texexp = $matches[1][$i] . $matches[2][$i];
$texexp = str_replace('','',$texexp);
$texexp = str_replace('','',$texexp);
+ $texexp = str_replace('','',$texexp);
+ $texexp = str_replace('','',$texexp);
$align = "middle";
if (preg_match('/^align=bottom /',$texexp)) {
$align = "text-bottom";