packages = ["whl/ziafont-0.4-py3-none-any.whl", "whl/ziamath-0.6-py3-none-any.whl", "latex2mathml"] [[fetch]] files = ["fonts/Asana-Math.ttf", "fonts/Concrete-Math.otf", "fonts/DejaVuMathTeXGyre.ttf", "fonts/Erewhon-Math.otf", "fonts/FiraMath-Regular.otf", "fonts/Garamond-Math.otf", "fonts/LibertinusMath-Regular.otf"]
Ziamath LaTeX Rendering Demo
Enter a LaTeX math expression
LaTeX Expression:
Font:
Stix2
Asana-Math
Concrete-Math
DejaVu Math Tex Gyre
Erewhon-Math
FiraMath
Garamond-Math
LibertinusMath
Download SVG
import asyncio from js import document, Object, window, console from pyodide.ffi import to_js, create_proxy import ziamath def getfont(): name = Element("mathfont").value return {'asana': 'fonts/Asana-Math.ttf', 'concrete': 'fonts/Concrete-Math.otf', 'dejavu': 'fonts/DejaVuMathTeXGyre.ttf', 'erewhon': 'fonts/Erewhon-Math.otf', 'fira': 'fonts/FiraMath-Regular.otf', 'garamond': 'fonts/Garamond-Math.otf', 'liber': 'fonts/LibertinusMath-Regular.otf' }.get(name, None) # stix is default/None async def drawit(): expr = Element("expression").value try: mathsvg = ziamath.Math.fromlatex(expr, font=getfont()) except Exception as e: console.log('Math Exception: ' + str(e.args)) else: #Element('mathout').write(mathsvg) display(mathsvg, target='mathout', append=False) async def file_save(): try: options = {"startIn": "downloads", "suggestedName": "math.svg"} fileHandle = await window.showSaveFilePicker(Object.fromEntries(to_js(options))) except Exception as e: console.log('Exception: ' + str(e.args)) return expr = Element("expression").value mathsvg = ziamath.Math.fromlatex(expr, font=getfont()).svg() file = await fileHandle.createWritable() await file.write(mathsvg) await file.close() return drawit()