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:
Cesar Berrospi Ramis
2025-12-09 12:36:09 +01:00
committed by GitHub
parent 6afd7c57ff
commit a97d950d74

View File

@@ -25,6 +25,7 @@ from docx import Document
from docx.document import Document as DocxDocument
from docx.oxml.table import CT_Tc
from docx.oxml.xmlchemy import BaseOxmlElement
from docx.styles.style import ParagraphStyle
from docx.table import Table, _Cell
from docx.text.hyperlink import Hyperlink
from docx.text.paragraph import Paragraph
@@ -511,15 +512,17 @@ class MsWordDocumentBackend(DeclarativeDocumentBackend):
if paragraph.style is None:
return "Normal", None
label = paragraph.style.style_id
name = paragraph.style.name
base_style_label = None
base_style_name = None
if base_style := getattr(paragraph.style, "base_style", None):
label: str = paragraph.style.style_id
name: str = paragraph.style.name or ""
base_style_label: Optional[str] = None
base_style_name: Optional[str] = None
if isinstance(
base_style := getattr(paragraph.style, "base_style", None), ParagraphStyle
):
base_style_label = base_style.style_id
base_style_name = base_style.name
if label is None:
if not label:
return "Normal", None
if ":" in label: