Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,26 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
def
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
iface = gr.Interface(
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
)
|
12 |
|
13 |
-
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
def latex_to_html(latex_str):
|
4 |
+
# MathJax를 이용하여 LaTeX 수식을 HTML로 변환합니다.
|
5 |
+
return f"""
|
6 |
+
<!DOCTYPE html>
|
7 |
+
<html>
|
8 |
+
<body>
|
9 |
+
<script src='https://polyfill.io/v3/polyfill.min.js?features=es6'></script>
|
10 |
+
<script type="text/javascript" async
|
11 |
+
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML">
|
12 |
+
</script>
|
13 |
+
<p>
|
14 |
+
$$ {latex_str} $$
|
15 |
+
</p>
|
16 |
+
</body>
|
17 |
+
</html>
|
18 |
+
"""
|
19 |
|
20 |
+
iface = gr.Interface(fn=latex_to_html,
|
21 |
+
inputs="text",
|
22 |
+
outputs="html",
|
23 |
+
examples=[["E = mc^2"], ["\\int_{-\\infty}^{\\infty} e^{-x^2} dx = \\sqrt{\\pi}"]],
|
24 |
+
title="LaTeX Renderer with MathJax")
|
|
|
25 |
|
26 |
+
iface.launch(share=True)
|