File size: 808 Bytes
282ba81
6e98020
282ba81
6e98020
32eac0f
 
 
 
 
6e98020
 
 
 
32eac0f
 
282ba81
ca60e9b
6e98020
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gradio as gr
import requests

def latex_to_image(latex_code):
    # 기본적인 LaTeX 문법 검사 예시
    if not latex_code.startswith("\\"):
        return "invalid equation: LaTeX commands should start with a backslash (\\)."

    # 실제 렌더링 URL 생성 로직
    codecogs_url = "https://latex.codecogs.com/png.latex?"
    response_url = codecogs_url + requests.utils.quote(latex_code)
    
    return response_url
    


iface = gr.Interface(fn=latex_to_image,
                     inputs=gr.Textbox(label="Enter your LaTeX code here"),
                     outputs=gr.Image(label="Rendered LaTeX"),
                     title="LaTeX to Image Converter",
                     description="This tool converts LaTeX code to an image using an external rendering service.")
iface.launch()