v0.19.0
This commit is contained in:
parent
bc92389ee1
commit
0f42e5a4c8
@ -1,7 +1,11 @@
|
||||
0.19.0 (2024-11-12)
|
||||
-------------------
|
||||
- Support rendering variables in footnotes (Thanks to Bart Broere)
|
||||
|
||||
0.18.0 (2024-07-21)
|
||||
-------------------
|
||||
- IMPORTANT : Remove Python 2.x support
|
||||
- Add hyperlink option in InlineImage (thanks to Jean Marcos da Rosa)
|
||||
- Add hyperlink option in InlineImage (Thanks to Jean Marcos da Rosa)
|
||||
- Update index.rst (Thanks to jkpet)
|
||||
- Add poetry env
|
||||
- Black all files
|
||||
|
||||
@ -4,7 +4,7 @@ Created : 2015-03-12
|
||||
|
||||
@author: Eric Lapouyade
|
||||
"""
|
||||
__version__ = "0.18.0"
|
||||
__version__ = "0.19.0"
|
||||
|
||||
# flake8: noqa
|
||||
from .inline_image import InlineImage
|
||||
|
||||
@ -210,7 +210,8 @@ class DocxTemplate(object):
|
||||
return re.sub(
|
||||
r"(</w:tcPr[ >].*?<w:t(?:.*?)>)(.*?)(?:{%\s*vm\s*%})(.*?)(</w:t>)",
|
||||
v_merge,
|
||||
m.group(), # Everything between ``</w:tc>`` and ``</w:tc>`` with ``{% vm %}`` inside.
|
||||
m.group(),
|
||||
# Everything between ``</w:tc>`` and ``</w:tc>`` with ``{% vm %}`` inside.
|
||||
flags=re.DOTALL,
|
||||
)
|
||||
|
||||
@ -310,7 +311,7 @@ class DocxTemplate(object):
|
||||
line_number = max(exc.lineno - 4, 0)
|
||||
exc.docx_context = map(
|
||||
lambda x: re.sub(r"<[^>]+>", "", x),
|
||||
src_xml.splitlines()[line_number:(line_number + 7)],
|
||||
src_xml.splitlines()[line_number : (line_number + 7)],
|
||||
)
|
||||
|
||||
raise exc
|
||||
@ -352,15 +353,22 @@ class DocxTemplate(object):
|
||||
setattr(self.docx.core_properties, prop, rendered)
|
||||
|
||||
def render_footnotes(
|
||||
self, context: Dict[str, Any], jinja_env: Optional[Environment] = None
|
||||
self, context: Dict[str, Any], jinja_env: Optional[Environment] = None
|
||||
) -> None:
|
||||
if jinja_env is None:
|
||||
jinja_env = Environment()
|
||||
|
||||
for section in self.docx.sections:
|
||||
for part in section.part.package.parts:
|
||||
if part.content_type == 'application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml':
|
||||
xml = self.patch_xml(part.blob.decode('utf-8') if isinstance(part.blob, bytes) else part.blob)
|
||||
if part.content_type == (
|
||||
"application/vnd.openxmlformats-officedocument"
|
||||
".wordprocessingml.footnotes+xml"
|
||||
):
|
||||
xml = self.patch_xml(
|
||||
part.blob.decode("utf-8")
|
||||
if isinstance(part.blob, bytes)
|
||||
else part.blob
|
||||
)
|
||||
xml = self.render_xml_part(xml, part, context, jinja_env)
|
||||
part._blob = xml
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user