|
From: <mi...@us...> - 2024-02-01 13:03:44
|
Revision: 9533
http://sourceforge.net/p/docutils/code/9533
Author: milde
Date: 2024-02-01 13:03:41 +0000 (Thu, 01 Feb 2024)
Log Message:
-----------
LaTeX to MathML: generate simpler MathML trees, fix `\cfrac`.
MathML Core defines more global attributes as MathML 3.
So we can now get rid of some `<mstyle>` wrappers and attach
styling attributes directly to the to-be-styled elements.
This also fixes
* a misattachment of expressions following continued fractions,
* styling of "smallmatrix" in Chromium,
Modified Paths:
--------------
trunk/docutils/docutils/utils/math/latex2mathml.py
trunk/docutils/docutils/utils/math/mathml_elements.py
trunk/docutils/test/functional/expected/math_experiments_mathml.html
trunk/docutils/test/functional/expected/mathematics_mathml.html
trunk/docutils/test/test_utils/test_math/test_mathml_elements.py
Modified: trunk/docutils/docutils/utils/math/latex2mathml.py
===================================================================
--- trunk/docutils/docutils/utils/math/latex2mathml.py 2024-02-01 13:03:27 UTC (rev 9532)
+++ trunk/docutils/docutils/utils/math/latex2mathml.py 2024-02-01 13:03:41 UTC (rev 9533)
@@ -31,7 +31,7 @@
from docutils.utils.math.mathml_elements import (
math, mtable, mrow, mtr, mtd, menclose, mphantom, msqrt, mi, mn, mo,
mtext, msub, msup, msubsup, munder, mover, munderover, mroot, mfrac,
- mspace, mstyle, MathRow)
+ mspace, MathRow)
# Character data
@@ -89,9 +89,8 @@
}
-# math font selection -> <mi mathvariant=...> or <mstyle mathvariant=...>
-# TODO: the "mathvariant" attribute is not supported by Chromium and
-# deprecated in the MathML specs (except with value "normal" for single chars).
+# "mathematical alphabets": map identifiers to the corresponding
+# characters from the "Mathematical Alphanumeric Symbols" block
math_alphabets = {
# 'cmdname': 'mathvariant value' # package
'mathbb': 'double-struck', # amssymb
@@ -301,15 +300,15 @@
# See also https://www.w3.org/TR/MathML3/chapter3.html#presm.scriptlevel
fractions = {
- # name: style_attrs, frac_attrs
- 'frac': ({}, {}),
- 'cfrac': ({'displaystyle': True, 'scriptlevel': 0,
- 'CLASS': 'cfrac'}, {}), # in LaTeX with padding
- 'dfrac': (layout_styles['displaystyle'], {}),
- 'tfrac': (layout_styles['textstyle'], {}),
- 'binom': ({}, {'linethickness': 0}),
- 'dbinom': (layout_styles['displaystyle'], {'linethickness': 0}),
- 'tbinom': (layout_styles['textstyle'], {'linethickness': 0}),
+ # name: attributes
+ 'frac': {},
+ 'cfrac': {'displaystyle': True, 'scriptlevel': 0,
+ 'class': 'cfrac'}, # in LaTeX with padding
+ 'dfrac': layout_styles['displaystyle'],
+ 'tfrac': layout_styles['textstyle'],
+ 'binom': {'linethickness': 0},
+ 'dbinom': layout_styles['displaystyle'] | {'linethickness': 0},
+ 'tbinom': layout_styles['textstyle'] | {'linethickness': 0},
}
delimiter_sizes = ['', '1.2em', '1.623em', '2.047em', '2.470em']
@@ -828,6 +827,8 @@
return new_node, string
if name == 'boxed':
+ # CSS padding is broken in Firefox 115.6.0esr
+ # therefore we still need the deprecated <menclose> element
new_node = menclose(notation='box', CLASS='boxed')
node.append(new_node)
return new_node, string
@@ -848,20 +849,18 @@
return new_node, string
if name in fractions:
- (style_atts, frac_atts) = fractions[name]
+ attributes = fractions[name]
if name == 'cfrac':
optarg, string = tex_optarg(string)
optargs = {'l': 'left', 'r': 'right'}
if optarg in optargs:
- frac_atts = frac_atts.copy()
- frac_atts['numalign'] = optargs[optarg] # "numalign" is deprecated
- frac_atts['class'] = 'numalign-' + optargs[optarg]
- new_node = frac = mfrac(**frac_atts)
+ attributes = attributes.copy()
+ attributes['numalign'] = optargs[optarg] # "numalign" is deprecated
+ attributes['class'] += ' numalign-' + optargs[optarg]
+ new_node = frac = mfrac(**attributes)
if name.endswith('binom'):
new_node = mrow(mo('('), new_node, mo(')'), CLASS='binom')
new_node.nchildren = 3
- if style_atts:
- new_node = mstyle(new_node, **style_atts)
node.append(new_node)
return frac, string
@@ -919,18 +918,12 @@
return new_node, string
if name in layout_styles: # 'displaystyle', 'textstyle', ...
- new_node = mstyle(**layout_styles[name])
- new_node.nchildren = None
- if isinstance(node, mrow) and len(node) == 0:
- # replace node with new_node
- node.parent[node.parent.children.index(node)] = new_node
- new_node.parent = node.parent
- elif node.__class__.__name__ == 'math':
- node.append(new_node)
- else:
+ if len(node) > 0:
raise MathError(rf'Declaration "\{name}" must be first command '
'in a group!')
- return new_node, string
+ for k, v in layout_styles[name].items():
+ node.set(k, v)
+ return node, string
if name.endswith('limits'):
arg, remainder = tex_token(string)
@@ -1076,9 +1069,7 @@
elif name == 'smallmatrix':
attributes['rowspacing'] = '0.02em'
attributes['columnspacing'] = '0.333em'
- wrapper = mstyle(scriptlevel='1')
- node.append(wrapper)
- node = wrapper
+ attributes['scriptlevel'] = '1'
elif name == 'aligned':
attributes['class'] = 'ams-align'
# TODO: array, aligned & alignedat take an optional [t], [b], or [c].
Modified: trunk/docutils/docutils/utils/math/mathml_elements.py
===================================================================
--- trunk/docutils/docutils/utils/math/mathml_elements.py 2024-02-01 13:03:27 UTC (rev 9532)
+++ trunk/docutils/docutils/utils/math/mathml_elements.py 2024-02-01 13:03:41 UTC (rev 9533)
@@ -421,11 +421,16 @@
... specified by the notation attribute.
- Non-standard: Do not use on the Web.
+ Non-standard but still required by Firefox for boxed expressions.
"""
nchildren = 1 # \boxed expects one argument or a group
+class mpadded(MathRow):
+ """Adjust space around content."""
+ # nchildren = 1 # currently not used by latex2mathml
+
+
class mphantom(MathRow):
"""Placeholder: Rendered invisibly but dimensions are kept."""
nchildren = 1 # \phantom expects one argument or a group
Modified: trunk/docutils/test/functional/expected/math_experiments_mathml.html
===================================================================
--- trunk/docutils/test/functional/expected/math_experiments_mathml.html 2024-02-01 13:03:27 UTC (rev 9532)
+++ trunk/docutils/test/functional/expected/math_experiments_mathml.html 2024-02-01 13:03:41 UTC (rev 9533)
@@ -958,33 +958,31 @@
</mrow>
<mrow>
<mo>(</mo>
- <mstyle scriptlevel="1">
- <mtable rowspacing="0.02em" columnspacing="0.333em">
- <mtr>
- <mtd>
- <mi>a</mi>
- </mtd>
- <mtd>
- <mi>b</mi>
- </mtd>
- </mtr>
- <mtr>
- <mtd>
- <mi>c</mi>
- </mtd>
- <mtd>
- <mi>d</mi>
- </mtd>
- </mtr>
- </mtable>
- <mo>)</mo>
- </mstyle>
- <mrow>
- <mo>(</mo>
- <mo>⨂</mo>
- <mo>)</mo>
- </mrow>
+ <mtable rowspacing="0.02em" columnspacing="0.333em" scriptlevel="1">
+ <mtr>
+ <mtd>
+ <mi>a</mi>
+ </mtd>
+ <mtd>
+ <mi>b</mi>
+ </mtd>
+ </mtr>
+ <mtr>
+ <mtd>
+ <mi>c</mi>
+ </mtd>
+ <mtd>
+ <mi>d</mi>
+ </mtd>
+ </mtr>
+ </mtable>
+ <mo>)</mo>
</mrow>
+ <mrow>
+ <mo>(</mo>
+ <mo>⨂</mo>
+ <mo>)</mo>
+ </mrow>
</math></p>
</dd>
<dt><math xmlns="http://www.w3.org/1998/Math/MathML">
Modified: trunk/docutils/test/functional/expected/mathematics_mathml.html
===================================================================
--- trunk/docutils/test/functional/expected/mathematics_mathml.html 2024-02-01 13:03:27 UTC (rev 9532)
+++ trunk/docutils/test/functional/expected/mathematics_mathml.html 2024-02-01 13:03:41 UTC (rev 9533)
@@ -3411,27 +3411,25 @@
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mo maxsize="1.2em" minsize="1.2em" symmetric="true">(</mo>
- <mstyle scriptlevel="1">
- <mtable rowspacing="0.02em" columnspacing="0.333em">
- <mtr>
- <mtd>
- <mi>a</mi>
- </mtd>
- <mtd>
- <mi>b</mi>
- </mtd>
- </mtr>
- <mtr>
- <mtd>
- <mi>c</mi>
- </mtd>
- <mtd>
- <mi>d</mi>
- </mtd>
- </mtr>
- </mtable>
- <mo maxsize="1.2em" minsize="1.2em" symmetric="true">)</mo>
- </mstyle>
+ <mtable rowspacing="0.02em" columnspacing="0.333em" scriptlevel="1">
+ <mtr>
+ <mtd>
+ <mi>a</mi>
+ </mtd>
+ <mtd>
+ <mi>b</mi>
+ </mtd>
+ </mtr>
+ <mtr>
+ <mtd>
+ <mi>c</mi>
+ </mtd>
+ <mtd>
+ <mi>d</mi>
+ </mtd>
+ </mtr>
+ </mtable>
+ <mo maxsize="1.2em" minsize="1.2em" symmetric="true">)</mo>
</mrow>
</math>
that comes closer to fitting within a single text line than a normal
@@ -3846,35 +3844,31 @@
</mrow>
</mfrac>
<mspace width="1em"></mspace>
- <mstyle displaystyle="true" scriptlevel="0">
- <mfrac>
- <mrow>
- <mi>x</mi>
- <mo>+</mo>
- <mn>1</mn>
- </mrow>
- <mrow>
- <mi>x</mi>
- <mo>−</mo>
- <mn>1</mn>
- </mrow>
- </mfrac>
- <mspace width="1em"></mspace>
- <mstyle displaystyle="false" scriptlevel="0">
- <mfrac>
- <mrow>
- <mi>x</mi>
- <mo>+</mo>
- <mn>1</mn>
- </mrow>
- <mrow>
- <mi>x</mi>
- <mo>−</mo>
- <mn>1</mn>
- </mrow>
- </mfrac>
- </mstyle>
- </mstyle>
+ <mfrac displaystyle="true" scriptlevel="0">
+ <mrow>
+ <mi>x</mi>
+ <mo>+</mo>
+ <mn>1</mn>
+ </mrow>
+ <mrow>
+ <mi>x</mi>
+ <mo>−</mo>
+ <mn>1</mn>
+ </mrow>
+ </mfrac>
+ <mspace width="1em"></mspace>
+ <mfrac displaystyle="false" scriptlevel="0">
+ <mrow>
+ <mi>x</mi>
+ <mo>+</mo>
+ <mn>1</mn>
+ </mrow>
+ <mrow>
+ <mi>x</mi>
+ <mo>−</mo>
+ <mn>1</mn>
+ </mrow>
+ </mfrac>
</math>
</div>
<p>and in text: <math xmlns="http://www.w3.org/1998/Math/MathML">
@@ -3891,35 +3885,31 @@
</mrow>
</mfrac>
</math>, <math xmlns="http://www.w3.org/1998/Math/MathML">
- <mstyle displaystyle="true" scriptlevel="0">
- <mfrac>
- <mrow>
- <mi>x</mi>
- <mo>+</mo>
- <mn>1</mn>
- </mrow>
- <mrow>
- <mi>x</mi>
- <mo>−</mo>
- <mn>1</mn>
- </mrow>
- </mfrac>
- </mstyle>
+ <mfrac displaystyle="true" scriptlevel="0">
+ <mrow>
+ <mi>x</mi>
+ <mo>+</mo>
+ <mn>1</mn>
+ </mrow>
+ <mrow>
+ <mi>x</mi>
+ <mo>−</mo>
+ <mn>1</mn>
+ </mrow>
+ </mfrac>
</math>, <math xmlns="http://www.w3.org/1998/Math/MathML">
- <mstyle displaystyle="false" scriptlevel="0">
- <mfrac>
- <mrow>
- <mi>x</mi>
- <mo>+</mo>
- <mn>1</mn>
- </mrow>
- <mrow>
- <mi>x</mi>
- <mo>−</mo>
- <mn>1</mn>
- </mrow>
- </mfrac>
- </mstyle>
+ <mfrac displaystyle="false" scriptlevel="0">
+ <mrow>
+ <mi>x</mi>
+ <mo>+</mo>
+ <mn>1</mn>
+ </mrow>
+ <mrow>
+ <mi>x</mi>
+ <mo>−</mo>
+ <mn>1</mn>
+ </mrow>
+ </mfrac>
</math>.</p>
<p>For binomial expressions such as <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow class="binom">
@@ -3987,106 +3977,98 @@
<mo>=</mo>
<mn>1</mn>
<mo>+</mo>
- <mstyle displaystyle="true" scriptlevel="0" class="cfrac">
- <mfrac>
- <msup>
- <mn>1</mn>
- <mn>2</mn>
- </msup>
- <mrow>
- <mn>2</mn>
- <mo>+</mo>
- <mstyle displaystyle="true" scriptlevel="0" class="cfrac">
- <mfrac>
+ <mfrac displaystyle="true" scriptlevel="0" class="cfrac">
+ <msup>
+ <mn>1</mn>
+ <mn>2</mn>
+ </msup>
+ <mrow>
+ <mn>2</mn>
+ <mo>+</mo>
+ <mfrac displaystyle="true" scriptlevel="0" class="cfrac">
+ <msup>
+ <mn>3</mn>
+ <mn>2</mn>
+ </msup>
+ <mrow>
+ <mn>2</mn>
+ <mo>+</mo>
+ <mfrac displaystyle="true" scriptlevel="0" class="cfrac">
<msup>
- <mn>3</mn>
+ <mn>5</mn>
<mn>2</mn>
</msup>
<mrow>
<mn>2</mn>
<mo>+</mo>
- <mstyle displaystyle="true" scriptlevel="0" class="cfrac">
- <mfrac>
- <msup>
- <mn>5</mn>
- <mn>2</mn>
- </msup>
- <mrow>
- <mn>2</mn>
- <mo>+</mo>
- <mstyle displaystyle="true" scriptlevel="0" class="cfrac">
- <mfrac>
- <msup>
- <mn>7</mn>
- <mn>2</mn>
- </msup>
- <mrow>
- <mn>2</mn>
- <mo>+</mo>
- <mi>⋯</mi>
- </mrow>
- </mfrac>
- </mstyle>
- </mrow>
- </mfrac>
- </mstyle>
- <mspace width="2em"></mspace>
- <mtext>vs.</mtext>
- <mspace width="2em"></mspace>
- <mfrac>
- <mi>π</mi>
- <mn>4</mn>
+ <mfrac displaystyle="true" scriptlevel="0" class="cfrac">
+ <msup>
+ <mn>7</mn>
+ <mn>2</mn>
+ </msup>
+ <mrow>
+ <mn>2</mn>
+ <mo>+</mo>
+ <mi>⋯</mi>
+ </mrow>
</mfrac>
- <mo>=</mo>
- <mn>1</mn>
+ </mrow>
+ </mfrac>
+ </mrow>
+ </mfrac>
+ </mrow>
+ </mfrac>
+ <mspace width="2em"></mspace>
+ <mtext>vs.</mtext>
+ <mspace width="2em"></mspace>
+ <mfrac>
+ <mi>π</mi>
+ <mn>4</mn>
+ </mfrac>
+ <mo>=</mo>
+ <mn>1</mn>
+ <mo>+</mo>
+ <mfrac>
+ <msup>
+ <mn>1</mn>
+ <mn>2</mn>
+ </msup>
+ <mrow>
+ <mn>2</mn>
+ <mo>+</mo>
+ <mfrac>
+ <msup>
+ <mn>3</mn>
+ <mn>2</mn>
+ </msup>
+ <mrow>
+ <mn>2</mn>
+ <mo>+</mo>
+ <mfrac>
+ <msup>
+ <mn>5</mn>
+ <mn>2</mn>
+ </msup>
+ <mrow>
+ <mn>2</mn>
<mo>+</mo>
<mfrac>
<msup>
- <mn>1</mn>
+ <mn>7</mn>
<mn>2</mn>
</msup>
<mrow>
<mn>2</mn>
<mo>+</mo>
- <mfrac>
- <msup>
- <mn>3</mn>
- <mn>2</mn>
- </msup>
- <mrow>
- <mn>2</mn>
- <mo>+</mo>
- <mfrac>
- <msup>
- <mn>5</mn>
- <mn>2</mn>
- </msup>
- <mrow>
- <mn>2</mn>
- <mo>+</mo>
- <mfrac>
- <msup>
- <mn>7</mn>
- <mn>2</mn>
- </msup>
- <mrow>
- <mn>2</mn>
- <mo>+</mo>
- <mi>⋯</mi>
- </mrow>
- </mfrac>
- </mrow>
- </mfrac>
- </mrow>
- </mfrac>
+ <mi>⋯</mi>
</mrow>
</mfrac>
</mrow>
</mfrac>
- </mstyle>
- </mrow>
- </mfrac>
- </mstyle>
+ </mrow>
+ </mfrac>
+ </mrow>
+ </mfrac>
</math>
</div>
<p>The optional argument <span class="docutils literal">[l]</span> or <span class="docutils literal">[r]</span> for left or right placement of
@@ -4093,38 +4075,32 @@
the numerator is <a class="reference external" href="https://github.com/w3c/mathml/issues/30">not supported by MathML Core</a>:</p>
<div>
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
- <mstyle displaystyle="true" scriptlevel="0" class="cfrac">
- <mfrac numalign="left" class="numalign-left">
+ <mfrac displaystyle="true" scriptlevel="0" class="cfrac numalign-left" numalign="left">
+ <mi>x</mi>
+ <mrow>
<mi>x</mi>
- <mrow>
- <mi>x</mi>
- <mo>−</mo>
- <mn>1</mn>
- </mrow>
- </mfrac>
- <mspace width="1em"></mspace>
- <mstyle displaystyle="true" scriptlevel="0" class="cfrac">
- <mfrac>
- <mi>x</mi>
- <mrow>
- <mi>x</mi>
- <mo>−</mo>
- <mn>1</mn>
- </mrow>
- </mfrac>
- <mspace width="1em"></mspace>
- <mstyle displaystyle="true" scriptlevel="0" class="cfrac">
- <mfrac numalign="right" class="numalign-right">
- <mi>x</mi>
- <mrow>
- <mi>x</mi>
- <mo>−</mo>
- <mn>1</mn>
- </mrow>
- </mfrac>
- </mstyle>
- </mstyle>
- </mstyle>
+ <mo>−</mo>
+ <mn>1</mn>
+ </mrow>
+ </mfrac>
+ <mspace width="1em"></mspace>
+ <mfrac displaystyle="true" scriptlevel="0" class="cfrac">
+ <mi>x</mi>
+ <mrow>
+ <mi>x</mi>
+ <mo>−</mo>
+ <mn>1</mn>
+ </mrow>
+ </mfrac>
+ <mspace width="1em"></mspace>
+ <mfrac displaystyle="true" scriptlevel="0" class="cfrac numalign-right" numalign="right">
+ <mi>x</mi>
+ <mrow>
+ <mi>x</mi>
+ <mo>−</mo>
+ <mn>1</mn>
+ </mrow>
+ </mfrac>
</math>
</div>
</section>
@@ -4152,104 +4128,92 @@
<td><p><span class="docutils literal">\Biggr</span></p></td>
</tr>
<tr><td><p>Result</p></td>
-<td><p><math xmlns="http://www.w3.org/1998/Math/MathML">
- <mstyle displaystyle="true" scriptlevel="0">
- <mo stretchy="false">(</mo>
+<td><p><math xmlns="http://www.w3.org/1998/Math/MathML" displaystyle="true" scriptlevel="0">
+ <mo stretchy="false">(</mo>
+ <mi>b</mi>
+ <mo stretchy="false">)</mo>
+ <mo stretchy="false">(</mo>
+ <mfrac>
+ <mi>c</mi>
+ <mi>d</mi>
+ </mfrac>
+ <mo stretchy="false">)</mo>
+</math></p></td>
+<td><p><math xmlns="http://www.w3.org/1998/Math/MathML" displaystyle="true" scriptlevel="0">
+ <mrow>
+ <mo>(</mo>
<mi>b</mi>
- <mo stretchy="false">)</mo>
- <mo stretchy="false">(</mo>
+ <mo>)</mo>
+ </mrow>
+ <mrow>
+ <mo>(</mo>
<mfrac>
<mi>c</mi>
<mi>d</mi>
</mfrac>
- <mo stretchy="false">)</mo>
- </mstyle>
+ <mo>)</mo>
+ </mrow>
</math></p></td>
-<td><p><math xmlns="http://www.w3.org/1998/Math/MathML">
- <mstyle displaystyle="true" scriptlevel="0">
- <mrow>
- <mo>(</mo>
- <mi>b</mi>
- <mo>)</mo>
- </mrow>
- <mrow>
- <mo>(</mo>
- <mfrac>
- <mi>c</mi>
- <mi>d</mi>
- </mfrac>
- <mo>)</mo>
- </mrow>
- </mstyle>
+<td><p><math xmlns="http://www.w3.org/1998/Math/MathML" displaystyle="true" scriptlevel="0">
+ <mrow>
+ <mo maxsize="1.2em" minsize="1.2em" symmetric="true">(</mo>
+ <mi>b</mi>
+ <mo maxsize="1.2em" minsize="1.2em" symmetric="true">)</mo>
+ </mrow>
+ <mrow>
+ <mo maxsize="1.2em" minsize="1.2em" symmetric="true">(</mo>
+ <mfrac>
+ <mi>c</mi>
+ <mi>d</mi>
+ </mfrac>
+ <mo maxsize="1.2em" minsize="1.2em" symmetric="true">)</mo>
+ </mrow>
</math></p></td>
-<td><p><math xmlns="http://www.w3.org/1998/Math/MathML">
- <mstyle displaystyle="true" scriptlevel="0">
- <mrow>
- <mo maxsize="1.2em" minsize="1.2em" symmetric="true">(</mo>
- <mi>b</mi>
- <mo maxsize="1.2em" minsize="1.2em" symmetric="true">)</mo>
- </mrow>
- <mrow>
- <mo maxsize="1.2em" minsize="1.2em" symmetric="true">(</mo>
- <mfrac>
- <mi>c</mi>
- <mi>d</mi>
- </mfrac>
- <mo maxsize="1.2em" minsize="1.2em" symmetric="true">)</mo>
- </mrow>
- </mstyle>
+<td><p><math xmlns="http://www.w3.org/1998/Math/MathML" displaystyle="true" scriptlevel="0">
+ <mrow>
+ <mo maxsize="1.623em" minsize="1.623em" symmetric="true">(</mo>
+ <mi>b</mi>
+ <mo maxsize="1.623em" minsize="1.623em" symmetric="true">)</mo>
+ </mrow>
+ <mrow>
+ <mo maxsize="1.623em" minsize="1.623em" symmetric="true">(</mo>
+ <mfrac>
+ <mi>c</mi>
+ <mi>d</mi>
+ </mfrac>
+ <mo maxsize="1.623em" minsize="1.623em" symmetric="true">)</mo>
+ </mrow>
</math></p></td>
-<td><p><math xmlns="http://www.w3.org/1998/Math/MathML">
- <mstyle displaystyle="true" scriptlevel="0">
- <mrow>
- <mo maxsize="1.623em" minsize="1.623em" symmetric="true">(</mo>
- <mi>b</mi>
- <mo maxsize="1.623em" minsize="1.623em" symmetric="true">)</mo>
- </mrow>
- <mrow>
- <mo maxsize="1.623em" minsize="1.623em" symmetric="true">(</mo>
- <mfrac>
- <mi>c</mi>
- <mi>d</mi>
- </mfrac>
- <mo maxsize="1.623em" minsize="1.623em" symmetric="true">)</mo>
- </mrow>
- </mstyle>
+<td><p><math xmlns="http://www.w3.org/1998/Math/MathML" displaystyle="true" scriptlevel="0">
+ <mrow>
+ <mo maxsize="2.047em" minsize="2.047em" symmetric="true">(</mo>
+ <mi>b</mi>
+ <mo maxsize="2.047em" minsize="2.047em" symmetric="true">)</mo>
+ </mrow>
+ <mrow>
+ <mo maxsize="2.047em" minsize="2.047em" symmetric="true">(</mo>
+ <mfrac>
+ <mi>c</mi>
+ <mi>d</mi>
+ </mfrac>
+ <mo maxsize="2.047em" minsize="2.047em" symmetric="true">)</mo>
+ </mrow>
</math></p></td>
-<td><p><math xmlns="http://www.w3.org/1998/Math/MathML">
- <mstyle displaystyle="true" scriptlevel="0">
- <mrow>
- <mo maxsize="2.047em" minsize="2.047em" symmetric="true">(</mo>
- <mi>b</mi>
- <mo maxsize="2.047em" minsize="2.047em" symmetric="true">)</mo>
- </mrow>
- <mrow>
- <mo maxsize="2.047em" minsize="2.047em" symmetric="true">(</mo>
- <mfrac>
- <mi>c</mi>
- <mi>d</mi>
- </mfrac>
- <mo maxsize="2.047em" minsize="2.047em" symmetric="true">)</mo>
- </mrow>
- </mstyle>
+<td><p><math xmlns="http://www.w3.org/1998/Math/MathML" displaystyle="true" scriptlevel="0">
+ <mrow>
+ <mo maxsize="2.470em" minsize="2.470em" symmetric="true">(</mo>
+ <mi>b</mi>
+ <mo maxsize="2.470em" minsize="2.470em" symmetric="true">)</mo>
+ </mrow>
+ <mrow>
+ <mo maxsize="2.470em" minsize="2.470em" symmetric="true">(</mo>
+ <mfrac>
+ <mi>c</mi>
+ <mi>d</mi>
+ </mfrac>
+ <mo maxsize="2.470em" minsize="2.470em" symmetric="true">)</mo>
+ </mrow>
</math></p></td>
-<td><p><math xmlns="http://www.w3.org/1998/Math/MathML">
- <mstyle displaystyle="true" scriptlevel="0">
- <mrow>
- <mo maxsize="2.470em" minsize="2.470em" symmetric="true">(</mo>
- <mi>b</mi>
- <mo maxsize="2.470em" minsize="2.470em" symmetric="true">)</mo>
- </mrow>
- <mrow>
- <mo maxsize="2.470em" minsize="2.470em" symmetric="true">(</mo>
- <mfrac>
- <mi>c</mi>
- <mi>d</mi>
- </mfrac>
- <mo maxsize="2.470em" minsize="2.470em" symmetric="true">)</mo>
- </mrow>
- </mstyle>
-</math></p></td>
</tr>
</tbody>
</table>
@@ -4493,53 +4457,49 @@
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mo>(</mo>
- <mstyle scriptlevel="1">
- <mtable rowspacing="0.02em" columnspacing="0.333em">
- <mtr>
- <mtd>
- <mi>a</mi>
- </mtd>
- <mtd>
- <mi>b</mi>
- </mtd>
- </mtr>
- <mtr>
- <mtd>
- <mi>c</mi>
- </mtd>
- <mtd>
- <mi>d</mi>
- </mtd>
- </mtr>
- </mtable>
- <mo>)</mo>
- </mstyle>
+ <mtable rowspacing="0.02em" columnspacing="0.333em" scriptlevel="1">
+ <mtr>
+ <mtd>
+ <mi>a</mi>
+ </mtd>
+ <mtd>
+ <mi>b</mi>
+ </mtd>
+ </mtr>
+ <mtr>
+ <mtd>
+ <mi>c</mi>
+ </mtd>
+ <mtd>
+ <mi>d</mi>
+ </mtd>
+ </mtr>
+ </mtable>
+ <mo>)</mo>
</mrow>
</math>
vs. <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mo maxsize="1.623em" minsize="1.623em" symmetric="true">(</mo>
- <mstyle scriptlevel="1">
- <mtable rowspacing="0.02em" columnspacing="0.333em">
- <mtr>
- <mtd>
- <mi>a</mi>
- </mtd>
- <mtd>
- <mi>b</mi>
- </mtd>
- </mtr>
- <mtr>
- <mtd>
- <mi>c</mi>
- </mtd>
- <mtd>
- <mi>d</mi>
- </mtd>
- </mtr>
- </mtable>
- <mo maxsize="1.623em" minsize="1.623em" symmetric="true">)</mo>
- </mstyle>
+ <mtable rowspacing="0.02em" columnspacing="0.333em" scriptlevel="1">
+ <mtr>
+ <mtd>
+ <mi>a</mi>
+ </mtd>
+ <mtd>
+ <mi>b</mi>
+ </mtd>
+ </mtr>
+ <mtr>
+ <mtd>
+ <mi>c</mi>
+ </mtd>
+ <mtd>
+ <mi>d</mi>
+ </mtd>
+ </mtr>
+ </mtable>
+ <mo maxsize="1.623em" minsize="1.623em" symmetric="true">)</mo>
</mrow>
</math>.</p>
</aside>
@@ -4832,22 +4792,20 @@
spacing that would be applied in display math, inline
math, first-order subscript, or second-order subscript, respectively
even when the current context would normally yield some other size.</p>
-<p>For example <span class="docutils literal"><span class="pre">:math:`\displaystyle</span> <span class="pre">\sum_{n=0}^\infty</span> <span class="pre">\frac{1}{n}`</span></span> is printed as <math xmlns="http://www.w3.org/1998/Math/MathML">
- <mstyle displaystyle="true" scriptlevel="0">
- <munderover>
- <mo movablelimits="true">∑</mo>
- <mrow>
- <mi>n</mi>
- <mo>=</mo>
- <mn>0</mn>
- </mrow>
- <mi>∞</mi>
- </munderover>
- <mfrac>
- <mn>1</mn>
+<p>For example <span class="docutils literal"><span class="pre">:math:`\displaystyle</span> <span class="pre">\sum_{n=0}^\infty</span> <span class="pre">\frac{1}{n}`</span></span> is printed as <math xmlns="http://www.w3.org/1998/Math/MathML" displaystyle="true" scriptlevel="0">
+ <munderover>
+ <mo movablelimits="true">∑</mo>
+ <mrow>
<mi>n</mi>
- </mfrac>
- </mstyle>
+ <mo>=</mo>
+ <mn>0</mn>
+ </mrow>
+ <mi>∞</mi>
+ </munderover>
+ <mfrac>
+ <mn>1</mn>
+ <mi>n</mi>
+ </mfrac>
</math>
rather than <math xmlns="http://www.w3.org/1998/Math/MathML">
<munderover>
@@ -4870,7 +4828,7 @@
<div>
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mfrac>
- <mstyle displaystyle="false" scriptlevel="1">
+ <mrow displaystyle="false" scriptlevel="1">
<munder>
<mo movablelimits="true">∑</mo>
<mrow>
@@ -4883,8 +4841,8 @@
<mi>z</mi>
<mi>n</mi>
</msup>
- </mstyle>
- <mstyle displaystyle="true" scriptlevel="0">
+ </mrow>
+ <mrow displaystyle="true" scriptlevel="0">
<munder>
<mo movablelimits="true">∏</mo>
<mrow>
@@ -4903,7 +4861,7 @@
<mi>k</mi>
</msup>
<mo stretchy="false">)</mo>
- </mstyle>
+ </mrow>
</mfrac>
<mtext> instead of the default </mtext>
<mfrac>
Modified: trunk/docutils/test/test_utils/test_math/test_mathml_elements.py
===================================================================
--- trunk/docutils/test/test_utils/test_math/test_mathml_elements.py 2024-02-01 13:03:27 UTC (rev 9532)
+++ trunk/docutils/test/test_utils/test_math/test_mathml_elements.py 2024-02-01 13:03:41 UTC (rev 9533)
@@ -35,7 +35,7 @@
<annotation> 0 Data annotations NOT IMPLEMENTED
<annotation-xml> * XML annotations NOT IMPLEMENTED
<math> * Top-level element
- <menclose> 1 Enclosed contents (non-standard)
+ <menclose> 1 Enclosed contents (non-standard) deprecated
<merror> * Enclosed syntax error messages
<mfenced> * Parentheses (non-standard) DEPRECATED
<mfrac> 2 Fraction
@@ -44,7 +44,7 @@
<mn> 0 Number
<mo> 0 Operator (and similar)
<mover> 2 Overscript
- <mpadded> * Extra padding NOT IMPLEMENTED
+ <mpadded> * Extra padding
<mphantom> 1 Invisible content reserving space
<mroot> 2 Radical with specified index
<mrow> * Grouped sub-expressions
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|