File size: 757 Bytes
282ba81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import gradio as gr

def render_latex(latex_string):
    preamble = """
    <!DOCTYPE html>
    <html>
    <head>
    <script src='https://polyfill.io/v3/polyfill.min.js?features=es6'></script>
    <script id='MathJax-script' async src='https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js'></script>
    </head>
    <body>
    $$""" + latex_string + """$$
    </body>
    </html>
    """
    return preamble

iface = gr.Interface(fn=render_latex, 
                     inputs=gr.Textbox(lines=2, placeholder="Enter LaTeX String Here..."), 
                     outputs="html",
                     title="LaTeX Renderer",
                     description="Enter a LaTeX string to render it!")

if __name__ == "__main__":
    iface.launch(share=True)