import gradio as gr from pymermaid import mermaid # HTML template for rendering Mermaid diagrams html_template = """
{}
""" def render_mermaid(mermaid_code): # Create HTML output html_content = html_template.format(mermaid_code) # Create PNG output png_path = "diagram.png" mermaid.render(mermaid_code, filename=png_path) return html_content, png_path # Create a Gradio interface iface = gr.Interface( fn=render_mermaid, inputs="text", outputs=["html", "image"], title="Mermaid Diagram Renderer", description="Input your Mermaid diagram code to render it." ) # Launch the app iface.launch()