Spaces:
Runtime error
Runtime error
import gradio as gr | |
# HTML template for rendering Mermaid diagrams | |
html_template = """ | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script> | |
<style> | |
mermaid { | |
display: block; | |
margin: auto; | |
} | |
</style> | |
</head> | |
<body> | |
<mermaid>{}</mermaid> | |
</body> | |
</html> | |
""" | |
def render_mermaid(mermaid_code): | |
# Wrap the input code into the HTML template | |
html_content = html_template.format(mermaid_code) | |
return html_content | |
# Create a Gradio interface | |
iface = gr.Interface( | |
fn=render_mermaid, | |
inputs="text", | |
outputs="html", | |
title="Mermaid Diagram Renderer", | |
description="Input your Mermaid diagram code to render it." | |
) | |
# Launch the app | |
iface.launch() | |