Skip to content

Commit 0f42e5a

Browse files
author
Eric Lapouyade
committed
v0.19.0
1 parent bc92389 commit 0f42e5a

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

CHANGES.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
0.19.0 (2024-11-12)
2+
-------------------
3+
- Support rendering variables in footnotes (Thanks to Bart Broere)
4+
15
0.18.0 (2024-07-21)
26
-------------------
37
- IMPORTANT : Remove Python 2.x support
4-
- Add hyperlink option in InlineImage (thanks to Jean Marcos da Rosa)
8+
- Add hyperlink option in InlineImage (Thanks to Jean Marcos da Rosa)
59
- Update index.rst (Thanks to jkpet)
610
- Add poetry env
711
- Black all files

docxtpl/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
@author: Eric Lapouyade
66
"""
7-
__version__ = "0.18.0"
7+
__version__ = "0.19.0"
88

99
# flake8: noqa
1010
from .inline_image import InlineImage

docxtpl/template.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ def v_merge(m1):
210210
return re.sub(
211211
r"(</w:tcPr[ >].*?<w:t(?:.*?)>)(.*?)(?:{%\s*vm\s*%})(.*?)(</w:t>)",
212212
v_merge,
213-
m.group(), # Everything between ``</w:tc>`` and ``</w:tc>`` with ``{% vm %}`` inside.
213+
m.group(),
214+
# Everything between ``</w:tc>`` and ``</w:tc>`` with ``{% vm %}`` inside.
214215
flags=re.DOTALL,
215216
)
216217

@@ -310,7 +311,7 @@ def render_xml_part(self, src_xml, part, context, jinja_env=None):
310311
line_number = max(exc.lineno - 4, 0)
311312
exc.docx_context = map(
312313
lambda x: re.sub(r"<[^>]+>", "", x),
313-
src_xml.splitlines()[line_number:(line_number + 7)],
314+
src_xml.splitlines()[line_number : (line_number + 7)],
314315
)
315316

316317
raise exc
@@ -352,15 +353,22 @@ def render_properties(
352353
setattr(self.docx.core_properties, prop, rendered)
353354

354355
def render_footnotes(
355-
self, context: Dict[str, Any], jinja_env: Optional[Environment] = None
356+
self, context: Dict[str, Any], jinja_env: Optional[Environment] = None
356357
) -> None:
357358
if jinja_env is None:
358359
jinja_env = Environment()
359360

360361
for section in self.docx.sections:
361362
for part in section.part.package.parts:
362-
if part.content_type == 'application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml':
363-
xml = self.patch_xml(part.blob.decode('utf-8') if isinstance(part.blob, bytes) else part.blob)
363+
if part.content_type == (
364+
"application/vnd.openxmlformats-officedocument"
365+
".wordprocessingml.footnotes+xml"
366+
):
367+
xml = self.patch_xml(
368+
part.blob.decode("utf-8")
369+
if isinstance(part.blob, bytes)
370+
else part.blob
371+
)
364372
xml = self.render_xml_part(xml, part, context, jinja_env)
365373
part._blob = xml
366374

0 commit comments

Comments
 (0)