From 088b93e77ec4ba5b65acfdac9129387ee4213657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Ram=C3=ADrez?= Date: Tue, 3 Feb 2015 16:18:44 -0600 Subject: [PATCH] Fix issue #12 --- secretary.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/secretary.py b/secretary.py index b32bede..d0cd2e3 100644 --- a/secretary.py +++ b/secretary.py @@ -452,7 +452,6 @@ def _render_xml(self, xml_document, **kwargs): self.replace_images(final_xml) return final_xml - except: self.log.error('Error rendering template:\n%s', xml_document.toprettyxml(), exc_info=True) @@ -483,8 +482,12 @@ def render(self, template, **kwargs): self.styles = parseString(self.files['styles.xml']) self.manifest = parseString(self.files['META-INF/manifest.xml']) - # Render content.xml - self.content = self._render_xml(self.content, **kwargs) + # Render content.xml keeping just 'office:body' node. + rendered_content = self._render_xml(self.content, **kwargs) + self.content.getElementsByTagName('office:document-content')[0].replaceChild( + rendered_content.getElementsByTagName('office:body')[0], + self.content.getElementsByTagName('office:body')[0] + ) # Render styles.xml self.styles = self._render_xml(self.styles, **kwargs)