Strip elements

Signed-off-by: SimJeg <sjegou@nvidia.com>
This commit is contained in:
SimJeg 2025-03-31 16:38:44 +02:00
parent 5b4464a741
commit 473a51adca

View File

@ -309,7 +309,7 @@ class MsWordDocumentBackend(DeclarativeDocumentBackend):
# If there is a hyperlink, add it immediately # If there is a hyperlink, add it immediately
if hyperlink is not None: if hyperlink is not None:
paragraph_elements.append((text, format, hyperlink)) paragraph_elements.append((text.strip(), format, hyperlink))
text = "" text = ""
else: else:
previous_format = format previous_format = format
@ -318,7 +318,7 @@ class MsWordDocumentBackend(DeclarativeDocumentBackend):
# Format the last group # Format the last group
if len(group_text.strip()) > 0: if len(group_text.strip()) > 0:
paragraph_elements.append((group_text, format, None)) paragraph_elements.append((group_text.strip(), format, None))
return paragraph_elements return paragraph_elements
@ -470,7 +470,7 @@ class MsWordDocumentBackend(DeclarativeDocumentBackend):
parent = doc.add_group(label=GroupLabel.INLINE, parent=self.parents[level - 1]) parent = doc.add_group(label=GroupLabel.INLINE, parent=self.parents[level - 1])
for text, format, hyperlink in paragraph_elements: for text, format, hyperlink in paragraph_elements:
doc.add_text( doc.add_text(
label=DocItemLabel.PARAGRAPH, parent=parent, text=text.strip(), label=DocItemLabel.PARAGRAPH, parent=parent, text=text,
formatting=format, hyperlink=hyperlink formatting=format, hyperlink=hyperlink
) )