Markitdown / app.py
AlirezaF138's picture
Update app.py
d6bc506 verified
raw
history blame
939 Bytes
import gradio as gr
from markitdown import MarkItDown
def convert_to_markdown(file):
markitdown = MarkItDown()
result = markitdown.convert(file.name)
return result.text_content
# Create Gradio interface
iface = gr.Interface(
fn=convert_to_markdown,
inputs=gr.File(label="Upload your file"),
outputs=[
gr.Textbox(label="Markdown Output", lines=20, interactive=False, show_label=False),
gr.Button("Copy to Clipboard") # Button to copy the text to clipboard
],
title="File to Markdown Converter",
description="Upload a file to convert its content to Markdown using Microsoft's markitdown library.",
layout="vertical"
)
# Adding functionality to copy the text to clipboard
def copy_to_clipboard(text):
return text # This is handled automatically by Gradio
# Bind copy button to copy functionality
iface.load(fn=None, inputs=None, outputs=None, api_name="copy")
iface.launch()