Base MathML element classes on xml.etree.
commit0167a50b321b9fb95155b0ef0c692f589162d8f2
authormilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>
Thu, 1 Feb 2024 13:04:04 +0000 (1 13:04 +0000)
committermilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>
Thu, 1 Feb 2024 13:04:04 +0000 (1 13:04 +0000)
tree72e7f6555fff120bcc31606846e11adaa58f430e
parenta0f488e2577a0e68d91ec2636ac03ed0f7310def
Base MathML element classes on xml.etree.

Use `xml.etree` for a more standard compatible implementation of
MathML element classes.

`xml.etree` comes with methods to represent XML elements,
to convert to XML (since Python 3.9 also indented XML),
search for elements, iterate over nodes etc.

The new module adds an interface to the requirements of latex2mathml:

* Simpler instantiation
  - tag name taken from class name,
  - attribute names are normalized to lowercase
    (allows 'CLASS' for 'class'),
  - attribute values may be specified as numbers, booleans, or strings
    (converted to `str` before storing).

* "internal" attributes to store a reference to the parent element
  and the number of expected children.

* "appending" to and "closing" an element returns the new "active node"
  (insertion point).

* Remove redundant `<mrow>` elements when closing.

* toxml() by default returns a Unicode `str` (not `bytes`).

git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@9535 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
docutils/docutils/utils/math/latex2mathml.py
docutils/docutils/utils/math/mathml_elements.py
docutils/test/test_utils/test_math/test_mathml_elements.py