Repository: sympy/sympy (Python)

Issue:
print_mathml uses the deprecated table <mfenced>
`<mfenced>` is deprecated and non-standard(according to https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mfenced).
1.`<mfenced close="}" open="{">` has no affect on Edge.But `print_mathml()` generates `<mfenced close="}" open="{">`.It should be taken place by `<mo>`.
2.When turn x*sqrt(y) into mathml, x is between `<mfenced><mrow>` and `</mrow></mfenced>`, but `<mfenced>` doesn't seem to have any meaning, that is, there won't be difference if you delete `<mfenced></mfenced>`.So `<mfenced>` in this situation should be cut out.
3.In other cases, `<mfenced>` s are also not supposed to be used because it's deprecated and non-standard.
All in all, `<mfenced>` shouldn't be use at all.


Discussion:
I'm too lazy to check all code, but found out that `<mfenced>` is mainly used for brackets, such as:
https://github.com/sympy/sympy/blob/94fc2abcc5bce59c19476f5a404f8c773d3510b9/sympy/printing/mathml.py#L663-L670
https://github.com/sympy/sympy/blob/94fc2abcc5bce59c19476f5a404f8c773d3510b9/sympy/printing/mathml.py#L739-L755
https://github.com/sympy/sympy/blob/94fc2abcc5bce59c19476f5a404f8c773d3510b9/sympy/printing/mathml.py#L1104-L1110
and so on...I'm too lazy to going on.
But something interesting is to use <mfenced> for functions:
https://github.com/sympy/sympy/blob/94fc2abcc5bce59c19476f5a404f8c773d3510b9/sympy/printing/mathml.py#L1160-L1172
It saved a lot of things : )
But there're also something I can't understand, for example:
https://github.com/sympy/sympy/blob/94fc2abcc5bce59c19476f5a404f8c773d3510b9/sympy/printing/mathml.py#L925-L952
I wonder why sum needs `<mfenced>`(Forgive me for not understanding `<mfenced>` well)
In total, there're 33 `<mfenced>`s in mathml.py,either for brackets or for...I don't know.
And I understand a bit about the use of `<mfenced>`.I found that most `_print_*` functions return a html element:
```
brac = self.dom.createElement('mfenced')
...
return brac
```
Is that means we can't return a `<mo>(</mo><mi>x</mi><mo>)</mo>` , but only a single element?
Oh,There's one mistake in my first comment.

> 2.When turn x*sqrt(y) into mathml, x is between <mfenced><mrow> and </mrow></mfenced>, but <mfenced> doesn't seem to have any meaning, that is, there won't be difference if you delete <mfenced></mfenced>.So <mfenced> in this situation should be cut out.

There isn't a problem.Instead, it was (x+y)*sqrt(x),so there's certainly a `<mfenced>`.
But it's sure that `<mfenced>` shouldn't be used.
I think that we may need some changes, but it can be nontrivial because `mfenced` is used a lot.
The deprecation was quite modern, and sympy had not been active for updating the mathml printer.



Patch:
diff --git a/sympy/printing/mathml.py b/sympy/printing/mathml.py
index db02cf52bcfa..d3251d2b1463 100644
--- a/sympy/printing/mathml.py
+++ b/sympy/printing/mathml.py
@@ -621,14 +621,70 @@ def mul_symbol_selection():
         n = e.__class__.__name__
         return n.lower()
 
+    def _l_paren(self):
+        mo = self.dom.createElement('mo')
+        mo.appendChild(self.dom.createTextNode('('))
+        return mo
+
+    def _r_paren(self):
+        mo = self.dom.createElement('mo')
+        mo.appendChild(self.dom.createTextNode(')'))
+        return mo
+
+    def _l_brace(self):
+        mo = self.dom.createElement('mo')
+        mo.appendChild(self.dom.createTextNode('{'))
+        return mo
+
+    def _r_brace(self):
+        mo = self.dom.createElement('mo')
+        mo.appendChild(self.dom.createTextNode('}'))
+        return mo
+
+    def _comma(self):
+        mo = self.dom.createElement('mo')
+        mo.appendChild(self.dom.createTextNode(','))
+        return mo
+
+    def _bar(self):
+        mo = self.dom.createElement('mo')
+        mo.appendChild(self.dom.createTextNode('|'))
+        return mo
+
+    def _semicolon(self):
+        mo = self.dom.createElement('mo')
+        mo.appendChild(self.dom.createTextNode(';'))
+        return mo
+
+    def _paren_comma_separated(self, *args):
+        mrow = self.dom.createElement('mrow')
+        mrow.appendChild(self._l_paren())
+        for i, arg in enumerate(args):
+            if i:
+                mrow.appendChild(self._comma())
+            mrow.appendChild(self._print(arg))
+        mrow.appendChild(self._r_paren())
+        return mrow
+
+    def _paren_bar_separated(self, *args):
+        mrow = self.dom.createElement('mrow')
+        mrow.appendChild(self._l_paren())
+        for i, arg in enumerate(args):
+            if i:
+                mrow.appendChild(self._bar())
+            mrow.appendChild(self._print(arg))
+        mrow.appendChild(self._r_paren())
+        return mrow
+
     def parenthesize(self, item, level, strict=False):
         prec_val = precedence_traditional(item)
         if (prec_val < level) or ((not strict) and prec_val <= level):
-            brac = self.dom.createElement('mfenced')
-            brac.appendChild(self._print(item))
-            return brac
-        else:
-            return self._print(item)
+            mrow = self.dom.createElement('mrow')
+            mrow.appendChild(self._l_paren())
+            mrow.appendChild(self._print(item))
+            mrow.appendChild(self._r_paren())
+            return mrow
+        return self._print(item)
 
     def _print_Mul(self, expr):
 
@@ -706,14 +762,22 @@ def _print_MatrixBase(self, m):
                 y.appendChild(self._print(m[i, j]))
                 x.appendChild(y)
             table.appendChild(x)
-        if self._settings["mat_delim"] == '':
+        mat_delim = self._settings["mat_delim"]
+        if mat_delim == '':
             return table
-        brac = self.dom.createElement('mfenced')
-        if self._settings["mat_delim"] == "[":
-            brac.setAttribute('close', ']')
-            brac.setAttribute('open', '[')
-        brac.appendChild(table)
-        return brac
+        left = self.dom.createElement('mo')
+        right = self.dom.createElement('mo')
+        if mat_delim == "[":
+            left.appendChild(self.dom.createTextNode("["))
+            right.appendChild(self.dom.createTextNode("]"))
+        else:
+            left.appendChild(self.dom.createTextNode("("))
+            right.appendChild(self.dom.createTextNode(")"))
+        mrow = self.dom.createElement('mrow')
+        mrow.appendChild(left)
+        mrow.appendChild(table)
+        mrow.appendChild(right)
+        return mrow
 
     def _get_printed_Rational(self, e, folded=None):
         if e.p < 0:
@@ -905,13 +969,7 @@ def _print_Sum(self, e):
 
         mrow = self.dom.createElement('mrow')
         mrow.appendChild(subsup)
-        if len(str(e.function)) == 1:
-            mrow.appendChild(self._print(e.function))
-        else:
-            fence = self.dom.createElement('mfenced')
-            fence.appendChild(self._print(e.function))
-            mrow.appendChild(fence)
-
+        mrow.appendChild(self.parenthesize(e.function, precedence_traditional(e)))
         return mrow
 
     def _print_Symbol(self, sym, style='plain'):
@@ -995,12 +1053,14 @@ def _print_factorial2(self, expr):
         return self._print_operator_after('!!', expr.args[0])
 
     def _print_binomial(self, expr):
-        brac = self.dom.createElement('mfenced')
         frac = self.dom.createElement('mfrac')
         frac.setAttribute('linethickness', '0')
         frac.appendChild(self._print(expr.args[0]))
         frac.appendChild(self._print(expr.args[1]))
+        brac = self.dom.createElement('mrow')
+        brac.appendChild(self._l_paren())
         brac.appendChild(frac)
+        brac.appendChild(self._r_paren())
         return brac
 
     def _print_Pow(self, e):
@@ -1063,11 +1123,16 @@ def _print_Number(self, e):
         return x
 
     def _print_AccumulationBounds(self, i):
-        brac = self.dom.createElement('mfenced')
-        brac.setAttribute('close', '\u27e9')
-        brac.setAttribute('open', '\u27e8')
+        left = self.dom.createElement('mo')
+        left.appendChild(self.dom.createTextNode('\u27e8'))
+        right = self.dom.createElement('mo')
+        right.appendChild(self.dom.createTextNode('\u27e9'))
+        brac = self.dom.createElement('mrow')
+        brac.appendChild(left)
         brac.appendChild(self._print(i.min))
+        brac.appendChild(self._comma())
         brac.appendChild(self._print(i.max))
+        brac.appendChild(right)
         return brac
 
     def _print_Derivative(self, e):
@@ -1119,17 +1184,14 @@ def _print_Derivative(self, e):
         return mrow
 
     def _print_Function(self, e):
-        mrow = self.dom.createElement('mrow')
         x = self.dom.createElement('mi')
         if self.mathml_tag(e) == 'log' and self._settings["ln_notation"]:
             x.appendChild(self.dom.createTextNode('ln'))
         else:
             x.appendChild(self.dom.createTextNode(self.mathml_tag(e)))
-        y = self.dom.createElement('mfenced')
-        for arg in e.args:
-            y.appendChild(self._print(arg))
+        mrow = self.dom.createElement('mrow')
         mrow.appendChild(x)
-        mrow.appendChild(y)
+        mrow.appendChild(self._paren_comma_separated(*e.args))
         return mrow
 
     def _print_Float(self, expr):
@@ -1180,8 +1242,10 @@ def _print_polylog(self, expr):
         m.appendChild(mi)
         m.appendChild(self._print(expr.args[0]))
         mrow.appendChild(m)
-        brac = self.dom.createElement('mfenced')
+        brac = self.dom.createElement('mrow')
+        brac.appendChild(self._l_paren())
         brac.appendChild(self._print(expr.args[1]))
+        brac.appendChild(self._r_paren())
         mrow.appendChild(brac)
         return mrow
 
@@ -1190,71 +1254,57 @@ def _print_Basic(self, e):
         mi = self.dom.createElement('mi')
         mi.appendChild(self.dom.createTextNode(self.mathml_tag(e)))
         mrow.appendChild(mi)
-        brac = self.dom.createElement('mfenced')
-        for arg in e.args:
-            brac.appendChild(self._print(arg))
-        mrow.appendChild(brac)
+        mrow.appendChild(self._paren_comma_separated(*e.args))
         return mrow
 
     def _print_Tuple(self, e):
-        mrow = self.dom.createElement('mrow')
-        x = self.dom.createElement('mfenced')
-        for arg in e.args:
-            x.appendChild(self._print(arg))
-        mrow.appendChild(x)
-        return mrow
+        return self._paren_comma_separated(*e.args)
 
     def _print_Interval(self, i):
-        mrow = self.dom.createElement('mrow')
-        brac = self.dom.createElement('mfenced')
-        if i.start == i.end:
-            # Most often, this type of Interval is converted to a FiniteSet
-            brac.setAttribute('close', '}')
-            brac.setAttribute('open', '{')
-            brac.appendChild(self._print(i.start))
+        right = self.dom.createElement('mo')
+        if i.right_open:
+            right.appendChild(self.dom.createTextNode(')'))
         else:
-            if i.right_open:
-                brac.setAttribute('close', ')')
-            else:
-                brac.setAttribute('close', ']')
-
-            if i.left_open:
-                brac.setAttribute('open', '(')
-            else:
-                brac.setAttribute('open', '[')
-            brac.appendChild(self._print(i.start))
-            brac.appendChild(self._print(i.end))
-
-        mrow.appendChild(brac)
+            right.appendChild(self.dom.createTextNode(']'))
+        left = self.dom.createElement('mo')
+        if i.left_open:
+            left.appendChild(self.dom.createTextNode('('))
+        else:
+            left.appendChild(self.dom.createTextNode('['))
+        mrow = self.dom.createElement('mrow')
+        mrow.appendChild(left)
+        mrow.appendChild(self._print(i.start))
+        mrow.appendChild(self._comma())
+        mrow.appendChild(self._print(i.end))
+        mrow.appendChild(right)
         return mrow
 
     def _print_Abs(self, expr, exp=None):
         mrow = self.dom.createElement('mrow')
-        x = self.dom.createElement('mfenced')
-        x.setAttribute('close', '|')
-        x.setAttribute('open', '|')
-        x.appendChild(self._print(expr.args[0]))
-        mrow.appendChild(x)
+        mrow.appendChild(self._bar())
+        mrow.appendChild(self._print(expr.args[0]))
+        mrow.appendChild(self._bar())
         return mrow
 
     _print_Determinant = _print_Abs
 
     def _print_re_im(self, c, expr):
-        mrow = self.dom.createElement('mrow')
+        brac = self.dom.createElement('mrow')
+        brac.appendChild(self._l_paren())
+        brac.appendChild(self._print(expr))
+        brac.appendChild(self._r_paren())
         mi = self.dom.createElement('mi')
-        mi.setAttribute('mathvariant', 'fraktur')
         mi.appendChild(self.dom.createTextNode(c))
+        mrow = self.dom.createElement('mrow')
         mrow.appendChild(mi)
-        brac = self.dom.createElement('mfenced')
-        brac.appendChild(self._print(expr))
         mrow.appendChild(brac)
         return mrow
 
     def _print_re(self, expr, exp=None):
-        return self._print_re_im('R', expr.args[0])
+        return self._print_re_im('\u211C', expr.args[0])
 
     def _print_im(self, expr, exp=None):
-        return self._print_re_im('I', expr.args[0])
+        return self._print_re_im('\u2111', expr.args[0])
 
     def _print_AssocOp(self, e):
         mrow = self.dom.createElement('mrow')
@@ -1301,11 +1351,13 @@ def _print_FiniteSet(self, s):
 
     def _print_set(self, s):
         items = sorted(s, key=default_sort_key)
-        brac = self.dom.createElement('mfenced')
-        brac.setAttribute('close', '}')
-        brac.setAttribute('open', '{')
-        for item in items:
+        brac = self.dom.createElement('mrow')
+        brac.appendChild(self._l_brace())
+        for i, item in enumerate(items):
+            if i:
+                brac.appendChild(self._comma())
             brac.appendChild(self._print(item))
+        brac.appendChild(self._r_brace())
         return brac
 
     _print_frozenset = _print_set
@@ -1313,8 +1365,10 @@ def _print_set(self, s):
     def _print_LogOp(self, args, symbol):
         mrow = self.dom.createElement('mrow')
         if args[0].is_Boolean and not args[0].is_Not:
-            brac = self.dom.createElement('mfenced')
+            brac = self.dom.createElement('mrow')
+            brac.appendChild(self._l_paren())
             brac.appendChild(self._print(args[0]))
+            brac.appendChild(self._r_paren())
             mrow.appendChild(brac)
         else:
             mrow.appendChild(self._print(args[0]))
@@ -1322,8 +1376,10 @@ def _print_LogOp(self, args, symbol):
             x = self.dom.createElement('mo')
             x.appendChild(self.dom.createTextNode(symbol))
             if arg.is_Boolean and not arg.is_Not:
-                y = self.dom.createElement('mfenced')
+                y = self.dom.createElement('mrow')
+                y.appendChild(self._l_paren())
                 y.appendChild(self._print(arg))
+                y.appendChild(self._r_paren())
             else:
                 y = self._print(arg)
             mrow.appendChild(x)
@@ -1362,8 +1418,10 @@ def _print_BasisDependent(self, expr):
                         mo = self.dom.createElement('mo')
                         mo.appendChild(self.dom.createTextNode('+'))
                         mrow.appendChild(mo)
-                    mbrac = self.dom.createElement('mfenced')
+                    mbrac = self.dom.createElement('mrow')
+                    mbrac.appendChild(self._l_paren())
                     mbrac.appendChild(self._print(v))
+                    mbrac.appendChild(self._r_paren())
                     mrow.appendChild(mbrac)
                     mo = self.dom.createElement('mo')
                     mo.appendChild(self.dom.createTextNode('&InvisibleTimes;'))
@@ -1397,8 +1455,10 @@ def _print_Not(self, e):
         mo.appendChild(self.dom.createTextNode('&#xAC;'))
         mrow.appendChild(mo)
         if (e.args[0].is_Boolean):
-            x = self.dom.createElement('mfenced')
+            x = self.dom.createElement('mrow')
+            x.appendChild(self._l_paren())
             x.appendChild(self._print(e.args[0]))
+            x.appendChild(self._r_paren())
         else:
             x = self._print(e.args[0])
         mrow.appendChild(x)
@@ -1419,10 +1479,6 @@ def _print_NoneType(self, e):
 
     def _print_Range(self, s):
         dots = "\u2026"
-        brac = self.dom.createElement('mfenced')
-        brac.setAttribute('close', '}')
-        brac.setAttribute('open', '{')
-
         if s.start.is_infinite and s.stop.is_infinite:
             if s.step.is_positive:
                 printset = dots, -1, 0, 1, dots
@@ -1438,15 +1494,18 @@ def _print_Range(self, s):
             printset = next(it), next(it), dots, s[-1]
         else:
             printset = tuple(s)
-
-        for el in printset:
+        brac = self.dom.createElement('mrow')
+        brac.appendChild(self._l_brace())
+        for i, el in enumerate(printset):
+            if i:
+                brac.appendChild(self._comma())
             if el == dots:
                 mi = self.dom.createElement('mi')
                 mi.appendChild(self.dom.createTextNode(dots))
                 brac.appendChild(mi)
             else:
                 brac.appendChild(self._print(el))
-
+        brac.appendChild(self._r_brace())
         return brac
 
     def _hprint_variadic_function(self, expr):
@@ -1455,10 +1514,7 @@ def _hprint_variadic_function(self, expr):
         mo = self.dom.createElement('mo')
         mo.appendChild(self.dom.createTextNode((str(expr.func)).lower()))
         mrow.appendChild(mo)
-        brac = self.dom.createElement('mfenced')
-        for symbol in args:
-            brac.appendChild(self._print(symbol))
-        mrow.appendChild(brac)
+        mrow.appendChild(self._paren_comma_separated(*args))
         return mrow
 
     _print_Min = _print_Max = _hprint_variadic_function
@@ -1621,11 +1677,15 @@ def _print_Naturals0(self, e):
     def _print_SingularityFunction(self, expr):
         shift = expr.args[0] - expr.args[1]
         power = expr.args[2]
-        sup = self.dom.createElement('msup')
-        brac = self.dom.createElement('mfenced')
-        brac.setAttribute('close', '\u27e9')
-        brac.setAttribute('open', '\u27e8')
+        left = self.dom.createElement('mo')
+        left.appendChild(self.dom.createTextNode('\u27e8'))
+        right = self.dom.createElement('mo')
+        right.appendChild(self.dom.createTextNode('\u27e9'))
+        brac = self.dom.createElement('mrow')
+        brac.appendChild(left)
         brac.appendChild(self._print(shift))
+        brac.appendChild(right)
+        sup = self.dom.createElement('msup')
         sup.appendChild(brac)
         sup.appendChild(self._print(power))
         return sup
@@ -1645,13 +1705,9 @@ def _print_number_function(self, e, name):
         sub.appendChild(self._print(e.args[0]))
         if len(e.args) == 1:
             return sub
-        # TODO: copy-pasted from _print_Function: can we do better?
         mrow = self.dom.createElement('mrow')
-        y = self.dom.createElement('mfenced')
-        for arg in e.args[1:]:
-            y.appendChild(self._print(arg))
         mrow.appendChild(sub)
-        mrow.appendChild(y)
+        mrow.appendChild(self._paren_comma_separated(*e.args[1:]))
         return mrow
 
     def _print_bernoulli(self, e):
@@ -1702,8 +1758,10 @@ def _print_Adjoint(self, expr):
         mat = expr.arg
         sup = self.dom.createElement('msup')
         if not isinstance(mat, MatrixSymbol):
-            brac = self.dom.createElement('mfenced')
+            brac = self.dom.createElement('mrow')
+            brac.appendChild(self._l_paren())
             brac.appendChild(self._print(mat))
+            brac.appendChild(self._r_paren())
             sup.appendChild(brac)
         else:
             sup.appendChild(self._print(mat))
@@ -1717,8 +1775,10 @@ def _print_Transpose(self, expr):
         mat = expr.arg
         sup = self.dom.createElement('msup')
         if not isinstance(mat, MatrixSymbol):
-            brac = self.dom.createElement('mfenced')
+            brac = self.dom.createElement('mrow')
+            brac.appendChild(self._l_paren())
             brac.appendChild(self._print(mat))
+            brac.appendChild(self._r_paren())
             sup.appendChild(brac)
         else:
             sup.appendChild(self._print(mat))
@@ -1732,8 +1792,10 @@ def _print_Inverse(self, expr):
         mat = expr.arg
         sup = self.dom.createElement('msup')
         if not isinstance(mat, MatrixSymbol):
-            brac = self.dom.createElement('mfenced')
+            brac = self.dom.createElement('mrow')
+            brac.appendChild(self._l_paren())
             brac.appendChild(self._print(mat))
+            brac.appendChild(self._r_paren())
             sup.appendChild(brac)
         else:
             sup.appendChild(self._print(mat))
@@ -1774,8 +1836,10 @@ def _print_MatPow(self, expr):
         base, exp = expr.base, expr.exp
         sup = self.dom.createElement('msup')
         if not isinstance(base, MatrixSymbol):
-            brac = self.dom.createElement('mfenced')
+            brac = self.dom.createElement('mrow')
+            brac.appendChild(self._l_paren())
             brac.appendChild(self._print(base))
+            brac.appendChild(self._r_paren())
             sup.appendChild(brac)
         else:
             sup.appendChild(self._print(base))
@@ -1811,44 +1875,45 @@ def _print_Identity(self, I):
         return x
 
     def _print_floor(self, e):
+        left = self.dom.createElement('mo')
+        left.appendChild(self.dom.createTextNode('\u230A'))
+        right = self.dom.createElement('mo')
+        right.appendChild(self.dom.createTextNode('\u230B'))
         mrow = self.dom.createElement('mrow')
-        x = self.dom.createElement('mfenced')
-        x.setAttribute('close', '\u230B')
-        x.setAttribute('open', '\u230A')
-        x.appendChild(self._print(e.args[0]))
-        mrow.appendChild(x)
+        mrow.appendChild(left)
+        mrow.appendChild(self._print(e.args[0]))
+        mrow.appendChild(right)
         return mrow
 
     def _print_ceiling(self, e):
+        left = self.dom.createElement('mo')
+        left.appendChild(self.dom.createTextNode('\u2308'))
+        right = self.dom.createElement('mo')
+        right.appendChild(self.dom.createTextNode('\u2309'))
         mrow = self.dom.createElement('mrow')
-        x = self.dom.createElement('mfenced')
-        x.setAttribute('close', '\u2309')
-        x.setAttribute('open', '\u2308')
-        x.appendChild(self._print(e.args[0]))
-        mrow.appendChild(x)
+        mrow.appendChild(left)
+        mrow.appendChild(self._print(e.args[0]))
+        mrow.appendChild(right)
         return mrow
 
     def _print_Lambda(self, e):
-        x = self.dom.createElement('mfenced')
         mrow = self.dom.createElement('mrow')
         symbols = e.args[0]
         if len(symbols) == 1:
             symbols = self._print(symbols[0])
         else:
             symbols = self._print(symbols)
+        mrow.appendChild(self._l_paren())
         mrow.appendChild(symbols)
         mo = self.dom.createElement('mo')
         mo.appendChild(self.dom.createTextNode('&#x21A6;'))
         mrow.appendChild(mo)
         mrow.appendChild(self._print(e.args[1]))
-        x.appendChild(mrow)
-        return x
+        mrow.appendChild(self._r_paren())
+        return mrow
 
     def _print_tuple(self, e):
-        x = self.dom.createElement('mfenced')
-        for i in e:
-            x.appendChild(self._print(i))
-        return x
+        return self._paren_comma_separated(*e)
 
     def _print_IndexedBase(self, e):
         return self._print(e.label)
@@ -1865,11 +1930,11 @@ def _print_Indexed(self, e):
     def _print_MatrixElement(self, e):
         x = self.dom.createElement('msub')
         x.appendChild(self.parenthesize(e.parent, PRECEDENCE["Atom"], strict = True))
-        brac = self.dom.createElement('mfenced')
-        brac.setAttribute("close", "")
-        brac.setAttribute("open", "")
-        for i in e.indices:
-            brac.appendChild(self._print(i))
+        brac = self.dom.createElement('mrow')
+        for i, arg in enumerate(e.indices):
+            if i:
+                brac.appendChild(self._comma())
+            brac.appendChild(self._print(arg))
         x.appendChild(brac)
         return x
 
@@ -1878,11 +1943,7 @@ def _print_elliptic_f(self, e):
         mi = self.dom.createElement('mi')
         mi.appendChild(self.dom.createTextNode('&#x1d5a5;'))
         x.appendChild(mi)
-        y = self.dom.createElement('mfenced')
-        y.setAttribute("separators", "|")
-        for i in e.args:
-            y.appendChild(self._print(i))
-        x.appendChild(y)
+        x.appendChild(self._paren_bar_separated(*e.args))
         return x
 
     def _print_elliptic_e(self, e):
@@ -1890,11 +1951,7 @@ def _print_elliptic_e(self, e):
         mi = self.dom.createElement('mi')
         mi.appendChild(self.dom.createTextNode('&#x1d5a4;'))
         x.appendChild(mi)
-        y = self.dom.createElement('mfenced')
-        y.setAttribute("separators", "|")
-        for i in e.args:
-            y.appendChild(self._print(i))
-        x.appendChild(y)
+        x.appendChild(self._paren_bar_separated(*e.args))
         return x
 
     def _print_elliptic_pi(self, e):
@@ -1902,13 +1959,21 @@ def _print_elliptic_pi(self, e):
         mi = self.dom.createElement('mi')
         mi.appendChild(self.dom.createTextNode('&#x1d6f1;'))
         x.appendChild(mi)
-        y = self.dom.createElement('mfenced')
+        y = self.dom.createElement('mrow')
+        y.appendChild(self._l_paren())
         if len(e.args) == 2:
-            y.setAttribute("separators", "|")
+            n, m = e.args
+            y.appendChild(self._print(n))
+            y.appendChild(self._bar())
+            y.appendChild(self._print(m))
         else:
-            y.setAttribute("separators", ";|")
-        for i in e.args:
-            y.appendChild(self._print(i))
+            n, m, z = e.args
+            y.appendChild(self._print(n))
+            y.appendChild(self._semicolon())
+            y.appendChild(self._print(m))
+            y.appendChild(self._bar())
+            y.appendChild(self._print(z))
+        y.appendChild(self._r_paren())
         x.appendChild(y)
         return x
 


Test patch:
diff --git a/sympy/printing/tests/test_mathml.py b/sympy/printing/tests/test_mathml.py
index 433115d402fa..bd62821b6da4 100644
--- a/sympy/printing/tests/test_mathml.py
+++ b/sympy/printing/tests/test_mathml.py
@@ -727,7 +727,7 @@ def test_presentation_mathml_functions():
     mml_1 = mpp._print(sin(x))
     assert mml_1.childNodes[0].childNodes[0
         ].nodeValue == 'sin'
-    assert mml_1.childNodes[1].childNodes[0
+    assert mml_1.childNodes[1].childNodes[1
         ].childNodes[0].nodeValue == 'x'
 
     mml_2 = mpp._print(diff(sin(x), x, evaluate=False))
@@ -735,7 +735,7 @@ def test_presentation_mathml_functions():
     assert mml_2.childNodes[0].childNodes[0
         ].childNodes[0].childNodes[0].nodeValue == '&dd;'
     assert mml_2.childNodes[1].childNodes[1
-        ].nodeName == 'mfenced'
+        ].nodeName == 'mrow'
     assert mml_2.childNodes[0].childNodes[1
         ].childNodes[0].childNodes[0].nodeValue == '&dd;'
 
@@ -753,7 +753,7 @@ def test_print_derivative():
     assert mathml(d) == \
         '<apply><partialdiff/><bvar><ci>y</ci><ci>z</ci><degree><cn>2</cn></degree><ci>x</ci><ci>z</ci><ci>x</ci></bvar><apply><f/><ci>x</ci><ci>y</ci><ci>z</ci></apply></apply>'
     assert mathml(d, printer='presentation') == \
-        '<mrow><mfrac><mrow><msup><mo>&#x2202;</mo><mn>6</mn></msup></mrow><mrow><mo>&#x2202;</mo><mi>y</mi><msup><mo>&#x2202;</mo><mn>2</mn></msup><mi>z</mi><mo>&#x2202;</mo><mi>x</mi><mo>&#x2202;</mo><mi>z</mi><mo>&#x2202;</mo><mi>x</mi></mrow></mfrac><mrow><mi>f</mi><mfenced><mi>x</mi><mi>y</mi><mi>z</mi></mfenced></mrow></mrow>'
+        '<mrow><mfrac><mrow><msup><mo>&#x2202;</mo><mn>6</mn></msup></mrow><mrow><mo>&#x2202;</mo><mi>y</mi><msup><mo>&#x2202;</mo><mn>2</mn></msup><mi>z</mi><mo>&#x2202;</mo><mi>x</mi><mo>&#x2202;</mo><mi>z</mi><mo>&#x2202;</mo><mi>x</mi></mrow></mfrac><mrow><mi>f</mi><mrow><mo>(</mo><mi>x</mi><mo>,</mo><mi>y</mi><mo>,</mo><mi>z</mi><mo>)</mo></mrow></mrow></mrow>'
 
 
 def test_presentation_mathml_limits():
@@ -778,8 +778,8 @@ def test_presentation_mathml_integrals():
         '<mrow><msubsup><mo>&#x222B;</mo><mn>0</mn><mn>1</mn></msubsup>'\
         '<mi>x</mi><mo>&dd;</mo><mi>x</mi></mrow>'
     assert mpp.doprint(Integral(log(x), x)) == \
-        '<mrow><mo>&#x222B;</mo><mrow><mi>log</mi><mfenced><mi>x</mi>'\
-        '</mfenced></mrow><mo>&dd;</mo><mi>x</mi></mrow>'
+        '<mrow><mo>&#x222B;</mo><mrow><mi>log</mi><mrow><mo>(</mo><mi>x</mi>' \
+        '<mo>)</mo></mrow></mrow><mo>&dd;</mo><mi>x</mi></mrow>'
     assert mpp.doprint(Integral(x*y, x, y)) == \
         '<mrow><mo>&#x222C;</mo><mrow><mi>x</mi><mo>&InvisibleTimes;</mo>'\
         '<mi>y</mi></mrow><mo>&dd;</mo><mi>y</mi><mo>&dd;</mo><mi>x</mi></mrow>'
@@ -807,46 +807,45 @@ def test_presentation_mathml_matrices():
     A = Matrix([1, 2, 3])
     B = Matrix([[0, 5, 4], [2, 3, 1], [9, 7, 9]])
     mll_1 = mpp._print(A)
-    assert mll_1.childNodes[0].nodeName == 'mtable'
-    assert mll_1.childNodes[0].childNodes[0].nodeName == 'mtr'
-    assert len(mll_1.childNodes[0].childNodes) == 3
-    assert mll_1.childNodes[0].childNodes[0].childNodes[0].nodeName == 'mtd'
-    assert len(mll_1.childNodes[0].childNodes[0].childNodes) == 1
-    assert mll_1.childNodes[0].childNodes[0].childNodes[0
+    assert mll_1.childNodes[1].nodeName == 'mtable'
+    assert mll_1.childNodes[1].childNodes[0].nodeName == 'mtr'
+    assert len(mll_1.childNodes[1].childNodes) == 3
+    assert mll_1.childNodes[1].childNodes[0].childNodes[0].nodeName == 'mtd'
+    assert len(mll_1.childNodes[1].childNodes[0].childNodes) == 1
+    assert mll_1.childNodes[1].childNodes[0].childNodes[0
         ].childNodes[0].childNodes[0].nodeValue == '1'
-    assert mll_1.childNodes[0].childNodes[1].childNodes[0
+    assert mll_1.childNodes[1].childNodes[1].childNodes[0
         ].childNodes[0].childNodes[0].nodeValue == '2'
-    assert mll_1.childNodes[0].childNodes[2].childNodes[0
+    assert mll_1.childNodes[1].childNodes[2].childNodes[0
         ].childNodes[0].childNodes[0].nodeValue == '3'
     mll_2 = mpp._print(B)
-    assert mll_2.childNodes[0].nodeName == 'mtable'
-    assert mll_2.childNodes[0].childNodes[0].nodeName == 'mtr'
-    assert len(mll_2.childNodes[0].childNodes) == 3
-    assert mll_2.childNodes[0].childNodes[0].childNodes[0].nodeName == 'mtd'
-    assert len(mll_2.childNodes[0].childNodes[0].childNodes) == 3
-    assert mll_2.childNodes[0].childNodes[0].childNodes[0
+    assert mll_2.childNodes[1].nodeName == 'mtable'
+    assert mll_2.childNodes[1].childNodes[0].nodeName == 'mtr'
+    assert len(mll_2.childNodes[1].childNodes) == 3
+    assert mll_2.childNodes[1].childNodes[0].childNodes[0].nodeName == 'mtd'
+    assert len(mll_2.childNodes[1].childNodes[0].childNodes) == 3
+    assert mll_2.childNodes[1].childNodes[0].childNodes[0
         ].childNodes[0].childNodes[0].nodeValue == '0'
-    assert mll_2.childNodes[0].childNodes[0].childNodes[1
+    assert mll_2.childNodes[1].childNodes[0].childNodes[1
         ].childNodes[0].childNodes[0].nodeValue == '5'
-    assert mll_2.childNodes[0].childNodes[0].childNodes[2
+    assert mll_2.childNodes[1].childNodes[0].childNodes[2
         ].childNodes[0].childNodes[0].nodeValue == '4'
-    assert mll_2.childNodes[0].childNodes[1].childNodes[0
+    assert mll_2.childNodes[1].childNodes[1].childNodes[0
         ].childNodes[0].childNodes[0].nodeValue == '2'
-    assert mll_2.childNodes[0].childNodes[1].childNodes[1
+    assert mll_2.childNodes[1].childNodes[1].childNodes[1
         ].childNodes[0].childNodes[0].nodeValue == '3'
-    assert mll_2.childNodes[0].childNodes[1].childNodes[2
+    assert mll_2.childNodes[1].childNodes[1].childNodes[2
         ].childNodes[0].childNodes[0].nodeValue == '1'
-    assert mll_2.childNodes[0].childNodes[2].childNodes[0
+    assert mll_2.childNodes[1].childNodes[2].childNodes[0
         ].childNodes[0].childNodes[0].nodeValue == '9'
-    assert mll_2.childNodes[0].childNodes[2].childNodes[1
+    assert mll_2.childNodes[1].childNodes[2].childNodes[1
         ].childNodes[0].childNodes[0].nodeValue == '7'
-    assert mll_2.childNodes[0].childNodes[2].childNodes[2
+    assert mll_2.childNodes[1].childNodes[2].childNodes[2
         ].childNodes[0].childNodes[0].nodeValue == '9'
 
 
 def test_presentation_mathml_sums():
-    summand = x
-    mml_1 = mpp._print(Sum(summand, (x, 1, 10)))
+    mml_1 = mpp._print(Sum(x, (x, 1, 10)))
     assert mml_1.childNodes[0].nodeName == 'munderover'
     assert len(mml_1.childNodes[0].childNodes) == 3
     assert mml_1.childNodes[0].childNodes[0].childNodes[0
@@ -856,6 +855,11 @@ def test_presentation_mathml_sums():
         ].nodeValue == '10'
     assert mml_1.childNodes[1].childNodes[0].nodeValue == 'x'
 
+    assert mpp.doprint(Sum(x, (x, 1, 10))) == \
+        '<mrow><munderover><mo>&#x2211;</mo><mrow><mi>x</mi><mo>=</mo><mn>1</mn></mrow><mn>10</mn></munderover><mi>x</mi></mrow>'
+    assert mpp.doprint(Sum(x + y, (x, 1, 10))) == \
+        '<mrow><munderover><mo>&#x2211;</mo><mrow><mi>x</mi><mo>=</mo><mn>1</mn></mrow><mn>10</mn></munderover><mrow><mo>(</mo><mrow><mi>x</mi><mo>+</mo><mi>y</mi></mrow><mo>)</mo></mrow></mrow>'
+
 
 def test_presentation_mathml_add():
     mml = mpp._print(x**5 - x**4 + x)
@@ -1160,53 +1164,52 @@ def test_presentation_mathml_order():
 def test_print_intervals():
     a = Symbol('a', real=True)
     assert mpp.doprint(Interval(0, a)) == \
-        '<mrow><mfenced close="]" open="["><mn>0</mn><mi>a</mi></mfenced></mrow>'
+        '<mrow><mo>[</mo><mn>0</mn><mo>,</mo><mi>a</mi><mo>]</mo></mrow>'
     assert mpp.doprint(Interval(0, a, False, False)) == \
-        '<mrow><mfenced close="]" open="["><mn>0</mn><mi>a</mi></mfenced></mrow>'
+        '<mrow><mo>[</mo><mn>0</mn><mo>,</mo><mi>a</mi><mo>]</mo></mrow>'
     assert mpp.doprint(Interval(0, a, True, False)) == \
-        '<mrow><mfenced close="]" open="("><mn>0</mn><mi>a</mi></mfenced></mrow>'
+        '<mrow><mo>(</mo><mn>0</mn><mo>,</mo><mi>a</mi><mo>]</mo></mrow>'
     assert mpp.doprint(Interval(0, a, False, True)) == \
-        '<mrow><mfenced close=")" open="["><mn>0</mn><mi>a</mi></mfenced></mrow>'
+        '<mrow><mo>[</mo><mn>0</mn><mo>,</mo><mi>a</mi><mo>)</mo></mrow>'
     assert mpp.doprint(Interval(0, a, True, True)) == \
-        '<mrow><mfenced close=")" open="("><mn>0</mn><mi>a</mi></mfenced></mrow>'
+        '<mrow><mo>(</mo><mn>0</mn><mo>,</mo><mi>a</mi><mo>)</mo></mrow>'
 
 
 def test_print_tuples():
     assert mpp.doprint(Tuple(0,)) == \
-        '<mrow><mfenced><mn>0</mn></mfenced></mrow>'
+        '<mrow><mo>(</mo><mn>0</mn><mo>)</mo></mrow>'
     assert mpp.doprint(Tuple(0, a)) == \
-        '<mrow><mfenced><mn>0</mn><mi>a</mi></mfenced></mrow>'
+        '<mrow><mo>(</mo><mn>0</mn><mo>,</mo><mi>a</mi><mo>)</mo></mrow>'
     assert mpp.doprint(Tuple(0, a, a)) == \
-        '<mrow><mfenced><mn>0</mn><mi>a</mi><mi>a</mi></mfenced></mrow>'
+        '<mrow><mo>(</mo><mn>0</mn><mo>,</mo><mi>a</mi><mo>,</mo><mi>a</mi><mo>)</mo></mrow>'
     assert mpp.doprint(Tuple(0, 1, 2, 3, 4)) == \
-        '<mrow><mfenced><mn>0</mn><mn>1</mn><mn>2</mn><mn>3</mn><mn>4</mn></mfenced></mrow>'
+        '<mrow><mo>(</mo><mn>0</mn><mo>,</mo><mn>1</mn><mo>,</mo><mn>2</mn><mo>,</mo><mn>3</mn><mo>,</mo><mn>4</mn><mo>)</mo></mrow>'
     assert mpp.doprint(Tuple(0, 1, Tuple(2, 3, 4))) == \
-        '<mrow><mfenced><mn>0</mn><mn>1</mn><mrow><mfenced><mn>2</mn><mn>3'\
-        '</mn><mn>4</mn></mfenced></mrow></mfenced></mrow>'
+        '<mrow><mo>(</mo><mn>0</mn><mo>,</mo><mn>1</mn><mo>,</mo><mrow><mo>(</mo><mn>2</mn><mo>,</mo><mn>3'\
+        '</mn><mo>,</mo><mn>4</mn><mo>)</mo></mrow><mo>)</mo></mrow>'
 
 
 def test_print_re_im():
     assert mpp.doprint(re(x)) == \
-        '<mrow><mi mathvariant="fraktur">R</mi><mfenced><mi>x</mi></mfenced></mrow>'
+        '<mrow><mi>&#8476;</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
     assert mpp.doprint(im(x)) == \
-        '<mrow><mi mathvariant="fraktur">I</mi><mfenced><mi>x</mi></mfenced></mrow>'
-    assert mpp.doprint(re(x + 1)) == \
-        '<mrow><mrow><mi mathvariant="fraktur">R</mi><mfenced><mi>x</mi>'\
-        '</mfenced></mrow><mo>+</mo><mn>1</mn></mrow>'
-    assert mpp.doprint(im(x + 1)) == \
-        '<mrow><mi mathvariant="fraktur">I</mi><mfenced><mi>x</mi></mfenced></mrow>'
+        '<mrow><mi>&#8465;</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
+    assert mpp.doprint(re(x + 1, evaluate=False)) == \
+        '<mrow><mi>&#8476;</mi><mrow><mo>(</mo><mrow><mi>x</mi><mo>+</mo><mn>1</mn></mrow><mo>)</mo></mrow></mrow>'
+    assert mpp.doprint(im(x + 1, evaluate=False)) == \
+        '<mrow><mi>&#8465;</mi><mrow><mo>(</mo><mrow><mi>x</mi><mo>+</mo><mn>1</mn></mrow><mo>)</mo></mrow></mrow>'
 
 
 def test_print_Abs():
     assert mpp.doprint(Abs(x)) == \
-        '<mrow><mfenced close="|" open="|"><mi>x</mi></mfenced></mrow>'
+        '<mrow><mo>|</mo><mi>x</mi><mo>|</mo></mrow>'
     assert mpp.doprint(Abs(x + 1)) == \
-        '<mrow><mfenced close="|" open="|"><mrow><mi>x</mi><mo>+</mo><mn>1</mn></mrow></mfenced></mrow>'
+        '<mrow><mo>|</mo><mrow><mi>x</mi><mo>+</mo><mn>1</mn></mrow><mo>|</mo></mrow>'
 
 
 def test_print_Determinant():
     assert mpp.doprint(Determinant(Matrix([[1, 2], [3, 4]]))) == \
-        '<mrow><mfenced close="|" open="|"><mfenced close="]" open="["><mtable><mtr><mtd><mn>1</mn></mtd><mtd><mn>2</mn></mtd></mtr><mtr><mtd><mn>3</mn></mtd><mtd><mn>4</mn></mtd></mtr></mtable></mfenced></mfenced></mrow>'
+        '<mrow><mo>|</mo><mrow><mo>[</mo><mtable><mtr><mtd><mn>1</mn></mtd><mtd><mn>2</mn></mtd></mtr><mtr><mtd><mn>3</mn></mtd><mtd><mn>4</mn></mtd></mtr></mtable><mo>]</mo></mrow><mo>|</mo></mrow>'
 
 
 def test_presentation_settings():
@@ -1247,19 +1250,19 @@ class TestAssocOp(AssocOp):
 def test_print_basic():
     expr = Basic(S(1), S(2))
     assert mpp.doprint(expr) == \
-        '<mrow><mi>basic</mi><mfenced><mn>1</mn><mn>2</mn></mfenced></mrow>'
+        '<mrow><mi>basic</mi><mrow><mo>(</mo><mn>1</mn><mo>,</mo><mn>2</mn><mo>)</mo></mrow></mrow>'
     assert mp.doprint(expr) == '<basic><cn>1</cn><cn>2</cn></basic>'
 
 
 def test_mat_delim_print():
     expr = Matrix([[1, 2], [3, 4]])
     assert mathml(expr, printer='presentation', mat_delim='[') == \
-        '<mfenced close="]" open="["><mtable><mtr><mtd><mn>1</mn></mtd><mtd>'\
+        '<mrow><mo>[</mo><mtable><mtr><mtd><mn>1</mn></mtd><mtd>'\
         '<mn>2</mn></mtd></mtr><mtr><mtd><mn>3</mn></mtd><mtd><mn>4</mn>'\
-        '</mtd></mtr></mtable></mfenced>'
+        '</mtd></mtr></mtable><mo>]</mo></mrow>'
     assert mathml(expr, printer='presentation', mat_delim='(') == \
-        '<mfenced><mtable><mtr><mtd><mn>1</mn></mtd><mtd><mn>2</mn></mtd>'\
-        '</mtr><mtr><mtd><mn>3</mn></mtd><mtd><mn>4</mn></mtd></mtr></mtable></mfenced>'
+        '<mrow><mo>(</mo><mtable><mtr><mtd><mn>1</mn></mtd><mtd><mn>2</mn></mtd>'\
+        '</mtr><mtr><mtd><mn>3</mn></mtd><mtd><mn>4</mn></mtd></mtr></mtable><mo>)</mo></mrow>'
     assert mathml(expr, printer='presentation', mat_delim='') == \
         '<mtable><mtr><mtd><mn>1</mn></mtd><mtd><mn>2</mn></mtd></mtr><mtr>'\
         '<mtd><mn>3</mn></mtd><mtd><mn>4</mn></mtd></mtr></mtable>'
@@ -1268,11 +1271,11 @@ def test_mat_delim_print():
 def test_ln_notation_print():
     expr = log(x)
     assert mathml(expr, printer='presentation') == \
-        '<mrow><mi>log</mi><mfenced><mi>x</mi></mfenced></mrow>'
+        '<mrow><mi>log</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
     assert mathml(expr, printer='presentation', ln_notation=False) == \
-        '<mrow><mi>log</mi><mfenced><mi>x</mi></mfenced></mrow>'
+        '<mrow><mi>log</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
     assert mathml(expr, printer='presentation', ln_notation=True) == \
-        '<mrow><mi>ln</mi><mfenced><mi>x</mi></mfenced></mrow>'
+        '<mrow><mi>ln</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
 
 
 def test_mul_symbol_print():
@@ -1291,34 +1294,34 @@ def test_mul_symbol_print():
 
 def test_print_lerchphi():
     assert mpp.doprint(lerchphi(1, 2, 3)) == \
-        '<mrow><mi>&#x3A6;</mi><mfenced><mn>1</mn><mn>2</mn><mn>3</mn></mfenced></mrow>'
+        '<mrow><mi>&#x3A6;</mi><mrow><mo>(</mo><mn>1</mn><mo>,</mo><mn>2</mn><mo>,</mo><mn>3</mn><mo>)</mo></mrow></mrow>'
 
 
 def test_print_polylog():
     assert mp.doprint(polylog(x, y)) == \
         '<apply><polylog/><ci>x</ci><ci>y</ci></apply>'
     assert mpp.doprint(polylog(x, y)) == \
-        '<mrow><msub><mi>Li</mi><mi>x</mi></msub><mfenced><mi>y</mi></mfenced></mrow>'
+        '<mrow><msub><mi>Li</mi><mi>x</mi></msub><mrow><mo>(</mo><mi>y</mi><mo>)</mo></mrow></mrow>'
 
 
 def test_print_set_frozenset():
     f = frozenset({1, 5, 3})
     assert mpp.doprint(f) == \
-        '<mfenced close="}" open="{"><mn>1</mn><mn>3</mn><mn>5</mn></mfenced>'
+        '<mrow><mo>{</mo><mn>1</mn><mo>,</mo><mn>3</mn><mo>,</mo><mn>5</mn><mo>}</mo></mrow>'
     s = set({1, 2, 3})
     assert mpp.doprint(s) == \
-        '<mfenced close="}" open="{"><mn>1</mn><mn>2</mn><mn>3</mn></mfenced>'
+        '<mrow><mo>{</mo><mn>1</mn><mo>,</mo><mn>2</mn><mo>,</mo><mn>3</mn><mo>}</mo></mrow>'
 
 
 def test_print_FiniteSet():
     f1 = FiniteSet(x, 1, 3)
     assert mpp.doprint(f1) == \
-        '<mfenced close="}" open="{"><mn>1</mn><mn>3</mn><mi>x</mi></mfenced>'
+        '<mrow><mo>{</mo><mn>1</mn><mo>,</mo><mn>3</mn><mo>,</mo><mi>x</mi><mo>}</mo></mrow>'
 
 
 def test_print_LambertW():
-    assert mpp.doprint(LambertW(x)) == '<mrow><mi>W</mi><mfenced><mi>x</mi></mfenced></mrow>'
-    assert mpp.doprint(LambertW(x, y)) == '<mrow><mi>W</mi><mfenced><mi>x</mi><mi>y</mi></mfenced></mrow>'
+    assert mpp.doprint(LambertW(x)) == '<mrow><mi>W</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
+    assert mpp.doprint(LambertW(x, y)) == '<mrow><mi>W</mi><mrow><mo>(</mo><mi>x</mi><mo>,</mo><mi>y</mi><mo>)</mo></mrow></mrow>'
 
 
 def test_print_EmptySet():
@@ -1358,21 +1361,21 @@ def test_print_SetOp():
     prntr = lambda x: mathml(x, printer='presentation')
 
     assert prntr(Union(f1, f2, evaluate=False)) == \
-    '<mrow><mfenced close="}" open="{"><mn>1</mn><mn>3</mn><mi>x</mi>'\
-    '</mfenced><mo>&#x222A;</mo><mfenced close="}" open="{"><mn>2</mn>'\
-    '<mn>4</mn><mi>y</mi></mfenced></mrow>'
+    '<mrow><mrow><mo>{</mo><mn>1</mn><mo>,</mo><mn>3</mn><mo>,</mo><mi>x</mi>'\
+    '<mo>}</mo></mrow><mo>&#x222A;</mo><mrow><mo>{</mo><mn>2</mn><mo>,</mo>'\
+    '<mn>4</mn><mo>,</mo><mi>y</mi><mo>}</mo></mrow></mrow>'
     assert prntr(Intersection(f1, f2, evaluate=False)) == \
-    '<mrow><mfenced close="}" open="{"><mn>1</mn><mn>3</mn><mi>x</mi>'\
-    '</mfenced><mo>&#x2229;</mo><mfenced close="}" open="{"><mn>2</mn>'\
-    '<mn>4</mn><mi>y</mi></mfenced></mrow>'
+    '<mrow><mrow><mo>{</mo><mn>1</mn><mo>,</mo><mn>3</mn><mo>,</mo><mi>x</mi>'\
+    '<mo>}</mo></mrow><mo>&#x2229;</mo><mrow><mo>{</mo><mn>2</mn>'\
+    '<mo>,</mo><mn>4</mn><mo>,</mo><mi>y</mi><mo>}</mo></mrow></mrow>'
     assert prntr(Complement(f1, f2, evaluate=False)) == \
-    '<mrow><mfenced close="}" open="{"><mn>1</mn><mn>3</mn><mi>x</mi>'\
-    '</mfenced><mo>&#x2216;</mo><mfenced close="}" open="{"><mn>2</mn>'\
-    '<mn>4</mn><mi>y</mi></mfenced></mrow>'
+    '<mrow><mrow><mo>{</mo><mn>1</mn><mo>,</mo><mn>3</mn><mo>,</mo><mi>x</mi>'\
+    '<mo>}</mo></mrow><mo>&#x2216;</mo><mrow><mo>{</mo><mn>2</mn>'\
+    '<mo>,</mo><mn>4</mn><mo>,</mo><mi>y</mi><mo>}</mo></mrow></mrow>'
     assert prntr(SymmetricDifference(f1, f2, evaluate=False)) == \
-    '<mrow><mfenced close="}" open="{"><mn>1</mn><mn>3</mn><mi>x</mi>'\
-    '</mfenced><mo>&#x2206;</mo><mfenced close="}" open="{"><mn>2</mn>'\
-    '<mn>4</mn><mi>y</mi></mfenced></mrow>'
+    '<mrow><mrow><mo>{</mo><mn>1</mn><mo>,</mo><mn>3</mn><mo>,</mo><mi>x</mi>'\
+    '<mo>}</mo></mrow><mo>&#x2206;</mo><mrow><mo>{</mo><mn>2</mn>'\
+    '<mo>,</mo><mn>4</mn><mo>,</mo><mi>y</mi><mo>}</mo></mrow></mrow>'
 
     A = FiniteSet(a)
     C = FiniteSet(c)
@@ -1386,30 +1389,30 @@ def test_print_SetOp():
     P1 = ProductSet(C, D)
 
     assert prntr(Union(A, I1, evaluate=False)) == \
-        '<mrow><mfenced close="}" open="{"><mi>a</mi></mfenced>' \
-        '<mo>&#x222A;</mo><mfenced><mrow><mfenced close="}" open="{">' \
-        '<mi>c</mi></mfenced><mo>&#x2229;</mo><mfenced close="}" open="{">' \
-        '<mi>d</mi></mfenced></mrow></mfenced></mrow>'
+        '<mrow><mrow><mo>{</mo><mi>a</mi><mo>}</mo></mrow>' \
+        '<mo>&#x222A;</mo><mrow><mo>(</mo><mrow><mrow><mo>{</mo>' \
+        '<mi>c</mi><mo>}</mo></mrow><mo>&#x2229;</mo><mrow><mo>{</mo>' \
+        '<mi>d</mi><mo>}</mo></mrow></mrow><mo>)</mo></mrow></mrow>'
     assert prntr(Intersection(A, C1, evaluate=False)) == \
-        '<mrow><mfenced close="}" open="{"><mi>a</mi></mfenced>' \
-        '<mo>&#x2229;</mo><mfenced><mrow><mfenced close="}" open="{">' \
-        '<mi>c</mi></mfenced><mo>&#x2216;</mo><mfenced close="}" open="{">' \
-        '<mi>d</mi></mfenced></mrow></mfenced></mrow>'
+        '<mrow><mrow><mo>{</mo><mi>a</mi><mo>}</mo></mrow>' \
+        '<mo>&#x2229;</mo><mrow><mo>(</mo><mrow><mrow><mo>{</mo>' \
+        '<mi>c</mi><mo>}</mo></mrow><mo>&#x2216;</mo><mrow><mo>{</mo>' \
+        '<mi>d</mi><mo>}</mo></mrow></mrow><mo>)</mo></mrow></mrow>'
     assert prntr(Complement(A, D1, evaluate=False)) == \
-        '<mrow><mfenced close="}" open="{"><mi>a</mi></mfenced>' \
-        '<mo>&#x2216;</mo><mfenced><mrow><mfenced close="}" open="{">' \
-        '<mi>c</mi></mfenced><mo>&#x2206;</mo><mfenced close="}" open="{">' \
-        '<mi>d</mi></mfenced></mrow></mfenced></mrow>'
+        '<mrow><mrow><mo>{</mo><mi>a</mi><mo>}</mo></mrow>' \
+        '<mo>&#x2216;</mo><mrow><mo>(</mo><mrow><mrow><mo>{</mo>' \
+        '<mi>c</mi><mo>}</mo></mrow><mo>&#x2206;</mo><mrow><mo>{</mo>' \
+        '<mi>d</mi><mo>}</mo></mrow></mrow><mo>)</mo></mrow></mrow>'
     assert prntr(SymmetricDifference(A, P1, evaluate=False)) == \
-        '<mrow><mfenced close="}" open="{"><mi>a</mi></mfenced>' \
-        '<mo>&#x2206;</mo><mfenced><mrow><mfenced close="}" open="{">' \
-        '<mi>c</mi></mfenced><mo>&#x00d7;</mo><mfenced close="}" open="{">' \
-        '<mi>d</mi></mfenced></mrow></mfenced></mrow>'
+        '<mrow><mrow><mo>{</mo><mi>a</mi><mo>}</mo></mrow>' \
+        '<mo>&#x2206;</mo><mrow><mo>(</mo><mrow><mrow><mo>{</mo>' \
+        '<mi>c</mi><mo>}</mo></mrow><mo>&#x00d7;</mo><mrow><mo>{</mo>' \
+        '<mi>d</mi><mo>}</mo></mrow></mrow><mo>)</mo></mrow></mrow>'
     assert prntr(ProductSet(A, U1)) == \
-        '<mrow><mfenced close="}" open="{"><mi>a</mi></mfenced>' \
-        '<mo>&#x00d7;</mo><mfenced><mrow><mfenced close="}" open="{">' \
-        '<mi>c</mi></mfenced><mo>&#x222A;</mo><mfenced close="}" open="{">' \
-        '<mi>d</mi></mfenced></mrow></mfenced></mrow>'
+        '<mrow><mrow><mo>{</mo><mi>a</mi><mo>}</mo></mrow>' \
+        '<mo>&#x00d7;</mo><mrow><mo>(</mo><mrow><mrow><mo>{</mo>' \
+        '<mi>c</mi><mo>}</mo></mrow><mo>&#x222A;</mo><mrow><mo>{</mo>' \
+        '<mi>d</mi><mo>}</mo></mrow></mrow><mo>)</mo></mrow></mrow>'
 
 
 def test_print_logic():
@@ -1435,15 +1438,14 @@ def test_print_logic():
         '<mrow><mrow><mi>x</mi><mo>=</mo><mi>y</mi></mrow><mo>&#x2228;</mo>'\
         '<mrow><mi>x</mi><mo>></mo><mn>4</mn></mrow></mrow>'
     assert mpp.doprint(And(Eq(x, 3), Or(y < 3, x > y + 1))) == \
-        '<mrow><mrow><mi>x</mi><mo>=</mo><mn>3</mn></mrow><mo>&#x2227;</mo>'\
-        '<mfenced><mrow><mrow><mi>x</mi><mo>></mo><mrow><mi>y</mi><mo>+</mo>'\
-        '<mn>1</mn></mrow></mrow><mo>&#x2228;</mo><mrow><mi>y</mi><mo><</mo>'\
-        '<mn>3</mn></mrow></mrow></mfenced></mrow>'
+        '<mrow><mrow><mi>x</mi><mo>=</mo><mn>3</mn></mrow>'\
+        '<mo>&#x2227;</mo><mrow><mo>(</mo><mrow><mrow><mi>x</mi><mo>></mo><mrow>'\
+        '<mi>y</mi><mo>+</mo><mn>1</mn></mrow></mrow><mo>&#x2228;</mo><mrow>'\
+        '<mi>y</mi><mo><</mo><mn>3</mn></mrow></mrow><mo>)</mo></mrow></mrow>'
 
     assert mpp.doprint(Not(x)) == '<mrow><mo>&#xAC;</mo><mi>x</mi></mrow>'
     assert mpp.doprint(Not(And(x, y))) == \
-        '<mrow><mo>&#xAC;</mo><mfenced><mrow><mi>x</mi><mo>&#x2227;</mo>'\
-        '<mi>y</mi></mrow></mfenced></mrow>'
+        '<mrow><mo>&#xAC;</mo><mrow><mo>(</mo><mrow><mi>x</mi><mo>&#x2227;</mo><mi>y</mi></mrow><mo>)</mo></mrow></mrow>'
 
 
 def test_root_notation_print():
@@ -1484,38 +1486,36 @@ def test_fold_short_frac_print():
 def test_print_factorials():
     assert mpp.doprint(factorial(x)) == '<mrow><mi>x</mi><mo>!</mo></mrow>'
     assert mpp.doprint(factorial(x + 1)) == \
-        '<mrow><mfenced><mrow><mi>x</mi><mo>+</mo><mn>1</mn></mrow></mfenced><mo>!</mo></mrow>'
+        '<mrow><mrow><mo>(</mo><mrow><mi>x</mi><mo>+</mo><mn>1</mn></mrow><mo>)</mo></mrow><mo>!</mo></mrow>'
     assert mpp.doprint(factorial2(x)) == '<mrow><mi>x</mi><mo>!!</mo></mrow>'
     assert mpp.doprint(factorial2(x + 1)) == \
-        '<mrow><mfenced><mrow><mi>x</mi><mo>+</mo><mn>1</mn></mrow></mfenced><mo>!!</mo></mrow>'
+        '<mrow><mrow><mo>(</mo><mrow><mi>x</mi><mo>+</mo><mn>1</mn></mrow><mo>)</mo></mrow><mo>!!</mo></mrow>'
     assert mpp.doprint(binomial(x, y)) == \
-        '<mfenced><mfrac linethickness="0"><mi>x</mi><mi>y</mi></mfrac></mfenced>'
+        '<mrow><mo>(</mo><mfrac linethickness="0"><mi>x</mi><mi>y</mi></mfrac><mo>)</mo></mrow>'
     assert mpp.doprint(binomial(4, x + y)) == \
-        '<mfenced><mfrac linethickness="0"><mn>4</mn><mrow><mi>x</mi>'\
-        '<mo>+</mo><mi>y</mi></mrow></mfrac></mfenced>'
+        '<mrow><mo>(</mo><mfrac linethickness="0"><mn>4</mn><mrow><mi>x</mi>'\
+        '<mo>+</mo><mi>y</mi></mrow></mfrac><mo>)</mo></mrow>'
 
 
 def test_print_floor():
     expr = floor(x)
     assert mathml(expr, printer='presentation') == \
-        '<mrow><mfenced close="&#8971;" open="&#8970;"><mi>x</mi></mfenced></mrow>'
+        '<mrow><mo>&#8970;</mo><mi>x</mi><mo>&#8971;</mo></mrow>'
 
 
 def test_print_ceiling():
     expr = ceiling(x)
     assert mathml(expr, printer='presentation') == \
-        '<mrow><mfenced close="&#8969;" open="&#8968;"><mi>x</mi></mfenced></mrow>'
+        '<mrow><mo>&#8968;</mo><mi>x</mi><mo>&#8969;</mo></mrow>'
 
 
 def test_print_Lambda():
     expr = Lambda(x, x+1)
     assert mathml(expr, printer='presentation') == \
-        '<mfenced><mrow><mi>x</mi><mo>&#x21A6;</mo><mrow><mi>x</mi><mo>+</mo>'\
-        '<mn>1</mn></mrow></mrow></mfenced>'
+        '<mrow><mo>(</mo><mi>x</mi><mo>&#x21A6;</mo><mrow><mi>x</mi><mo>+</mo><mn>1</mn></mrow><mo>)</mo></mrow>'
     expr = Lambda((x, y), x + y)
     assert mathml(expr, printer='presentation') == \
-        '<mfenced><mrow><mrow><mfenced><mi>x</mi><mi>y</mi></mfenced></mrow>'\
-        '<mo>&#x21A6;</mo><mrow><mi>x</mi><mo>+</mo><mi>y</mi></mrow></mrow></mfenced>'
+        '<mrow><mo>(</mo><mrow><mo>(</mo><mi>x</mi><mo>,</mo><mi>y</mi><mo>)</mo></mrow><mo>&#x21A6;</mo><mrow><mi>x</mi><mo>+</mo><mi>y</mi></mrow><mo>)</mo></mrow>'
 
 
 def test_print_conjugate():
@@ -1527,9 +1527,9 @@ def test_print_conjugate():
 
 def test_print_AccumBounds():
     a = Symbol('a', real=True)
-    assert mpp.doprint(AccumBounds(0, 1)) == '<mfenced close="&#10217;" open="&#10216;"><mn>0</mn><mn>1</mn></mfenced>'
-    assert mpp.doprint(AccumBounds(0, a)) == '<mfenced close="&#10217;" open="&#10216;"><mn>0</mn><mi>a</mi></mfenced>'
-    assert mpp.doprint(AccumBounds(a + 1, a + 2)) == '<mfenced close="&#10217;" open="&#10216;"><mrow><mi>a</mi><mo>+</mo><mn>1</mn></mrow><mrow><mi>a</mi><mo>+</mo><mn>2</mn></mrow></mfenced>'
+    assert mpp.doprint(AccumBounds(0, 1)) == '<mrow><mo>&#10216;</mo><mn>0</mn><mo>,</mo><mn>1</mn><mo>&#10217;</mo></mrow>'
+    assert mpp.doprint(AccumBounds(0, a)) == '<mrow><mo>&#10216;</mo><mn>0</mn><mo>,</mo><mi>a</mi><mo>&#10217;</mo></mrow>'
+    assert mpp.doprint(AccumBounds(a + 1, a + 2)) == '<mrow><mo>&#10216;</mo><mrow><mi>a</mi><mo>+</mo><mn>1</mn></mrow><mo>,</mo><mrow><mi>a</mi><mo>+</mo><mn>2</mn></mrow><mo>&#10217;</mo></mrow>'
 
 
 def test_print_Float():
@@ -1541,20 +1541,20 @@ def test_print_Float():
 
 
 def test_print_different_functions():
-    assert mpp.doprint(gamma(x)) == '<mrow><mi>&#x393;</mi><mfenced><mi>x</mi></mfenced></mrow>'
-    assert mpp.doprint(lowergamma(x, y)) == '<mrow><mi>&#x3B3;</mi><mfenced><mi>x</mi><mi>y</mi></mfenced></mrow>'
-    assert mpp.doprint(uppergamma(x, y)) == '<mrow><mi>&#x393;</mi><mfenced><mi>x</mi><mi>y</mi></mfenced></mrow>'
-    assert mpp.doprint(zeta(x)) == '<mrow><mi>&#x3B6;</mi><mfenced><mi>x</mi></mfenced></mrow>'
-    assert mpp.doprint(zeta(x, y)) == '<mrow><mi>&#x3B6;</mi><mfenced><mi>x</mi><mi>y</mi></mfenced></mrow>'
-    assert mpp.doprint(dirichlet_eta(x)) ==  '<mrow><mi>&#x3B7;</mi><mfenced><mi>x</mi></mfenced></mrow>'
-    assert mpp.doprint(elliptic_k(x)) == '<mrow><mi>&#x39A;</mi><mfenced><mi>x</mi></mfenced></mrow>'
-    assert mpp.doprint(totient(x)) == '<mrow><mi>&#x3D5;</mi><mfenced><mi>x</mi></mfenced></mrow>'
-    assert mpp.doprint(reduced_totient(x)) == '<mrow><mi>&#x3BB;</mi><mfenced><mi>x</mi></mfenced></mrow>'
-    assert mpp.doprint(primenu(x)) == '<mrow><mi>&#x3BD;</mi><mfenced><mi>x</mi></mfenced></mrow>'
-    assert mpp.doprint(primeomega(x)) == '<mrow><mi>&#x3A9;</mi><mfenced><mi>x</mi></mfenced></mrow>'
-    assert mpp.doprint(fresnels(x)) == '<mrow><mi>S</mi><mfenced><mi>x</mi></mfenced></mrow>'
-    assert mpp.doprint(fresnelc(x)) ==  '<mrow><mi>C</mi><mfenced><mi>x</mi></mfenced></mrow>'
-    assert mpp.doprint(Heaviside(x)) == '<mrow><mi>&#x398;</mi><mfenced><mi>x</mi><mfrac><mn>1</mn><mn>2</mn></mfrac></mfenced></mrow>'
+    assert mpp.doprint(gamma(x)) == '<mrow><mi>&#x393;</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
+    assert mpp.doprint(lowergamma(x, y)) == '<mrow><mi>&#x3B3;</mi><mrow><mo>(</mo><mi>x</mi><mo>,</mo><mi>y</mi><mo>)</mo></mrow></mrow>'
+    assert mpp.doprint(uppergamma(x, y)) == '<mrow><mi>&#x393;</mi><mrow><mo>(</mo><mi>x</mi><mo>,</mo><mi>y</mi><mo>)</mo></mrow></mrow>'
+    assert mpp.doprint(zeta(x)) == '<mrow><mi>&#x3B6;</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
+    assert mpp.doprint(zeta(x, y)) == '<mrow><mi>&#x3B6;</mi><mrow><mo>(</mo><mi>x</mi><mo>,</mo><mi>y</mi><mo>)</mo></mrow></mrow>'
+    assert mpp.doprint(dirichlet_eta(x)) ==  '<mrow><mi>&#x3B7;</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
+    assert mpp.doprint(elliptic_k(x)) == '<mrow><mi>&#x39A;</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
+    assert mpp.doprint(totient(x)) == '<mrow><mi>&#x3D5;</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
+    assert mpp.doprint(reduced_totient(x)) == '<mrow><mi>&#x3BB;</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
+    assert mpp.doprint(primenu(x)) == '<mrow><mi>&#x3BD;</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
+    assert mpp.doprint(primeomega(x)) == '<mrow><mi>&#x3A9;</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
+    assert mpp.doprint(fresnels(x)) == '<mrow><mi>S</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
+    assert mpp.doprint(fresnelc(x)) ==  '<mrow><mi>C</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
+    assert mpp.doprint(Heaviside(x)) == '<mrow><mi>&#x398;</mi><mrow><mo>(</mo><mi>x</mi><mo>,</mo><mfrac><mn>1</mn><mn>2</mn></mfrac><mo>)</mo></mrow></mrow>'
 
 
 def test_mathml_builtins():
@@ -1565,22 +1565,21 @@ def test_mathml_builtins():
 
 def test_mathml_Range():
     assert mpp.doprint(Range(1, 51)) == \
-        '<mfenced close="}" open="{"><mn>1</mn><mn>2</mn><mi>&#8230;</mi><mn>50</mn></mfenced>'
+        '<mrow><mo>{</mo><mn>1</mn><mo>,</mo><mn>2</mn><mo>,</mo><mi>&#8230;</mi><mo>,</mo><mn>50</mn><mo>}</mo></mrow>'
     assert mpp.doprint(Range(1, 4)) == \
-        '<mfenced close="}" open="{"><mn>1</mn><mn>2</mn><mn>3</mn></mfenced>'
+        '<mrow><mo>{</mo><mn>1</mn><mo>,</mo><mn>2</mn><mo>,</mo><mn>3</mn><mo>}</mo></mrow>'
     assert mpp.doprint(Range(0, 3, 1)) == \
-        '<mfenced close="}" open="{"><mn>0</mn><mn>1</mn><mn>2</mn></mfenced>'
+        '<mrow><mo>{</mo><mn>0</mn><mo>,</mo><mn>1</mn><mo>,</mo><mn>2</mn><mo>}</mo></mrow>'
     assert mpp.doprint(Range(0, 30, 1)) == \
-        '<mfenced close="}" open="{"><mn>0</mn><mn>1</mn><mi>&#8230;</mi><mn>29</mn></mfenced>'
+        '<mrow><mo>{</mo><mn>0</mn><mo>,</mo><mn>1</mn><mo>,</mo><mi>&#8230;</mi><mo>,</mo><mn>29</mn><mo>}</mo></mrow>'
     assert mpp.doprint(Range(30, 1, -1)) == \
-        '<mfenced close="}" open="{"><mn>30</mn><mn>29</mn><mi>&#8230;</mi>'\
-        '<mn>2</mn></mfenced>'
+        '<mrow><mo>{</mo><mn>30</mn><mo>,</mo><mn>29</mn><mo>,</mo><mi>&#8230;</mi><mo>,</mo><mn>2</mn><mo>}</mo></mrow>'
     assert mpp.doprint(Range(0, oo, 2)) == \
-        '<mfenced close="}" open="{"><mn>0</mn><mn>2</mn><mi>&#8230;</mi></mfenced>'
+        '<mrow><mo>{</mo><mn>0</mn><mo>,</mo><mn>2</mn><mo>,</mo><mi>&#8230;</mi><mo>}</mo></mrow>'
     assert mpp.doprint(Range(oo, -2, -2)) == \
-        '<mfenced close="}" open="{"><mi>&#8230;</mi><mn>2</mn><mn>0</mn></mfenced>'
+        '<mrow><mo>{</mo><mi>&#8230;</mi><mo>,</mo><mn>2</mn><mo>,</mo><mn>0</mn><mo>}</mo></mrow>'
     assert mpp.doprint(Range(-2, -oo, -1)) == \
-        '<mfenced close="}" open="{"><mn>-2</mn><mn>-3</mn><mi>&#8230;</mi></mfenced>'
+        '<mrow><mo>{</mo><mn>-2</mn><mo>,</mo><mn>-3</mn><mo>,</mo><mi>&#8230;</mi><mo>}</mo></mrow>'
 
 
 def test_print_exp():
@@ -1592,15 +1591,13 @@ def test_print_exp():
 
 def test_print_MinMax():
     assert mpp.doprint(Min(x, y)) == \
-        '<mrow><mo>min</mo><mfenced><mi>x</mi><mi>y</mi></mfenced></mrow>'
+        '<mrow><mo>min</mo><mrow><mo>(</mo><mi>x</mi><mo>,</mo><mi>y</mi><mo>)</mo></mrow></mrow>'
     assert mpp.doprint(Min(x, 2, x**3)) == \
-        '<mrow><mo>min</mo><mfenced><mn>2</mn><mi>x</mi><msup><mi>x</mi>'\
-        '<mn>3</mn></msup></mfenced></mrow>'
+        '<mrow><mo>min</mo><mrow><mo>(</mo><mn>2</mn><mo>,</mo><mi>x</mi><mo>,</mo><msup><mi>x</mi><mn>3</mn></msup><mo>)</mo></mrow></mrow>'
     assert mpp.doprint(Max(x, y)) == \
-        '<mrow><mo>max</mo><mfenced><mi>x</mi><mi>y</mi></mfenced></mrow>'
+        '<mrow><mo>max</mo><mrow><mo>(</mo><mi>x</mi><mo>,</mo><mi>y</mi><mo>)</mo></mrow></mrow>'
     assert mpp.doprint(Max(x, 2, x**3)) == \
-        '<mrow><mo>max</mo><mfenced><mn>2</mn><mi>x</mi><msup><mi>x</mi>'\
-        '<mn>3</mn></msup></mfenced></mrow>'
+        '<mrow><mo>max</mo><mrow><mo>(</mo><mn>2</mn><mo>,</mo><mi>x</mi><mo>,</mo><msup><mi>x</mi><mn>3</mn></msup><mo>)</mo></mrow></mrow>'
 
 
 def test_mathml_presentation_numbers():
@@ -1620,33 +1617,32 @@ def test_mathml_presentation_numbers():
     assert mathml(tribonacci(n), printer='presentation') == \
         '<msub><mi>T</mi><mi>n</mi></msub>'
     assert mathml(bernoulli(n, x), printer='presentation') == \
-        '<mrow><msub><mi>B</mi><mi>n</mi></msub><mfenced><mi>x</mi></mfenced></mrow>'
-    assert mathml(bell(n, x), printer='presentation') == \
-        '<mrow><msub><mi>B</mi><mi>n</mi></msub><mfenced><mi>x</mi></mfenced></mrow>'
+        mathml(bell(n, x), printer='presentation') == \
+        '<mrow><msub><mi>B</mi><mi>n</mi></msub><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
     assert mathml(euler(n, x), printer='presentation') == \
-        '<mrow><msub><mi>E</mi><mi>n</mi></msub><mfenced><mi>x</mi></mfenced></mrow>'
+        '<mrow><msub><mi>E</mi><mi>n</mi></msub><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
     assert mathml(fibonacci(n, x), printer='presentation') == \
-        '<mrow><msub><mi>F</mi><mi>n</mi></msub><mfenced><mi>x</mi></mfenced></mrow>'
+        '<mrow><msub><mi>F</mi><mi>n</mi></msub><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
     assert mathml(tribonacci(n, x), printer='presentation') == \
-        '<mrow><msub><mi>T</mi><mi>n</mi></msub><mfenced><mi>x</mi></mfenced></mrow>'
+        '<mrow><msub><mi>T</mi><mi>n</mi></msub><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
 
 
 def test_mathml_presentation_mathieu():
     assert mathml(mathieuc(x, y, z), printer='presentation') == \
-        '<mrow><mi>C</mi><mfenced><mi>x</mi><mi>y</mi><mi>z</mi></mfenced></mrow>'
+        '<mrow><mi>C</mi><mrow><mo>(</mo><mi>x</mi><mo>,</mo><mi>y</mi><mo>,</mo><mi>z</mi><mo>)</mo></mrow></mrow>'
     assert mathml(mathieus(x, y, z), printer='presentation') == \
-        '<mrow><mi>S</mi><mfenced><mi>x</mi><mi>y</mi><mi>z</mi></mfenced></mrow>'
+        '<mrow><mi>S</mi><mrow><mo>(</mo><mi>x</mi><mo>,</mo><mi>y</mi><mo>,</mo><mi>z</mi><mo>)</mo></mrow></mrow>'
     assert mathml(mathieucprime(x, y, z), printer='presentation') == \
-        '<mrow><mi>C&#x2032;</mi><mfenced><mi>x</mi><mi>y</mi><mi>z</mi></mfenced></mrow>'
+        '<mrow><mi>C&#x2032;</mi><mrow><mo>(</mo><mi>x</mi><mo>,</mo><mi>y</mi><mo>,</mo><mi>z</mi><mo>)</mo></mrow></mrow>'
     assert mathml(mathieusprime(x, y, z), printer='presentation') == \
-        '<mrow><mi>S&#x2032;</mi><mfenced><mi>x</mi><mi>y</mi><mi>z</mi></mfenced></mrow>'
+        '<mrow><mi>S&#x2032;</mi><mrow><mo>(</mo><mi>x</mi><mo>,</mo><mi>y</mi><mo>,</mo><mi>z</mi><mo>)</mo></mrow></mrow>'
 
 
 def test_mathml_presentation_stieltjes():
     assert mathml(stieltjes(n), printer='presentation') == \
          '<msub><mi>&#x03B3;</mi><mi>n</mi></msub>'
     assert mathml(stieltjes(n, x), printer='presentation') == \
-         '<mrow><msub><mi>&#x03B3;</mi><mi>n</mi></msub><mfenced><mi>x</mi></mfenced></mrow>'
+         '<mrow><msub><mi>&#x03B3;</mi><mi>n</mi></msub><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
 
 
 def test_print_matrix_symbol():
@@ -1675,9 +1671,9 @@ def test_print_hadamard():
 
     assert mathml(HadamardProduct(X, Y)*Y, printer="presentation") == \
         '<mrow>' \
-        '<mfenced>' \
+        '<mrow><mo>(</mo>' \
         '<mrow><mi>X</mi><mo>&#x2218;</mo><mi>Y</mi></mrow>' \
-        '</mfenced>' \
+        '<mo>)</mo></mrow>' \
         '<mo>&InvisibleTimes;</mo><mi>Y</mi>' \
         '</mrow>'
 
@@ -1691,9 +1687,9 @@ def test_print_hadamard():
     assert mathml(
         Transpose(HadamardProduct(X, Y)), printer="presentation") == \
             '<msup>' \
-            '<mfenced>' \
+            '<mrow><mo>(</mo>' \
             '<mrow><mi>X</mi><mo>&#x2218;</mo><mi>Y</mi></mrow>' \
-            '</mfenced>' \
+            '<mo>)</mo></mrow>' \
             '<mo>T</mo>' \
             '</msup>'
 
@@ -1708,7 +1704,7 @@ def test_print_IndexedBase():
     assert mathml(IndexedBase(a)[b], printer='presentation') == \
         '<msub><mi>a</mi><mi>b</mi></msub>'
     assert mathml(IndexedBase(a)[b, c, d], printer='presentation') == \
-        '<msub><mi>a</mi><mfenced><mi>b</mi><mi>c</mi><mi>d</mi></mfenced></msub>'
+        '<msub><mi>a</mi><mrow><mo>(</mo><mi>b</mi><mo>,</mo><mi>c</mi><mo>,</mo><mi>d</mi><mo>)</mo></mrow></msub>'
     assert mathml(IndexedBase(a)[b]*IndexedBase(c)[d]*IndexedBase(e),
                   printer='presentation') == \
                   '<mrow><msub><mi>a</mi><mi>b</mi></msub><mo>&InvisibleTimes;'\
@@ -1720,113 +1716,113 @@ def test_print_Indexed():
     assert mathml(IndexedBase(a/b), printer='presentation') == \
         '<mrow><mfrac><mi>a</mi><mi>b</mi></mfrac></mrow>'
     assert mathml(IndexedBase((a, b)), printer='presentation') == \
-        '<mrow><mfenced><mi>a</mi><mi>b</mi></mfenced></mrow>'
+        '<mrow><mo>(</mo><mi>a</mi><mo>,</mo><mi>b</mi><mo>)</mo></mrow>'
 
 def test_print_MatrixElement():
     i, j = symbols('i j')
     A = MatrixSymbol('A', i, j)
     assert mathml(A[0,0],printer = 'presentation') == \
-        '<msub><mi>A</mi><mfenced close="" open=""><mn>0</mn><mn>0</mn></mfenced></msub>'
+        '<msub><mi>A</mi><mrow><mn>0</mn><mo>,</mo><mn>0</mn></mrow></msub>'
     assert mathml(A[i,j], printer = 'presentation') == \
-        '<msub><mi>A</mi><mfenced close="" open=""><mi>i</mi><mi>j</mi></mfenced></msub>'
+        '<msub><mi>A</mi><mrow><mi>i</mi><mo>,</mo><mi>j</mi></mrow></msub>'
     assert mathml(A[i*j,0], printer = 'presentation') == \
-        '<msub><mi>A</mi><mfenced close="" open=""><mrow><mi>i</mi><mo>&InvisibleTimes;</mo><mi>j</mi></mrow><mn>0</mn></mfenced></msub>'
+        '<msub><mi>A</mi><mrow><mrow><mi>i</mi><mo>&InvisibleTimes;</mo><mi>j</mi></mrow><mo>,</mo><mn>0</mn></mrow></msub>'
 
 
 def test_print_Vector():
     ACS = CoordSys3D('A')
     assert mathml(Cross(ACS.i, ACS.j*ACS.x*3 + ACS.k), printer='presentation') == \
         '<mrow><msub><mover><mi mathvariant="bold">i</mi><mo>^</mo></mover>'\
-        '<mi mathvariant="bold">A</mi></msub><mo>&#xD7;</mo><mfenced><mrow>'\
-        '<mfenced><mrow><mn>3</mn><mo>&InvisibleTimes;</mo><msub>'\
+        '<mi mathvariant="bold">A</mi></msub><mo>&#xD7;</mo><mrow><mo>(</mo><mrow>'\
+        '<mrow><mo>(</mo><mrow><mn>3</mn><mo>&InvisibleTimes;</mo><msub>'\
         '<mi mathvariant="bold">x</mi><mi mathvariant="bold">A</mi></msub>'\
-        '</mrow></mfenced><mo>&InvisibleTimes;</mo><msub><mover>'\
+        '</mrow><mo>)</mo></mrow><mo>&InvisibleTimes;</mo><msub><mover>'\
         '<mi mathvariant="bold">j</mi><mo>^</mo></mover>'\
         '<mi mathvariant="bold">A</mi></msub><mo>+</mo><msub><mover>'\
         '<mi mathvariant="bold">k</mi><mo>^</mo></mover><mi mathvariant="bold">'\
-        'A</mi></msub></mrow></mfenced></mrow>'
+        'A</mi></msub></mrow><mo>)</mo></mrow></mrow>'
     assert mathml(Cross(ACS.i, ACS.j), printer='presentation') == \
         '<mrow><msub><mover><mi mathvariant="bold">i</mi><mo>^</mo></mover>'\
         '<mi mathvariant="bold">A</mi></msub><mo>&#xD7;</mo><msub><mover>'\
         '<mi mathvariant="bold">j</mi><mo>^</mo></mover>'\
         '<mi mathvariant="bold">A</mi></msub></mrow>'
     assert mathml(x*Cross(ACS.i, ACS.j), printer='presentation') == \
-        '<mrow><mi>x</mi><mo>&InvisibleTimes;</mo><mfenced><mrow><msub><mover>'\
+        '<mrow><mi>x</mi><mo>&InvisibleTimes;</mo><mrow><mo>(</mo><mrow><msub><mover>'\
         '<mi mathvariant="bold">i</mi><mo>^</mo></mover>'\
         '<mi mathvariant="bold">A</mi></msub><mo>&#xD7;</mo><msub><mover>'\
         '<mi mathvariant="bold">j</mi><mo>^</mo></mover>'\
-        '<mi mathvariant="bold">A</mi></msub></mrow></mfenced></mrow>'
+        '<mi mathvariant="bold">A</mi></msub></mrow><mo>)</mo></mrow></mrow>'
     assert mathml(Cross(x*ACS.i, ACS.j), printer='presentation') == \
         '<mrow><mo>-</mo><mrow><msub><mover><mi mathvariant="bold">j</mi>'\
         '<mo>^</mo></mover><mi mathvariant="bold">A</mi></msub>'\
-        '<mo>&#xD7;</mo><mfenced><mrow><mfenced><mi>x</mi></mfenced>'\
+        '<mo>&#xD7;</mo><mrow><mo>(</mo><mrow><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow>'\
         '<mo>&InvisibleTimes;</mo><msub><mover><mi mathvariant="bold">i</mi>'\
         '<mo>^</mo></mover><mi mathvariant="bold">A</mi></msub></mrow>'\
-        '</mfenced></mrow></mrow>'
+        '<mo>)</mo></mrow></mrow></mrow>'
     assert mathml(Curl(3*ACS.x*ACS.j), printer='presentation') == \
-        '<mrow><mo>&#x2207;</mo><mo>&#xD7;</mo><mfenced><mrow><mfenced><mrow>'\
-        '<mn>3</mn><mo>&InvisibleTimes;</mo><msub>'\
-        '<mi mathvariant="bold">x</mi><mi mathvariant="bold">A</mi></msub>'\
-        '</mrow></mfenced><mo>&InvisibleTimes;</mo><msub><mover>'\
-        '<mi mathvariant="bold">j</mi><mo>^</mo></mover>'\
-        '<mi mathvariant="bold">A</mi></msub></mrow></mfenced></mrow>'
+        '<mrow><mo>&#x2207;</mo><mo>&#xD7;</mo><mrow><mo>(</mo><mrow><mrow><mo>(</mo>'\
+        '<mrow><mn>3</mn><mo>&InvisibleTimes;</mo><msub><mi mathvariant="bold">x</mi>'\
+        '<mi mathvariant="bold">A</mi></msub></mrow><mo>)</mo></mrow><mo>&InvisibleTimes;</mo>'\
+        '<msub><mover><mi mathvariant="bold">j</mi><mo>^</mo></mover>'\
+        '<mi mathvariant="bold">A</mi></msub></mrow><mo>)</mo></mrow></mrow>'
     assert mathml(Curl(3*x*ACS.x*ACS.j), printer='presentation') == \
-        '<mrow><mo>&#x2207;</mo><mo>&#xD7;</mo><mfenced><mrow><mfenced><mrow>'\
+        '<mrow><mo>&#x2207;</mo><mo>&#xD7;</mo><mrow><mo>(</mo><mrow><mrow><mo>(</mo><mrow>'\
         '<mn>3</mn><mo>&InvisibleTimes;</mo><msub><mi mathvariant="bold">x'\
         '</mi><mi mathvariant="bold">A</mi></msub><mo>&InvisibleTimes;</mo>'\
-        '<mi>x</mi></mrow></mfenced><mo>&InvisibleTimes;</mo><msub><mover>'\
+        '<mi>x</mi></mrow><mo>)</mo></mrow><mo>&InvisibleTimes;</mo><msub><mover>'\
         '<mi mathvariant="bold">j</mi><mo>^</mo></mover>'\
-        '<mi mathvariant="bold">A</mi></msub></mrow></mfenced></mrow>'
+        '<mi mathvariant="bold">A</mi></msub></mrow><mo>)</mo></mrow></mrow>'
     assert mathml(x*Curl(3*ACS.x*ACS.j), printer='presentation') == \
-        '<mrow><mi>x</mi><mo>&InvisibleTimes;</mo><mfenced><mrow><mo>&#x2207;</mo>'\
-        '<mo>&#xD7;</mo><mfenced><mrow><mfenced><mrow><mn>3</mn>'\
+        '<mrow><mi>x</mi><mo>&InvisibleTimes;</mo><mrow><mo>(</mo><mrow><mo>&#x2207;</mo>'\
+        '<mo>&#xD7;</mo><mrow><mo>(</mo><mrow><mrow><mo>(</mo><mrow><mn>3</mn>'\
         '<mo>&InvisibleTimes;</mo><msub><mi mathvariant="bold">x</mi>'\
-        '<mi mathvariant="bold">A</mi></msub></mrow></mfenced>'\
+        '<mi mathvariant="bold">A</mi></msub></mrow><mo>)</mo></mrow>'\
         '<mo>&InvisibleTimes;</mo><msub><mover><mi mathvariant="bold">j</mi>'\
-        '<mo>^</mo></mover><mi mathvariant="bold">A</mi></msub></mrow>'\
-        '</mfenced></mrow></mfenced></mrow>'
+        '<mo>^</mo></mover><mi mathvariant="bold">A</mi></msub></mrow><mo>)</mo>'\
+        '</mrow></mrow><mo>)</mo></mrow></mrow>'
     assert mathml(Curl(3*x*ACS.x*ACS.j + ACS.i), printer='presentation') == \
-        '<mrow><mo>&#x2207;</mo><mo>&#xD7;</mo><mfenced><mrow><msub><mover>'\
+        '<mrow><mo>&#x2207;</mo><mo>&#xD7;</mo><mrow><mo>(</mo><mrow><msub><mover>'\
         '<mi mathvariant="bold">i</mi><mo>^</mo></mover>'\
-        '<mi mathvariant="bold">A</mi></msub><mo>+</mo><mfenced><mrow>'\
+        '<mi mathvariant="bold">A</mi></msub><mo>+</mo><mrow><mo>(</mo><mrow>'\
         '<mn>3</mn><mo>&InvisibleTimes;</mo><msub><mi mathvariant="bold">x'\
         '</mi><mi mathvariant="bold">A</mi></msub><mo>&InvisibleTimes;</mo>'\
-        '<mi>x</mi></mrow></mfenced><mo>&InvisibleTimes;</mo><msub><mover>'\
+        '<mi>x</mi></mrow><mo>)</mo></mrow><mo>&InvisibleTimes;</mo><msub><mover>'\
         '<mi mathvariant="bold">j</mi><mo>^</mo></mover>'\
-        '<mi mathvariant="bold">A</mi></msub></mrow></mfenced></mrow>'
+        '<mi mathvariant="bold">A</mi></msub></mrow><mo>)</mo></mrow></mrow>'
     assert mathml(Divergence(3*ACS.x*ACS.j), printer='presentation') == \
-        '<mrow><mo>&#x2207;</mo><mo>&#xB7;</mo><mfenced><mrow><mfenced><mrow>'\
-        '<mn>3</mn><mo>&InvisibleTimes;</mo><msub><mi mathvariant="bold">x'\
-        '</mi><mi mathvariant="bold">A</mi></msub></mrow></mfenced>'\
+        '<mrow><mo>&#x2207;</mo><mo>&#xB7;</mo><mrow><mo>(</mo><mrow><mrow><mo>(</mo>'\
+        '<mrow><mn>3</mn><mo>&InvisibleTimes;</mo><msub><mi mathvariant="bold">x'\
+        '</mi><mi mathvariant="bold">A</mi></msub></mrow><mo>)</mo></mrow>'\
         '<mo>&InvisibleTimes;</mo><msub><mover><mi mathvariant="bold">j</mi>'\
-        '<mo>^</mo></mover><mi mathvariant="bold">A</mi></msub></mrow></mfenced></mrow>'
+        '<mo>^</mo></mover><mi mathvariant="bold">A</mi></msub></mrow><mo>)</mo></mrow></mrow>'
     assert mathml(x*Divergence(3*ACS.x*ACS.j), printer='presentation') == \
-        '<mrow><mi>x</mi><mo>&InvisibleTimes;</mo><mfenced><mrow><mo>&#x2207;</mo>'\
-        '<mo>&#xB7;</mo><mfenced><mrow><mfenced><mrow><mn>3</mn>'\
+        '<mrow><mi>x</mi><mo>&InvisibleTimes;</mo><mrow><mo>(</mo><mrow><mo>&#x2207;</mo>'\
+        '<mo>&#xB7;</mo><mrow><mo>(</mo><mrow><mrow><mo>(</mo><mrow><mn>3</mn>'\
         '<mo>&InvisibleTimes;</mo><msub><mi mathvariant="bold">x</mi>'\
-        '<mi mathvariant="bold">A</mi></msub></mrow></mfenced>'\
+        '<mi mathvariant="bold">A</mi></msub></mrow><mo>)</mo></mrow>'\
         '<mo>&InvisibleTimes;</mo><msub><mover><mi mathvariant="bold">j</mi>'\
         '<mo>^</mo></mover><mi mathvariant="bold">A</mi></msub></mrow>'\
-        '</mfenced></mrow></mfenced></mrow>'
+        '<mo>)</mo></mrow></mrow><mo>)</mo></mrow></mrow>'
     assert mathml(Divergence(3*x*ACS.x*ACS.j + ACS.i), printer='presentation') == \
-        '<mrow><mo>&#x2207;</mo><mo>&#xB7;</mo><mfenced><mrow><msub><mover>'\
+        '<mrow><mo>&#x2207;</mo><mo>&#xB7;</mo><mrow><mo>(</mo><mrow><msub><mover>'\
         '<mi mathvariant="bold">i</mi><mo>^</mo></mover>'\
-        '<mi mathvariant="bold">A</mi></msub><mo>+</mo><mfenced><mrow>'\
+        '<mi mathvariant="bold">A</mi></msub><mo>+</mo><mrow><mo>(</mo><mrow>'\
         '<mn>3</mn><mo>&InvisibleTimes;</mo><msub>'\
         '<mi mathvariant="bold">x</mi><mi mathvariant="bold">A</mi></msub>'\
-        '<mo>&InvisibleTimes;</mo><mi>x</mi></mrow></mfenced>'\
+        '<mo>&InvisibleTimes;</mo><mi>x</mi></mrow><mo>)</mo></mrow>'\
         '<mo>&InvisibleTimes;</mo><msub><mover><mi mathvariant="bold">j</mi>'\
-        '<mo>^</mo></mover><mi mathvariant="bold">A</mi></msub></mrow></mfenced></mrow>'
+        '<mo>^</mo></mover><mi mathvariant="bold">A</mi></msub></mrow>'\
+        '<mo>)</mo></mrow></mrow>'
     assert mathml(Dot(ACS.i, ACS.j*ACS.x*3+ACS.k), printer='presentation') == \
         '<mrow><msub><mover><mi mathvariant="bold">i</mi><mo>^</mo></mover>'\
-        '<mi mathvariant="bold">A</mi></msub><mo>&#xB7;</mo><mfenced><mrow>'\
-        '<mfenced><mrow><mn>3</mn><mo>&InvisibleTimes;</mo><msub>'\
+        '<mi mathvariant="bold">A</mi></msub><mo>&#xB7;</mo><mrow><mo>(</mo><mrow>'\
+        '<mrow><mo>(</mo><mrow><mn>3</mn><mo>&InvisibleTimes;</mo><msub>'\
         '<mi mathvariant="bold">x</mi><mi mathvariant="bold">A</mi></msub>'\
-        '</mrow></mfenced><mo>&InvisibleTimes;</mo><msub><mover>'\
+        '</mrow><mo>)</mo></mrow><mo>&InvisibleTimes;</mo><msub><mover>'\
         '<mi mathvariant="bold">j</mi><mo>^</mo></mover>'\
         '<mi mathvariant="bold">A</mi></msub><mo>+</mo><msub><mover>'\
         '<mi mathvariant="bold">k</mi><mo>^</mo></mover>'\
-        '<mi mathvariant="bold">A</mi></msub></mrow></mfenced></mrow>'
+        '<mi mathvariant="bold">A</mi></msub></mrow><mo>)</mo></mrow></mrow>'
     assert mathml(Dot(ACS.i, ACS.j), printer='presentation') == \
         '<mrow><msub><mover><mi mathvariant="bold">i</mi><mo>^</mo></mover>'\
         '<mi mathvariant="bold">A</mi></msub><mo>&#xB7;</mo><msub><mover>'\
@@ -1834,32 +1830,32 @@ def test_print_Vector():
         '<mi mathvariant="bold">A</mi></msub></mrow>'
     assert mathml(Dot(x*ACS.i, ACS.j), printer='presentation') == \
         '<mrow><msub><mover><mi mathvariant="bold">j</mi><mo>^</mo></mover>'\
-        '<mi mathvariant="bold">A</mi></msub><mo>&#xB7;</mo><mfenced><mrow>'\
-        '<mfenced><mi>x</mi></mfenced><mo>&InvisibleTimes;</mo><msub><mover>'\
+        '<mi mathvariant="bold">A</mi></msub><mo>&#xB7;</mo><mrow><mo>(</mo><mrow>'\
+        '<mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow><mo>&InvisibleTimes;</mo><msub><mover>'\
         '<mi mathvariant="bold">i</mi><mo>^</mo></mover>'\
-        '<mi mathvariant="bold">A</mi></msub></mrow></mfenced></mrow>'
+        '<mi mathvariant="bold">A</mi></msub></mrow><mo>)</mo></mrow></mrow>'
     assert mathml(x*Dot(ACS.i, ACS.j), printer='presentation') == \
-        '<mrow><mi>x</mi><mo>&InvisibleTimes;</mo><mfenced><mrow><msub><mover>'\
+        '<mrow><mi>x</mi><mo>&InvisibleTimes;</mo><mrow><mo>(</mo><mrow><msub><mover>'\
         '<mi mathvariant="bold">i</mi><mo>^</mo></mover>'\
         '<mi mathvariant="bold">A</mi></msub><mo>&#xB7;</mo><msub><mover>'\
         '<mi mathvariant="bold">j</mi><mo>^</mo></mover>'\
-        '<mi mathvariant="bold">A</mi></msub></mrow></mfenced></mrow>'
+        '<mi mathvariant="bold">A</mi></msub></mrow><mo>)</mo></mrow></mrow>'
     assert mathml(Gradient(ACS.x), printer='presentation') == \
         '<mrow><mo>&#x2207;</mo><msub><mi mathvariant="bold">x</mi>'\
         '<mi mathvariant="bold">A</mi></msub></mrow>'
     assert mathml(Gradient(ACS.x + 3*ACS.y), printer='presentation') == \
-        '<mrow><mo>&#x2207;</mo><mfenced><mrow><msub><mi mathvariant="bold">'\
+        '<mrow><mo>&#x2207;</mo><mrow><mo>(</mo><mrow><msub><mi mathvariant="bold">'\
         'x</mi><mi mathvariant="bold">A</mi></msub><mo>+</mo><mrow><mn>3</mn>'\
         '<mo>&InvisibleTimes;</mo><msub><mi mathvariant="bold">y</mi>'\
-        '<mi mathvariant="bold">A</mi></msub></mrow></mrow></mfenced></mrow>'
+        '<mi mathvariant="bold">A</mi></msub></mrow></mrow><mo>)</mo></mrow></mrow>'
     assert mathml(x*Gradient(ACS.x), printer='presentation') == \
-        '<mrow><mi>x</mi><mo>&InvisibleTimes;</mo><mfenced><mrow><mo>&#x2207;</mo>'\
+        '<mrow><mi>x</mi><mo>&InvisibleTimes;</mo><mrow><mo>(</mo><mrow><mo>&#x2207;</mo>'\
         '<msub><mi mathvariant="bold">x</mi><mi mathvariant="bold">A</mi>'\
-        '</msub></mrow></mfenced></mrow>'
+        '</msub></mrow><mo>)</mo></mrow></mrow>'
     assert mathml(Gradient(x*ACS.x), printer='presentation') == \
-        '<mrow><mo>&#x2207;</mo><mfenced><mrow><msub><mi mathvariant="bold">'\
+        '<mrow><mo>&#x2207;</mo><mrow><mo>(</mo><mrow><msub><mi mathvariant="bold">'\
         'x</mi><mi mathvariant="bold">A</mi></msub><mo>&InvisibleTimes;</mo>'\
-        '<mi>x</mi></mrow></mfenced></mrow>'
+        '<mi>x</mi></mrow><mo>)</mo></mrow></mrow>'
     assert mathml(Cross(ACS.x, ACS.z) + Cross(ACS.z, ACS.x), printer='presentation') == \
         '<mover><mi mathvariant="bold">0</mi><mo>^</mo></mover>'
     assert mathml(Cross(ACS.z, ACS.x), printer='presentation') == \
@@ -1870,105 +1866,98 @@ def test_print_Vector():
         '<mrow><mo>&#x2206;</mo><msub><mi mathvariant="bold">x</mi>'\
         '<mi mathvariant="bold">A</mi></msub></mrow>'
     assert mathml(Laplacian(ACS.x + 3*ACS.y), printer='presentation') == \
-        '<mrow><mo>&#x2206;</mo><mfenced><mrow><msub><mi mathvariant="bold">'\
+        '<mrow><mo>&#x2206;</mo><mrow><mo>(</mo><mrow><msub><mi mathvariant="bold">'\
         'x</mi><mi mathvariant="bold">A</mi></msub><mo>+</mo><mrow><mn>3</mn>'\
         '<mo>&InvisibleTimes;</mo><msub><mi mathvariant="bold">y</mi>'\
-        '<mi mathvariant="bold">A</mi></msub></mrow></mrow></mfenced></mrow>'
+        '<mi mathvariant="bold">A</mi></msub></mrow></mrow><mo>)</mo></mrow></mrow>'
     assert mathml(x*Laplacian(ACS.x), printer='presentation') == \
-        '<mrow><mi>x</mi><mo>&InvisibleTimes;</mo><mfenced><mrow><mo>&#x2206;</mo>'\
+        '<mrow><mi>x</mi><mo>&InvisibleTimes;</mo><mrow><mo>(</mo><mrow><mo>&#x2206;</mo>'\
         '<msub><mi mathvariant="bold">x</mi><mi mathvariant="bold">A</mi>'\
-        '</msub></mrow></mfenced></mrow>'
+        '</msub></mrow><mo>)</mo></mrow></mrow>'
     assert mathml(Laplacian(x*ACS.x), printer='presentation') == \
-        '<mrow><mo>&#x2206;</mo><mfenced><mrow><msub><mi mathvariant="bold">'\
+        '<mrow><mo>&#x2206;</mo><mrow><mo>(</mo><mrow><msub><mi mathvariant="bold">'\
         'x</mi><mi mathvariant="bold">A</mi></msub><mo>&InvisibleTimes;</mo>'\
-        '<mi>x</mi></mrow></mfenced></mrow>'
+        '<mi>x</mi></mrow><mo>)</mo></mrow></mrow>'
 
 def test_print_elliptic_f():
     assert mathml(elliptic_f(x, y), printer = 'presentation') == \
-        '<mrow><mi>&#x1d5a5;</mi><mfenced separators="|"><mi>x</mi><mi>y</mi></mfenced></mrow>'
+        '<mrow><mi>&#x1d5a5;</mi><mrow><mo>(</mo><mi>x</mi><mo>|</mo><mi>y</mi><mo>)</mo></mrow></mrow>'
     assert mathml(elliptic_f(x/y, y), printer = 'presentation') == \
-        '<mrow><mi>&#x1d5a5;</mi><mfenced separators="|"><mrow><mfrac><mi>x</mi><mi>y</mi></mfrac></mrow><mi>y</mi></mfenced></mrow>'
+        '<mrow><mi>&#x1d5a5;</mi><mrow><mo>(</mo><mrow><mfrac><mi>x</mi><mi>y</mi></mfrac></mrow><mo>|</mo><mi>y</mi><mo>)</mo></mrow></mrow>'
 
 def test_print_elliptic_e():
     assert mathml(elliptic_e(x), printer = 'presentation') == \
-        '<mrow><mi>&#x1d5a4;</mi><mfenced separators="|"><mi>x</mi></mfenced></mrow>'
+        '<mrow><mi>&#x1d5a4;</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
     assert mathml(elliptic_e(x, y), printer = 'presentation') == \
-        '<mrow><mi>&#x1d5a4;</mi><mfenced separators="|"><mi>x</mi><mi>y</mi></mfenced></mrow>'
+        '<mrow><mi>&#x1d5a4;</mi><mrow><mo>(</mo><mi>x</mi><mo>|</mo><mi>y</mi><mo>)</mo></mrow></mrow>'
 
 def test_print_elliptic_pi():
     assert mathml(elliptic_pi(x, y), printer = 'presentation') == \
-        '<mrow><mi>&#x1d6f1;</mi><mfenced separators="|"><mi>x</mi><mi>y</mi></mfenced></mrow>'
+        '<mrow><mi>&#x1d6f1;</mi><mrow><mo>(</mo><mi>x</mi><mo>|</mo><mi>y</mi><mo>)</mo></mrow></mrow>'
     assert mathml(elliptic_pi(x, y, z), printer = 'presentation') == \
-        '<mrow><mi>&#x1d6f1;</mi><mfenced separators=";|"><mi>x</mi><mi>y</mi><mi>z</mi></mfenced></mrow>'
+        '<mrow><mi>&#x1d6f1;</mi><mrow><mo>(</mo><mi>x</mi><mo>;</mo><mi>y</mi><mo>|</mo><mi>z</mi><mo>)</mo></mrow></mrow>'
 
 def test_print_Ei():
     assert mathml(Ei(x), printer = 'presentation') == \
-        '<mrow><mi>Ei</mi><mfenced><mi>x</mi></mfenced></mrow>'
+        '<mrow><mi>Ei</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
     assert mathml(Ei(x**y), printer = 'presentation') == \
-        '<mrow><mi>Ei</mi><mfenced><msup><mi>x</mi><mi>y</mi></msup></mfenced></mrow>'
+        '<mrow><mi>Ei</mi><mrow><mo>(</mo><msup><mi>x</mi><mi>y</mi></msup><mo>)</mo></mrow></mrow>'
 
 def test_print_expint():
     assert mathml(expint(x, y), printer = 'presentation') == \
-        '<mrow><msub><mo>E</mo><mi>x</mi></msub><mfenced><mi>y</mi></mfenced></mrow>'
+        '<mrow><msub><mo>E</mo><mi>x</mi></msub><mrow><mo>(</mo><mi>y</mi><mo>)</mo></mrow></mrow>'
     assert mathml(expint(IndexedBase(x)[1], IndexedBase(x)[2]), printer = 'presentation') == \
-        '<mrow><msub><mo>E</mo><msub><mi>x</mi><mn>1</mn></msub></msub><mfenced><msub><mi>x</mi><mn>2</mn></msub></mfenced></mrow>'
+        '<mrow><msub><mo>E</mo><msub><mi>x</mi><mn>1</mn></msub></msub><mrow><mo>(</mo><msub><mi>x</mi><mn>2</mn></msub><mo>)</mo></mrow></mrow>'
 
 def test_print_jacobi():
     assert mathml(jacobi(n, a, b, x), printer = 'presentation') == \
-        '<mrow><msubsup><mo>P</mo><mi>n</mi><mfenced><mi>a</mi><mi>b</mi></mfenced></msubsup><mfenced><mi>x</mi></mfenced></mrow>'
+        '<mrow><msubsup><mo>P</mo><mi>n</mi><mrow><mo>(</mo><mi>a</mi><mo>,</mo><mi>b</mi><mo>)</mo></mrow></msubsup><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
 
 def test_print_gegenbauer():
     assert mathml(gegenbauer(n, a, x), printer = 'presentation') == \
-        '<mrow><msubsup><mo>C</mo><mi>n</mi><mfenced><mi>a</mi></mfenced></msubsup><mfenced><mi>x</mi></mfenced></mrow>'
+        '<mrow><msubsup><mo>C</mo><mi>n</mi><mrow><mo>(</mo><mi>a</mi><mo>)</mo></mrow></msubsup><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
 
 def test_print_chebyshevt():
     assert mathml(chebyshevt(n, x), printer = 'presentation') == \
-        '<mrow><msub><mo>T</mo><mi>n</mi></msub><mfenced><mi>x</mi></mfenced></mrow>'
+        '<mrow><msub><mo>T</mo><mi>n</mi></msub><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
 
 def test_print_chebyshevu():
     assert mathml(chebyshevu(n, x), printer = 'presentation') == \
-        '<mrow><msub><mo>U</mo><mi>n</mi></msub><mfenced><mi>x</mi></mfenced></mrow>'
+        '<mrow><msub><mo>U</mo><mi>n</mi></msub><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
 
 def test_print_legendre():
     assert mathml(legendre(n, x), printer = 'presentation') == \
-        '<mrow><msub><mo>P</mo><mi>n</mi></msub><mfenced><mi>x</mi></mfenced></mrow>'
+        '<mrow><msub><mo>P</mo><mi>n</mi></msub><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
 
 def test_print_assoc_legendre():
     assert mathml(assoc_legendre(n, a, x), printer = 'presentation') == \
-        '<mrow><msubsup><mo>P</mo><mi>n</mi><mfenced><mi>a</mi></mfenced></msubsup><mfenced><mi>x</mi></mfenced></mrow>'
+        '<mrow><msubsup><mo>P</mo><mi>n</mi><mrow><mo>(</mo><mi>a</mi><mo>)</mo></mrow></msubsup><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
 
 def test_print_laguerre():
     assert mathml(laguerre(n, x), printer = 'presentation') == \
-        '<mrow><msub><mo>L</mo><mi>n</mi></msub><mfenced><mi>x</mi></mfenced></mrow>'
+        '<mrow><msub><mo>L</mo><mi>n</mi></msub><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
 
 def test_print_assoc_laguerre():
     assert mathml(assoc_laguerre(n, a, x), printer = 'presentation') == \
-        '<mrow><msubsup><mo>L</mo><mi>n</mi><mfenced><mi>a</mi></mfenced></msubsup><mfenced><mi>x</mi></mfenced></mrow>'
+        '<mrow><msubsup><mo>L</mo><mi>n</mi><mrow><mo>(</mo><mi>a</mi><mo>)</mo></mrow></msubsup><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
 
 def test_print_hermite():
     assert mathml(hermite(n, x), printer = 'presentation') == \
-        '<mrow><msub><mo>H</mo><mi>n</mi></msub><mfenced><mi>x</mi></mfenced></mrow>'
+        '<mrow><msub><mo>H</mo><mi>n</mi></msub><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow>'
 
 def test_mathml_SingularityFunction():
     assert mathml(SingularityFunction(x, 4, 5), printer='presentation') == \
-        '<msup><mfenced close="&#10217;" open="&#10216;"><mrow><mi>x</mi>' \
-        '<mo>-</mo><mn>4</mn></mrow></mfenced><mn>5</mn></msup>'
+        '<msup><mrow><mo>&#10216;</mo><mrow><mi>x</mi><mo>-</mo><mn>4</mn></mrow><mo>&#10217;</mo></mrow><mn>5</mn></msup>'
     assert mathml(SingularityFunction(x, -3, 4), printer='presentation') == \
-        '<msup><mfenced close="&#10217;" open="&#10216;"><mrow><mi>x</mi>' \
-        '<mo>+</mo><mn>3</mn></mrow></mfenced><mn>4</mn></msup>'
+        '<msup><mrow><mo>&#10216;</mo><mrow><mi>x</mi><mo>+</mo><mn>3</mn></mrow><mo>&#10217;</mo></mrow><mn>4</mn></msup>'
     assert mathml(SingularityFunction(x, 0, 4), printer='presentation') == \
-        '<msup><mfenced close="&#10217;" open="&#10216;"><mi>x</mi></mfenced>' \
-        '<mn>4</mn></msup>'
+        '<msup><mrow><mo>&#10216;</mo><mi>x</mi><mo>&#10217;</mo></mrow><mn>4</mn></msup>'
     assert mathml(SingularityFunction(x, a, n), printer='presentation') == \
-        '<msup><mfenced close="&#10217;" open="&#10216;"><mrow><mrow>' \
-        '<mo>-</mo><mi>a</mi></mrow><mo>+</mo><mi>x</mi></mrow></mfenced>' \
-        '<mi>n</mi></msup>'
+        '<msup><mrow><mo>&#10216;</mo><mrow><mrow><mo>-</mo><mi>a</mi></mrow><mo>+</mo><mi>x</mi></mrow><mo>&#10217;</mo></mrow><mi>n</mi></msup>'
     assert mathml(SingularityFunction(x, 4, -2), printer='presentation') == \
-        '<msup><mfenced close="&#10217;" open="&#10216;"><mrow><mi>x</mi>' \
-        '<mo>-</mo><mn>4</mn></mrow></mfenced><mn>-2</mn></msup>'
+        '<msup><mrow><mo>&#10216;</mo><mrow><mi>x</mi><mo>-</mo><mn>4</mn></mrow><mo>&#10217;</mo></mrow><mn>-2</mn></msup>'
     assert mathml(SingularityFunction(x, 4, -1), printer='presentation') == \
-        '<msup><mfenced close="&#10217;" open="&#10216;"><mrow><mi>x</mi>' \
-        '<mo>-</mo><mn>4</mn></mrow></mfenced><mn>-1</mn></msup>'
+        '<msup><mrow><mo>&#10216;</mo><mrow><mi>x</mi><mo>-</mo><mn>4</mn></mrow><mo>&#10217;</mo></mrow><mn>-1</mn></msup>'
 
 
 def test_mathml_matrix_functions():
@@ -1978,35 +1967,35 @@ def test_mathml_matrix_functions():
     assert mathml(Adjoint(X), printer='presentation') == \
         '<msup><mi>X</mi><mo>&#x2020;</mo></msup>'
     assert mathml(Adjoint(X + Y), printer='presentation') == \
-        '<msup><mfenced><mrow><mi>X</mi><mo>+</mo><mi>Y</mi></mrow></mfenced><mo>&#x2020;</mo></msup>'
+        '<msup><mrow><mo>(</mo><mrow><mi>X</mi><mo>+</mo><mi>Y</mi></mrow><mo>)</mo></mrow><mo>&#x2020;</mo></msup>'
     assert mathml(Adjoint(X) + Adjoint(Y), printer='presentation') == \
         '<mrow><msup><mi>X</mi><mo>&#x2020;</mo></msup><mo>+</mo><msup>' \
         '<mi>Y</mi><mo>&#x2020;</mo></msup></mrow>'
     assert mathml(Adjoint(X*Y), printer='presentation') == \
-        '<msup><mfenced><mrow><mi>X</mi><mo>&InvisibleTimes;</mo>' \
-        '<mi>Y</mi></mrow></mfenced><mo>&#x2020;</mo></msup>'
+        '<msup><mrow><mo>(</mo><mrow><mi>X</mi><mo>&InvisibleTimes;</mo>' \
+        '<mi>Y</mi></mrow><mo>)</mo></mrow><mo>&#x2020;</mo></msup>'
     assert mathml(Adjoint(Y)*Adjoint(X), printer='presentation') == \
         '<mrow><msup><mi>Y</mi><mo>&#x2020;</mo></msup><mo>&InvisibleTimes;' \
         '</mo><msup><mi>X</mi><mo>&#x2020;</mo></msup></mrow>'
     assert mathml(Adjoint(X**2), printer='presentation') == \
-        '<msup><mfenced><msup><mi>X</mi><mn>2</mn></msup></mfenced><mo>&#x2020;</mo></msup>'
+        '<msup><mrow><mo>(</mo><msup><mi>X</mi><mn>2</mn></msup><mo>)</mo></mrow><mo>&#x2020;</mo></msup>'
     assert mathml(Adjoint(X)**2, printer='presentation') == \
-        '<msup><mfenced><msup><mi>X</mi><mo>&#x2020;</mo></msup></mfenced><mn>2</mn></msup>'
+        '<msup><mrow><mo>(</mo><msup><mi>X</mi><mo>&#x2020;</mo></msup><mo>)</mo></mrow><mn>2</mn></msup>'
     assert mathml(Adjoint(Inverse(X)), printer='presentation') == \
-        '<msup><mfenced><msup><mi>X</mi><mn>-1</mn></msup></mfenced><mo>&#x2020;</mo></msup>'
+        '<msup><mrow><mo>(</mo><msup><mi>X</mi><mn>-1</mn></msup><mo>)</mo></mrow><mo>&#x2020;</mo></msup>'
     assert mathml(Inverse(Adjoint(X)), printer='presentation') == \
-        '<msup><mfenced><msup><mi>X</mi><mo>&#x2020;</mo></msup></mfenced><mn>-1</mn></msup>'
+        '<msup><mrow><mo>(</mo><msup><mi>X</mi><mo>&#x2020;</mo></msup><mo>)</mo></mrow><mn>-1</mn></msup>'
     assert mathml(Adjoint(Transpose(X)), printer='presentation') == \
-        '<msup><mfenced><msup><mi>X</mi><mo>T</mo></msup></mfenced><mo>&#x2020;</mo></msup>'
+        '<msup><mrow><mo>(</mo><msup><mi>X</mi><mo>T</mo></msup><mo>)</mo></mrow><mo>&#x2020;</mo></msup>'
     assert mathml(Transpose(Adjoint(X)), printer='presentation') ==  \
-        '<msup><mfenced><msup><mi>X</mi><mo>&#x2020;</mo></msup></mfenced><mo>T</mo></msup>'
+        '<msup><mrow><mo>(</mo><msup><mi>X</mi><mo>&#x2020;</mo></msup><mo>)</mo></mrow><mo>T</mo></msup>'
     assert mathml(Transpose(Adjoint(X) + Y), printer='presentation') ==  \
-        '<msup><mfenced><mrow><msup><mi>X</mi><mo>&#x2020;</mo></msup>' \
-        '<mo>+</mo><mi>Y</mi></mrow></mfenced><mo>T</mo></msup>'
+        '<msup><mrow><mo>(</mo><mrow><msup><mi>X</mi><mo>&#x2020;</mo></msup>' \
+        '<mo>+</mo><mi>Y</mi></mrow><mo>)</mo></mrow><mo>T</mo></msup>'
     assert mathml(Transpose(X), printer='presentation') == \
         '<msup><mi>X</mi><mo>T</mo></msup>'
     assert mathml(Transpose(X + Y), printer='presentation') == \
-        '<msup><mfenced><mrow><mi>X</mi><mo>+</mo><mi>Y</mi></mrow></mfenced><mo>T</mo></msup>'
+        '<msup><mrow><mo>(</mo><mrow><mi>X</mi><mo>+</mo><mi>Y</mi></mrow><mo>)</mo></mrow><mo>T</mo></msup>'
 
 
 def test_mathml_special_matrices():
@@ -2026,9 +2015,9 @@ def test_mathml_piecewise():
 
 def test_issue_17857():
     assert mathml(Range(-oo, oo), printer='presentation') == \
-        '<mfenced close="}" open="{"><mi>&#8230;</mi><mn>-1</mn><mn>0</mn><mn>1</mn><mi>&#8230;</mi></mfenced>'
+        '<mrow><mo>{</mo><mi>&#8230;</mi><mo>,</mo><mn>-1</mn><mo>,</mo><mn>0</mn><mo>,</mo><mn>1</mn><mo>,</mo><mi>&#8230;</mi><mo>}</mo></mrow>'
     assert mathml(Range(oo, -oo, -1), printer='presentation') == \
-        '<mfenced close="}" open="{"><mi>&#8230;</mi><mn>1</mn><mn>0</mn><mn>-1</mn><mi>&#8230;</mi></mfenced>'
+        '<mrow><mo>{</mo><mi>&#8230;</mi><mo>,</mo><mn>1</mn><mo>,</mo><mn>0</mn><mo>,</mo><mn>-1</mn><mo>,</mo><mi>&#8230;</mi><mo>}</mo></mrow>'
 
 
 def test_float_roundtrip():