This commit is contained in:
Eric Lapouyade 2020-04-15 15:11:47 +02:00
parent 97be69b950
commit ccdf20a121
5 changed files with 43 additions and 79 deletions

View File

@ -1,3 +1,7 @@
0.9.0 (2020-04-15)
-------------------
- New syntax : {%- and -%} to merge lines/paragraphs
0.8.1 (2020-04-14)
-------------------
- fix #266
@ -14,103 +18,37 @@
-------------------
- Add the possibility to add RichText to a Richtext
- Prevent lxml from attempting to parse None
0.6.3 (2019-06-20)
-------------------
- PR #207 and #209
0.6.2 (2019-06-09)
-------------------
- Handle spaces correctly when run are split by Jinja code (#205)
0.6.1 (2019-06-05)
-------------------
- PR #203
0.6.0 (2019-06-03)
-------------------
- DocxTemplate now accepts file-like objects (Thanks to edufresne)
0.5.20 (2019-05-23)
-------------------
- Fix #199
0.5.19 (2019-05-23)
-------------------
- Add support for file-like objects for replace_media (#197)
0.5.18 (2019-05-20)
-------------------
- Fix #176
0.5.17 (2019-01-20)
-------------------
- Delegated autoescaping to Jinja2 Environment (#175)
0.5.16 (2019-01-11)
-------------------
- Force to use python-docx 0.8.7 (#170)
- Add getting undeclared variables in the template (#171)
0.5.15 (2019-01-02)
-------------------
- Added `PAGE_BREAK` feature (#168)
0.5.14 (2018-12-23)
-------------------
- Fixed issue #159: autoescaped values for both str and unicode.
0.5.12 (2018-12-18)
-------------------
- Fix tables with gridSpan that have less cells after the tc forloop (#164)
0.5.11 (2018-11-21)
-------------------
- Smart double quotes in jinja tags are now converted into simple double quotes
0.5.10 (2018-11-20)
-------------------
- Smart quotes in jinja tags are now converted into simple quotes
- Add custom jinja filter example in tests/
- Reformat the code to be a little more PEP8 compliant
0.5.9 (2018-11-18)
------------------
- Add {% hm %} tag for table columns horizontal merging (Thanks to nickgashkov)
- Split tests/tests_files dir into templates and output dirs
0.5.8 (2018-11-08)
------------------
- autoescape support for python 2.7
- fix issue #154
0.5.7 (2018-11-07)
------------------
- Render can now autoescape context dict
0.5.6 (2018-10-18)
------------------
- Fix invalid xml parse because using {% vm %}
0.5.5 (2018-10-05)
------------------
- Cast to string non-string value given to RichText or Listing objects
- Import html.escape instead of cgi.escape (deprecated)
0.5.4 (2018-09-19)
------------------
- Declare package as python2 and python3 compatible for wheel distrib
0.5.3 (2018-09-19)
------------------
- Add sub/superscript in RichText
0.5.2 (2018-09-13)
------------------
- Fix table vertical merge
0.5.0 (2018-08-03)
------------------
- An hyperlink can now be used in RichText
0.4.13 (2018-06-21)

View File

@ -53,9 +53,9 @@ copyright = u'2015, Eric Lapouyade'
# built documents.
#
# The short X.Y version.
version = '0.7'
version = '0.9'
# The full version, including alpha/beta/rc tags.
release = '0.7.x'
release = '0.9.x'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.

View File

@ -89,6 +89,29 @@ But use this instead in your docx template ::
This syntax is possible because MS Word considers each line as a new paragraph and
``{%p`` tags are not in the same paragraph in the second case.
Split and merge text
....................
* You can merge a jinja2 tag with previous line by using ``{%-``
* You can merge a jinja2 tag with next line by using ``-%}``
A text containing Jinja2 tags may be unreadable if too long::
My house is located {% if living_in_town %} in urban area {% else %} in countryside {% endif %} and I love it.
One can use *ENTER* or *SHIFT+ENTER* to split a text like below, then use ``{%-`` and ``-%}`` to tell docxtpl to merge the whole thing::
My house is located
{%- if living_in_town -%}
in urban area
{%- else -%}
in countryside
{%- endif -%}
and I love it.
**IMPORTANT :** Use an unbreakable space (*CTRL+SHIFT+SPACE*) when a space is wanted at line beginning or ending.
Display variables
.................
@ -96,7 +119,7 @@ As part of jinja2, one can used double braces::
{{ <var> }}
But if ``<var>`` is a RichText :ref:`RichText` object, you must specify that you are changing the actual 'run' ::
But if ``<var>`` is a RichText_ object, you must specify that you are changing the actual 'run'::
{{r <var> }}
@ -137,7 +160,9 @@ In order to display ``{%``, ``%}``, ``{{`` or ``}}``, one can use ::
{_%, %_}, {_{ or }_}
.. _RichText:
RichText
--------
@ -153,7 +178,7 @@ you do not specify a style in ``RichText()``, the style will go back to a micros
This will affect only character styles, not the paragraph styles (MSWord manages this 2 kind of styles).
Hyperlink with RichText
.......................
+++++++++++++++++++++++
You can add an hyperlink to a text by using a Richtext with this syntax::

View File

@ -7,7 +7,7 @@ Created : 2015-03-12
import functools
import io
__version__ = '0.8.1'
__version__ = '0.9.0'
from lxml import etree
from docx import Document
@ -410,6 +410,7 @@ class DocxTemplate(object):
tpl.replace_media(io.BytesIO(image_stream), io.BytesIO(new_image_stream))
Note: for images, the aspect ratio will be the same as the replaced image
Note2: it is important to have the source media file as it is required
to calculate its CRC to find them in the docx
"""