{"id":6783,"library":"py-asciimath","title":"ASCIIMath/MathML/LaTeX Expression Converter","description":"py-asciimath is a Python library designed for converting mathematical expressions between ASCIIMath, MathML, and LaTeX formats. It provides functionality to convert from ASCIIMath to LaTeX or MathML, from MathML to LaTeX, and from LaTeX to ASCIIMath. The current version is 0.3.0. The project maintains an active development status, with ongoing updates and feature expansions, evidenced by recent major version bumps and support for new translation directions.","status":"active","version":"0.3.0","language":"en","source_language":"en","source_url":"https://github.com/belerico/py-asciimath","tags":["mathematics","asciimath","mathml","latex","conversion","parser"],"install":[{"cmd":"pip install py-asciimath","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Required for MathML parsing and XSLT-based transformations, especially MathML to LaTeX conversion.","package":"lxml","optional":false},{"reason":"Used for parsing ASCIIMath and LaTeX expressions.","package":"ply","optional":false},{"reason":"Compatibility layer for Python 2 and 3, though Python 2.7 support has been dropped in recent versions.","package":"six","optional":false}],"imports":[{"symbol":"ASCIIMath2MathML","correct":"from py_asciimath.translator.translator import ASCIIMath2MathML"},{"symbol":"ASCIIMath2Tex","correct":"from py_asciimath.translator.translator import ASCIIMath2Tex"},{"symbol":"MathML2Tex","correct":"from py_asciimath.translator.translator import MathML2Tex"},{"symbol":"Tex2ASCIIMath","correct":"from py_asciimath.translator.translator import Tex2ASCIIMath"}],"quickstart":{"code":"from py_asciimath.translator.translator import (ASCIIMath2MathML, ASCIIMath2Tex, MathML2Tex, Tex2ASCIIMath)\n\n# Example: ASCIIMath to MathML\nasciimath_expr = r\"e^x > 0 forall x in RR\"\nasciimath2mathml = ASCIIMath2MathML(log=False, inplace=True)\nmathml_output = asciimath2mathml.translate(\n    asciimath_expr,\n    displaystyle=True,\n    dtd=\"mathml2\",\n    dtd_validation=False,\n    from_file=False,\n    output=\"string\"\n)\nprint(\"ASCIIMath to MathML:\\n\", mathml_output)\n\n# Example: ASCIIMath to LaTeX\nasciimath2tex = ASCIIMath2Tex()\nlatex_output = asciimath2tex.translate(asciimath_expr)\nprint(\"ASCIIMath to LaTeX:\\n\", latex_output)\n\n# Example: LaTeX to ASCIIMath\nlatex_expr = r\"\\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}\"\ntex2asciimath = Tex2ASCIIMath()\nasciimath_from_tex_output = tex2asciimath.translate(latex_expr)\nprint(\"LaTeX to ASCIIMath:\\n\", asciimath_from_tex_output)","lang":"python","description":"This quickstart demonstrates how to initialize different translator classes and use the `translate` method to convert mathematical expressions between ASCIIMath, MathML, and LaTeX formats. Various options like `displaystyle` and `dtd` can be passed to the `translate` method for fine-grained control over the output."},"warnings":[{"fix":"Upgrade to Python 3.x or pin the library version to `py-asciimath==0.2.2`.","message":"Python 2.7 compatibility was officially dropped in version `0.2.3`. Users requiring Python 2.7 support must use `py-asciimath` version `0.2.2` or older.","severity":"breaking","affected_versions":"<=0.2.2"},{"fix":"Test conversions thoroughly with your specific MathML input. Report any inconsistencies or errors to the library's GitHub issue tracker.","message":"The `MathML2Tex` conversion relies on an XSLT MathML Library. While generally robust, unexpected behavior may occur with certain complex or non-standard MathML structures. Users are encouraged to report any issues.","severity":"gotcha","affected_versions":">=0.2.0"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}