Spaces:
Running
Running
import gradio as gr | |
def latex_to_html(latex_str): | |
# MathJax를 이용하여 LaTeX 수식을 HTML로 변환합니다. | |
return f""" | |
<!DOCTYPE html> | |
<html> | |
<body> | |
<script src='https://polyfill.io/v3/polyfill.min.js?features=es6'></script> | |
<script type="text/javascript" async | |
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML"> | |
</script> | |
<p> | |
$$ {latex_str} $$ | |
</p> | |
</body> | |
</html> | |
""" | |
iface = gr.Interface(fn=latex_to_html, | |
inputs="text", | |
outputs="html", | |
examples=[["E = mc^2"], ["\\int_{-\\infty}^{\\infty} e^{-x^2} dx = \\sqrt{\\pi}"]], | |
title="LaTeX Renderer with MathJax") | |
iface.launch(share=True) |