Force header / footer nodes format.
get_headers_footers_xml was returning the xml in a raw string without any processing on it. If we had a quote in docx document, it was encode in a xml entity ("), but because of the entities, Jinja raise error. Now, xml passes through etree.tostring and we have a clean string.
This commit is contained in:
parent
1e6523d464
commit
878197a93c
@ -9,6 +9,7 @@ __version__ = '0.3.5'
|
||||
|
||||
from lxml import etree
|
||||
from docx import Document
|
||||
from docx.opc.oxml import serialize_part_xml, parse_xml
|
||||
from jinja2 import Template
|
||||
from cgi import escape
|
||||
import re
|
||||
@ -102,7 +103,7 @@ class DocxTemplate(object):
|
||||
def get_headers_footers_xml(self, uri):
|
||||
for relKey, val in self.docx._part._rels.items():
|
||||
if val.reltype == uri:
|
||||
yield relKey, val._target._blob
|
||||
yield relKey, self.xml_to_string(parse_xml(val._target._blob))
|
||||
|
||||
def get_headers_footers_encoding(self,xml):
|
||||
m = re.match(r'<\?xml[^\?]+\bencoding="([^"]+)"',xml,re.I)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user