Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,7 @@ import os
|
|
7 |
|
8 |
def extract_text_markdown(doc):
|
9 |
markdown_output = ""
|
|
|
10 |
|
11 |
for page in doc:
|
12 |
blocks = page.get_text("dict")["blocks"]
|
@@ -21,12 +22,14 @@ def extract_text_markdown(doc):
|
|
21 |
if line_text:
|
22 |
elements.append((line_y, line_text))
|
23 |
elif b["type"] == 1: # Imagen
|
24 |
-
|
|
|
|
|
25 |
|
26 |
# Ordenar por posici贸n vertical
|
27 |
elements.sort(key=lambda x: x[0])
|
28 |
|
29 |
-
#
|
30 |
previous_y = None
|
31 |
for y, content in elements:
|
32 |
if previous_y is not None and abs(y - previous_y) > 10:
|
|
|
7 |
|
8 |
def extract_text_markdown(doc):
|
9 |
markdown_output = ""
|
10 |
+
image_counter = 1 # Contador de im谩genes
|
11 |
|
12 |
for page in doc:
|
13 |
blocks = page.get_text("dict")["blocks"]
|
|
|
22 |
if line_text:
|
23 |
elements.append((line_y, line_text))
|
24 |
elif b["type"] == 1: # Imagen
|
25 |
+
# A帽ade un enlace con nombre 煤nico
|
26 |
+
elements.append((y, f"[imagen_{image_counter}]()"))
|
27 |
+
image_counter += 1
|
28 |
|
29 |
# Ordenar por posici贸n vertical
|
30 |
elements.sort(key=lambda x: x[0])
|
31 |
|
32 |
+
# Reconstrucci贸n con saltos l贸gicos
|
33 |
previous_y = None
|
34 |
for y, content in elements:
|
35 |
if previous_y is not None and abs(y - previous_y) > 10:
|