Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -133,13 +133,33 @@ def convert(pdf_file):
|
|
133 |
|
134 |
return markdown_output.strip(), {}, image_paths, markdown_path
|
135 |
|
136 |
-
gr.
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
|
134 |
return markdown_output.strip(), {}, image_paths, markdown_path
|
135 |
|
136 |
+
with gr.Blocks() as demo:
|
137 |
+
with gr.Row():
|
138 |
+
pdf_input = gr.File(label="Sube tu PDF", type="filepath")
|
139 |
+
submit_btn = gr.Button("Procesar PDF")
|
140 |
+
|
141 |
+
markdown_output = gr.Markdown(label="Markdown estructurado")
|
142 |
+
gallery_output = gr.Gallery(label="Im谩genes extra铆das", type="file")
|
143 |
+
download_md = gr.File(label="Descargar .md")
|
144 |
+
|
145 |
+
with gr.Row():
|
146 |
+
copy_btn = gr.Button("馃搵 Copiar Markdown al portapapeles")
|
147 |
+
reload_btn = gr.Button("馃攧 Refrescar app")
|
148 |
+
|
149 |
+
# L贸gica del bot贸n principal
|
150 |
+
submit_btn.click(fn=convert, inputs=[pdf_input], outputs=[markdown_output, gallery_output, download_md])
|
151 |
+
|
152 |
+
# Copiar texto al portapapeles
|
153 |
+
copy_btn.js("""
|
154 |
+
async () => {
|
155 |
+
const text = document.querySelector('gr-markdown').innerText;
|
156 |
+
await navigator.clipboard.writeText(text);
|
157 |
+
alert('Markdown copiado al portapapeles');
|
158 |
+
}
|
159 |
+
""")
|
160 |
+
|
161 |
+
# Refrescar
|
162 |
+
reload_btn.js("() => window.location.reload()")
|
163 |
+
|
164 |
+
demo.launch()
|
165 |
+
|