mirror of
https://github.com/DS4SD/docling.git
synced 2025-12-11 22:28:31 +00:00
fix(docx): handle missing value in paragraph style name (#2761)
Signed-off-by: Cesar Berrospi Ramis <ceb@zurich.ibm.com>
This commit is contained in:
committed by
GitHub
parent
6afd7c57ff
commit
a97d950d74
@@ -25,6 +25,7 @@ from docx import Document
|
|||||||
from docx.document import Document as DocxDocument
|
from docx.document import Document as DocxDocument
|
||||||
from docx.oxml.table import CT_Tc
|
from docx.oxml.table import CT_Tc
|
||||||
from docx.oxml.xmlchemy import BaseOxmlElement
|
from docx.oxml.xmlchemy import BaseOxmlElement
|
||||||
|
from docx.styles.style import ParagraphStyle
|
||||||
from docx.table import Table, _Cell
|
from docx.table import Table, _Cell
|
||||||
from docx.text.hyperlink import Hyperlink
|
from docx.text.hyperlink import Hyperlink
|
||||||
from docx.text.paragraph import Paragraph
|
from docx.text.paragraph import Paragraph
|
||||||
@@ -511,15 +512,17 @@ class MsWordDocumentBackend(DeclarativeDocumentBackend):
|
|||||||
if paragraph.style is None:
|
if paragraph.style is None:
|
||||||
return "Normal", None
|
return "Normal", None
|
||||||
|
|
||||||
label = paragraph.style.style_id
|
label: str = paragraph.style.style_id
|
||||||
name = paragraph.style.name
|
name: str = paragraph.style.name or ""
|
||||||
base_style_label = None
|
base_style_label: Optional[str] = None
|
||||||
base_style_name = None
|
base_style_name: Optional[str] = None
|
||||||
if base_style := getattr(paragraph.style, "base_style", None):
|
if isinstance(
|
||||||
|
base_style := getattr(paragraph.style, "base_style", None), ParagraphStyle
|
||||||
|
):
|
||||||
base_style_label = base_style.style_id
|
base_style_label = base_style.style_id
|
||||||
base_style_name = base_style.name
|
base_style_name = base_style.name
|
||||||
|
|
||||||
if label is None:
|
if not label:
|
||||||
return "Normal", None
|
return "Normal", None
|
||||||
|
|
||||||
if ":" in label:
|
if ":" in label:
|
||||||
|
|||||||
Reference in New Issue
Block a user