diff --git a/ghostwriter/modules/reportwriter/html_to_docx.py b/ghostwriter/modules/reportwriter/html_to_docx.py index 895301900..b83306377 100644 --- a/ghostwriter/modules/reportwriter/html_to_docx.py +++ b/ghostwriter/modules/reportwriter/html_to_docx.py @@ -120,7 +120,7 @@ def tag_p(self, el, *, par=None, **kwargs): # Top level

par = self.doc.add_paragraph(style=self.p_style) - par_classes = set(el.attrs.get("class", "").split()) + par_classes = set(el.attrs.get("class", [])) if "left" in par_classes: par.alignment = WD_ALIGN_PARAGRAPH.LEFT if "center" in par_classes: diff --git a/ghostwriter/modules/reportwriter/html_to_pptx.py b/ghostwriter/modules/reportwriter/html_to_pptx.py index c2bcdb4df..860aeb1b5 100644 --- a/ghostwriter/modules/reportwriter/html_to_pptx.py +++ b/ghostwriter/modules/reportwriter/html_to_pptx.py @@ -85,7 +85,7 @@ def tag_p(self, el, **kwargs): self.text_tracking.new_block() par = self.shape.text_frame.add_paragraph() - par_classes = set(el.attrs.get("class", "").split()) + par_classes = set(el.attrs.get("class", [])) if "left" in par_classes: par.alignment = PP_ALIGN.LEFT if "center" in par_classes: diff --git a/ghostwriter/reporting/tests/test_rich_text_docx.py b/ghostwriter/reporting/tests/test_rich_text_docx.py index 575590d8a..cae1a99db 100644 --- a/ghostwriter/reporting/tests/test_rich_text_docx.py +++ b/ghostwriter/reporting/tests/test_rich_text_docx.py @@ -570,3 +570,16 @@ class RichTextToDocxTests(TestCase): """, ) + + test_paragraph_class = mk_test_docx( + "test_paragraph_class", + """ +

Paragraph with a class

+ """, + """ + + + Paragraph with a class + + """ + )