Spaces:
Paused
Paused
Update util.py
Browse files
util.py
CHANGED
|
@@ -39,17 +39,18 @@ def read_docx(file_path):
|
|
| 39 |
for block in doc.element.body:
|
| 40 |
if block.tag.endswith("p"):
|
| 41 |
for paragraph in doc.paragraphs:
|
| 42 |
-
if paragraph._element == block
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
| 44 |
elif block.tag.endswith("tbl"):
|
| 45 |
for table in doc.tables:
|
| 46 |
if table._element == block:
|
| 47 |
for row in table.rows:
|
| 48 |
row_text = []
|
| 49 |
-
|
| 50 |
for cell in row.cells:
|
| 51 |
row_text.append(cell.text.strip())
|
| 52 |
-
|
| 53 |
text.append(" | ".join(row_text))
|
| 54 |
|
| 55 |
return "\n".join(text)
|
|
|
|
| 39 |
for block in doc.element.body:
|
| 40 |
if block.tag.endswith("p"):
|
| 41 |
for paragraph in doc.paragraphs:
|
| 42 |
+
if paragraph._element == block:
|
| 43 |
+
if paragraph.style.name.startswith("Heading"):
|
| 44 |
+
text.append("\n**" + paragraph.text + "**\n")
|
| 45 |
+
elif paragraph.text:
|
| 46 |
+
text.append(paragraph.text)
|
| 47 |
elif block.tag.endswith("tbl"):
|
| 48 |
for table in doc.tables:
|
| 49 |
if table._element == block:
|
| 50 |
for row in table.rows:
|
| 51 |
row_text = []
|
|
|
|
| 52 |
for cell in row.cells:
|
| 53 |
row_text.append(cell.text.strip())
|
|
|
|
| 54 |
text.append(" | ".join(row_text))
|
| 55 |
|
| 56 |
return "\n".join(text)
|