Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,14 +2,24 @@ import gradio as gr
|
|
2 |
from huggingface_hub import InferenceClient
|
3 |
import os
|
4 |
import markdown
|
5 |
-
|
6 |
|
7 |
# Initialize the Hugging Face Inference Client
|
8 |
client = InferenceClient()
|
9 |
|
10 |
|
11 |
def render_latex(latex_input):
|
12 |
-
rendered_html = katex.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
return f"{rendered_html}"
|
14 |
|
15 |
|
|
|
2 |
from huggingface_hub import InferenceClient
|
3 |
import os
|
4 |
import markdown
|
5 |
+
|
6 |
|
7 |
# Initialize the Hugging Face Inference Client
|
8 |
client = InferenceClient()
|
9 |
|
10 |
|
11 |
def render_latex(latex_input):
|
12 |
+
rendered_html = f"""<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.0/dist/katex.min.css">
|
13 |
+
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"></script>
|
14 |
+
<div id="math" style="font-size: 1.5em; margin: 10px;">
|
15 |
+
<script>
|
16 |
+
document.addEventListener('DOMContentLoaded', function() {{
|
17 |
+
katex.render(String.raw`{latex_input}`, document.getElementById('math'), {{
|
18 |
+
throwOnError: false
|
19 |
+
}});
|
20 |
+
}});
|
21 |
+
</script>
|
22 |
+
</div>"""
|
23 |
return f"{rendered_html}"
|
24 |
|
25 |
|