v0.5.3
Example document / build (push) Has been cancelled
Python application / build (push) Has been cancelled

- Мелкие исправления увеличивающие работу конвертера
This commit is contained in:
Igor20264
2026-09-10 10:50:15 +03:00
parent 658036f920
commit f7136bd8bd
95 changed files with 7165 additions and 8771 deletions
+13 -4
View File
@@ -8,15 +8,24 @@ from lxml.etree import _Element
from . import package_dir
_MML2OMML_TRANSFORM: etree.XSLT | None = None
def _mml2omml_transform() -> etree.XSLT:
"""The stylesheet is stateless and reusable, so parse and compile it once."""
global _MML2OMML_TRANSFORM
if _MML2OMML_TRANSFORM is None:
_MML2OMML_TRANSFORM = etree.XSLT(etree.parse(
os.path.join(package_dir(), "mml2omml")
))
return _MML2OMML_TRANSFORM
def latex_to_omml(latex_equation: str) -> _Element:
try:
mathml = latex2mathml.converter.convert(latex_equation)
tree = etree.fromstring(mathml)
xslt = etree.parse(
os.path.join(package_dir(), "mml2omml")
)
transform = etree.XSLT(xslt)
transform = _mml2omml_transform()
new_dom = transform(tree)
word_math = new_dom.getroot()
except Exception: