From e17d03ecaea08be16dc7d21388b8caff589b097b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Ram=C3=ADrez?= Date: Thu, 3 Nov 2016 12:27:30 -0600 Subject: [PATCH 01/25] Fix issue reported in #30. Contents of
  • elements most be wrapped inside a container like

    . This container is not automatically created by markdown2 unless the list items are explicitly separated with double linebreaks. The above issue was generating documents with invisible list items in LibreOffice. --- secretary.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/secretary.py b/secretary.py index 722e1e6..9dd8c46 100644 --- a/secretary.py +++ b/secretary.py @@ -720,6 +720,17 @@ class Renderer(object): # Transfer child nodes if html_node.hasChildNodes(): for child_node in html_node.childNodes: + # We can't directly insert text into a text:list-item + # element. The content of the item most be wrapped inside + # a container like text:p. When there's not a double linebreak + # separating list elements, markdown2 creates

  • elements without + # wraping their contents inside a container. Here we automatically + # create the container if one was not created by markdown2. + if (tag == 'li' and (not child_node.localName)): + container = xml_object.createElement('text:p') + container.appendChild(child_node.cloneNode(True)) + child_node = container + odt_node.appendChild(child_node.cloneNode(True)) # Add style-attributes defined in transform_map From 5f30fc93bf33939a8a958448156a37a970381b9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Ram=C3=ADrez?= Date: Fri, 4 Nov 2016 11:03:50 -0600 Subject: [PATCH 02/25] Fix an issue with previous markdown fix. Previous fix was only keeping the last text node found in a list element. --- secretary.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/secretary.py b/secretary.py index 9dd8c46..f3aaa2c 100644 --- a/secretary.py +++ b/secretary.py @@ -719,19 +719,20 @@ class Renderer(object): # Transfer child nodes if html_node.hasChildNodes(): - for child_node in html_node.childNodes: - # We can't directly insert text into a text:list-item - # element. The content of the item most be wrapped inside - # a container like text:p. When there's not a double linebreak - # separating list elements, markdown2 creates
  • elements without - # wraping their contents inside a container. Here we automatically - # create the container if one was not created by markdown2. - if (tag == 'li' and (not child_node.localName)): - container = xml_object.createElement('text:p') - container.appendChild(child_node.cloneNode(True)) - child_node = container + # We can't directly insert text into a text:list-item element. + # The content of the item most be wrapped inside a container + # like text:p. When there's not a double linebreak separating + # list elements, markdown2 creates
  • elements without wraping + # their contents inside a container. Here we automatically create + # the container if one was not created by markdown2. + if (tag=='li' and html_node.childNodes[0].localName <> 'p'): + container = xml_object.createElement('text:p') + odt_node.appendChild(container) + else: + container = odt_node - odt_node.appendChild(child_node.cloneNode(True)) + for child_node in html_node.childNodes: + container.appendChild(child_node.cloneNode(True)) # Add style-attributes defined in transform_map if 'style_attributes' in transform_map[tag]: From fdd62c3ff6f21a11b8c098e6d8019bb3b3ef1e4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Ram=C3=ADrez?= Date: Fri, 4 Nov 2016 11:05:02 -0600 Subject: [PATCH 03/25] Increase version number. --- README.md | 1 + setup.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a67c802..db2e7ff 100644 --- a/README.md +++ b/README.md @@ -147,6 +147,7 @@ Pad zeroes to `value` to the left until output value's length be equal to `lengt Secretary supports most of the jinja2 control structure/flow tags. But please avoid using the following tags since they are not supported: `block`, `extends`, `macro`, `call`, `include` and `import`. ### Version History +* **0.2.12**: Fix reported bug in markdown filter outputing emply lists. * **0.2.11**: Fix bug when unescaping `"`, `'`, `<`, `>` and '&' inside Jinja expressions. * **0.2.10**: --- * **0.2.9**: --- diff --git a/setup.py b/setup.py index f00ba4f..c45af52 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ class PyTest(TestCommand): setup( name='secretary', - version='0.2.11', + version='0.2.12', url='https://github.com/christopher-ramirez/secretary', license='MIT', author='Christopher Ramírez', From 3f0b97ac64e05a3641b53780098a648352bd99d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Ram=C3=ADrez?= Date: Fri, 4 Nov 2016 11:12:27 -0600 Subject: [PATCH 04/25] Fix syntax error. --- secretary.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/secretary.py b/secretary.py index f3aaa2c..7357b26 100644 --- a/secretary.py +++ b/secretary.py @@ -725,7 +725,7 @@ class Renderer(object): # list elements, markdown2 creates
  • elements without wraping # their contents inside a container. Here we automatically create # the container if one was not created by markdown2. - if (tag=='li' and html_node.childNodes[0].localName <> 'p'): + if (tag=='li' and html_node.childNodes[0].localName != 'p'): container = xml_object.createElement('text:p') odt_node.appendChild(container) else: From d0bdea1874ee0e4ea64615a4e876f80e25860748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Ram=C3=ADrez?= Date: Fri, 4 Nov 2016 11:13:18 -0600 Subject: [PATCH 05/25] Update version number. --- README.md | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index db2e7ff..1986715 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ Pad zeroes to `value` to the left until output value's length be equal to `lengt Secretary supports most of the jinja2 control structure/flow tags. But please avoid using the following tags since they are not supported: `block`, `extends`, `macro`, `call`, `include` and `import`. ### Version History -* **0.2.12**: Fix reported bug in markdown filter outputing emply lists. +* **0.2.13**: Fix reported bug in markdown filter outputing emply lists. * **0.2.11**: Fix bug when unescaping `"`, `'`, `<`, `>` and '&' inside Jinja expressions. * **0.2.10**: --- * **0.2.9**: --- diff --git a/setup.py b/setup.py index c45af52..fe12699 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ class PyTest(TestCommand): setup( name='secretary', - version='0.2.12', + version='0.2.13', url='https://github.com/christopher-ramirez/secretary', license='MIT', author='Christopher Ramírez', From a827b28f481e33b41196ec6bc29159f82745fd9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Ram=C3=ADrez?= Date: Mon, 13 Feb 2017 08:38:25 -0600 Subject: [PATCH 06/25] Fix #33 Check for existance of variable "result" when handling ExpatError exception. --- secretary.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/secretary.py b/secretary.py index 7357b26..befd9cb 100644 --- a/secretary.py +++ b/secretary.py @@ -551,6 +551,8 @@ class Renderer(object): return final_xml except ExpatError as e: + if not 'result' in locals(): + result = xml_source near = result.split('\n')[e.lineno -1][e.offset-200:e.offset+200] raise ExpatError('ExpatError "%s" at line %d, column %d\nNear of: "[...]%s[...]"' % \ (ErrorString(e.code), e.lineno, e.offset, near)) From 96ceaf41f107a90c91d08eae6b5895c166bb0970 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Ram=C3=ADrez?= Date: Mon, 13 Feb 2017 11:22:22 -0600 Subject: [PATCH 07/25] Fix #34 Automatically unescape URIs whose scheme is "secretary". --- secretary.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/secretary.py b/secretary.py index befd9cb..723b81b 100644 --- a/secretary.py +++ b/secretary.py @@ -397,8 +397,9 @@ class Renderer(object): def _unescape_entities(self, xml_text): """ - Unescape '&', '<', '"' and '>' within jinja instructions. - The regexs rules used here are compiled in _compile_escape_expressions. + Unescape links and '&', '<', '"' and '>' within jinja + instructions. The regexs rules used here are compiled in + _compile_escape_expressions. """ for regexp, replacement in self.escape_map.items(): while True: @@ -406,6 +407,23 @@ class Renderer(object): if not substitutions: break + return self._unescape_links(xml_text) + + def _unescape_links(self, xml_text): + """Fix Libreoffice auto escaping of xlink:href attribute values. + This unescaping is only done on 'secretary' scheme URLs.""" + import urllib + robj = re.compile(r'(?is)(xlink:href=\")secretary:(.*?)(\")') + + def replacement(match): + return ''.join([match.group(1), urllib.unquote(match.group(2)), + match.group(3)]) + + while True: + xml_text, rep = robj.subn(replacement, xml_text) + if not rep: + break + return xml_text @staticmethod From df513dbaa394b510eda04aabe897d04340f4a291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Ram=C3=ADrez?= Date: Mon, 13 Feb 2017 11:24:27 -0600 Subject: [PATCH 08/25] Increase version. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index fe12699..377fa3a 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ class PyTest(TestCommand): setup( name='secretary', - version='0.2.13', + version='0.2.14', url='https://github.com/christopher-ramirez/secretary', license='MIT', author='Christopher Ramírez', From b1a83ba30558fcff8205046225044003d34ee9b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Ram=C3=ADrez?= Date: Mon, 13 Feb 2017 11:40:10 -0600 Subject: [PATCH 09/25] Document in README changes introduced by fixing hyperlink encoding in #34. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 1986715..97a8cb8 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,10 @@ Although most of the time the automatic handling of control flow in secretary ma * `after::cell`: Same as `after::row` but for a table cell. > Field content is the control flow tag you insert with the Writer *input field* +### Hyperlink Support +LibreOffice by default escapes every URL in links, pictures or any other element supporting hyperlink functionallity. This can be a problem if you need to generate dynamic links because your template logic is URL encoded and impossible to be handled by the Jinja engine. Secretary solves this problem by reserving the `secretary` URI scheme. If you need to create dynamic links in your documents, prepend every link with the `secretary:` scheme. + +So for example if you have the following dynamic link: `https://mysite/products/{{ product.id }}`, prepend it with the **`secretary:`** screme, leaving the final link as `secretary:https://mysite/products/{{ product.id }}`. ### Image Support Secretary allows you to use placeholder images in templates that will be replaced when rendering the final document. To create a placeholder image on your template: From 0db3f593e1ea27c5bb8d905e4ad49143dd48024c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Ram=C3=ADrez?= Date: Mon, 13 Feb 2017 11:58:52 -0600 Subject: [PATCH 10/25] Add version log for 0.2.14. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 97a8cb8..bf55f25 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ Although most of the time the automatic handling of control flow in secretary ma ### Hyperlink Support LibreOffice by default escapes every URL in links, pictures or any other element supporting hyperlink functionallity. This can be a problem if you need to generate dynamic links because your template logic is URL encoded and impossible to be handled by the Jinja engine. Secretary solves this problem by reserving the `secretary` URI scheme. If you need to create dynamic links in your documents, prepend every link with the `secretary:` scheme. -So for example if you have the following dynamic link: `https://mysite/products/{{ product.id }}`, prepend it with the **`secretary:`** screme, leaving the final link as `secretary:https://mysite/products/{{ product.id }}`. +So for example if you have the following dynamic link: `https://mysite/products/{{ product.id }}`, prepend it with the **`secretary:`** scheme, leaving the final link as `secretary:https://mysite/products/{{ product.id }}`. ### Image Support Secretary allows you to use placeholder images in templates that will be replaced when rendering the final document. To create a placeholder image on your template: @@ -151,6 +151,7 @@ Pad zeroes to `value` to the left until output value's length be equal to `lengt Secretary supports most of the jinja2 control structure/flow tags. But please avoid using the following tags since they are not supported: `block`, `extends`, `macro`, `call`, `include` and `import`. ### Version History +* **0.2.14**: Implement dynamic links escaping and fix #33. * **0.2.13**: Fix reported bug in markdown filter outputing emply lists. * **0.2.11**: Fix bug when unescaping `"`, `'`, `<`, `>` and '&' inside Jinja expressions. * **0.2.10**: --- From 3162b42c36592069be58fed106d55d5000e4441a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pasternak?= Date: Tue, 2 May 2017 22:17:46 +0200 Subject: [PATCH 11/25] Badges --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index bf55f25..e9d6eaf 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,11 @@ # SECRETARY +.. image:: https://img.shields.io/pypi/v/secretary.svg + :target: https://pypi.python.org/pypi/secretary + +.. image:: https://img.shields.io/travis/christopher-ramirez/secretary.svg + :target: https://travis-ci.org/christopher-ramirez/secretary + #### Take the power of Jinja2 templates to OpenOffice and LibreOffice and create reports in your web applications. From d748ecd785cb540e5ed908ee8029b2f0e6a275b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pasternak?= Date: Tue, 2 May 2017 22:17:59 +0200 Subject: [PATCH 12/25] Make TravisCI use tox configuration --- .travis.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index f07d49e..c5914ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,12 @@ +env: +- TOXENV=py36 +- TOXENV=py35 +- TOXENV=py34 +- TOXENV=py33 +- TOXENV=py3 +- TOXENV=py27 +- TOXENV=py26 +install: pip install -U tox language: python -python: - - "2.6" - - "2.7" - - "3.3" -install: "python setup.py develop" -script: "python setup.py test" +python: 3.6 +script: tox -e ${TOXENV} From 31e4f257247ea8a6e06a16ec650d852b7f77318e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pasternak?= Date: Tue, 2 May 2017 22:18:09 +0200 Subject: [PATCH 13/25] More Python versions --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 6fb3487..6f64342 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py26, py27, py3, py33, py34 +envlist = py26, py27, py3, py33, py34, py35, py36 [testenv] deps = pytest From 80bc2f243e7cc77d1ac62075979d9520c789218e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pasternak?= Date: Tue, 2 May 2017 22:29:36 +0200 Subject: [PATCH 14/25] Badges, again --- README.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e9d6eaf..994bf52 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,13 @@ # SECRETARY -.. image:: https://img.shields.io/pypi/v/secretary.svg - :target: https://pypi.python.org/pypi/secretary - -.. image:: https://img.shields.io/travis/christopher-ramirez/secretary.svg - :target: https://travis-ci.org/christopher-ramirez/secretary + + + + + + + + #### Take the power of Jinja2 templates to OpenOffice and LibreOffice and create reports in your web applications. From 30f4f5207d66ac808ce7f2cf22857aeeca2d7351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pasternak?= Date: Tue, 2 May 2017 22:34:31 +0200 Subject: [PATCH 15/25] Change base python to 3.5, because it broke (https://travis-ci.org/mpasternak/secretary/jobs/228097578) --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c5914ea..13539e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,5 +8,5 @@ env: - TOXENV=py26 install: pip install -U tox language: python -python: 3.6 +python: 3.5 script: tox -e ${TOXENV} From 3b93437db5fe92b81cc3d685e491c90f543c2919 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pasternak?= Date: Tue, 2 May 2017 22:35:09 +0200 Subject: [PATCH 16/25] Strip whitespace --- README.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 994bf52..9dec62d 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,12 @@ # SECRETARY - - - - - - - + + + + + + #### Take the power of Jinja2 templates to OpenOffice and LibreOffice and create reports in your web applications. From e01dead7279c6aaaeecc2a83edf06e63f86cc0d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pasternak?= Date: Tue, 2 May 2017 22:39:43 +0200 Subject: [PATCH 17/25] Let's try another way then --- .travis.yml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 13539e9..c5c2fe9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,10 @@ -env: -- TOXENV=py36 -- TOXENV=py35 -- TOXENV=py34 -- TOXENV=py33 -- TOXENV=py3 -- TOXENV=py27 -- TOXENV=py26 install: pip install -U tox language: python -python: 3.5 -script: tox -e ${TOXENV} +python: + - 2.6 + - 2.7 + - 3.3 + - 3.4 + - 3.5 + - 3.6 +script: tox -e py${TRAVIS_PYTHON_VERSION//./} From b62e9e1db38b220a68abe47e3983b25cdbe5689f Mon Sep 17 00:00:00 2001 From: Florian Ludwig Date: Thu, 11 May 2017 00:13:40 +0200 Subject: [PATCH 18/25] newline unit tests --- test_secretary.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test_secretary.py b/test_secretary.py index 9a5d629..9e21bca 100644 --- a/test_secretary.py +++ b/test_secretary.py @@ -18,6 +18,7 @@ def test_pad_string(): assert pad_string('TEST', 4) == 'TEST' assert pad_string(1) == '00001' + class RenderTestCase(TestCase): def setUp(self): root = os.path.dirname(__file__) @@ -63,7 +64,6 @@ class RenderTestCase(TestCase): for test, expect in test_samples.items(): assert self.engine._encode_escape_chars(test) == expect - def _test_is_jinja_tag(self): assert self._is_jinja_tag('{{ foo }}')==True assert self._is_jinja_tag('{ foo }')==False @@ -79,3 +79,12 @@ class RenderTestCase(TestCase): def test_create_text_span_node(self): assert self.engine.create_text_span_node(self.document, 'text').toxml() == 'text' + def test_newline(self): + xml_text = 'Teststraße 5\n1234 Lünen' + result = Renderer._encode_escape_chars(xml_text) + assert result == 'Teststraße 51234 Lünen' + + def test_evil_newline(self): + xml_text = '\n\n' + result = Renderer._encode_escape_chars(xml_text) + assert result == '\n' From 3d2cedeec8c46c029f42fcea65db92a35ad4a28d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Ram=C3=ADrez?= Date: Mon, 12 Jun 2017 12:54:40 -0600 Subject: [PATCH 19/25] Fix #39. Introducing new tests for _encode_escape_chars. --- secretary.py | 2 +- test_secretary.py | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/secretary.py b/secretary.py index 723b81b..0fae7ac 100644 --- a/secretary.py +++ b/secretary.py @@ -431,7 +431,7 @@ class Renderer(object): """ Replace line feed and/or tabs within text:span entities. """ - find_pattern = r'(?is)([^>]*?([\n|\t])[^<]*?)' + find_pattern = r'(?is)([^>]*?([\n\t])[^<]*?)' for m in re.findall(find_pattern, xml_text): replacement = m[1].replace('\n', '') replacement = replacement.replace('\t', '') diff --git a/test_secretary.py b/test_secretary.py index 9e21bca..9000a0b 100644 --- a/test_secretary.py +++ b/test_secretary.py @@ -79,12 +79,23 @@ class RenderTestCase(TestCase): def test_create_text_span_node(self): assert self.engine.create_text_span_node(self.document, 'text').toxml() == 'text' - def test_newline(self): - xml_text = 'Teststraße 5\n1234 Lünen' - result = Renderer._encode_escape_chars(xml_text) - assert result == 'Teststraße 51234 Lünen' - def test_evil_newline(self): - xml_text = '\n\n' - result = Renderer._encode_escape_chars(xml_text) - assert result == '\n' +class EncodeLFAndFWithinTextNamespace(TestCase): + """Test encoding of line feed and tab chars within text: namespace""" + def test_encode_linefeed_char(self): + xml = 'This\nLF' + espected = 'ThisLF' + assert (Renderer._encode_escape_chars(xml) == espected) + + def test_encode_tab_char(self): + xml = 'This\tTab' + espected = 'ThisTab' + assert (Renderer._encode_escape_chars(xml) == espected) + + def test_escape_elem_with_attributes(self): + """A bug in _encode_escape_chars was preventing it from escaping + LF and tabs inside text elements with tag attributes. See: + https://github.com/christopher-ramirez/secretary/issues/39""" + xml = 'This\nLF' + espected = 'ThisLF' + assert (Renderer._encode_escape_chars(xml) == espected) From fb2fbe15a39d619dc250c6bf8c4d87da374f7475 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Ram=C3=ADrez?= Date: Mon, 12 Jun 2017 12:55:05 -0600 Subject: [PATCH 20/25] Adding new exceptions to .gitignore. --- .gitignore | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 4e6917a..e1e7a78 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,11 @@ *.*~ *.egg *.egg-info +*.odt +*.txt +.tox +.cache +.vscode dist build -eggs +eggs \ No newline at end of file From 02e7c97ad0523d4c495f0171d4c8db6a58a54abc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Ram=C3=ADrez?= Date: Mon, 12 Jun 2017 12:57:43 -0600 Subject: [PATCH 21/25] Increase minor version. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 377fa3a..f667bf1 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ class PyTest(TestCommand): setup( name='secretary', - version='0.2.14', + version='0.2.15', url='https://github.com/christopher-ramirez/secretary', license='MIT', author='Christopher Ramírez', From d132c2a98c200069183d428844f4c245a57b4f67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Ram=C3=ADrez?= Date: Mon, 12 Jun 2017 12:59:37 -0600 Subject: [PATCH 22/25] Document new version changes. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9dec62d..7bbcf96 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # SECRETARY - + @@ -159,6 +159,7 @@ Pad zeroes to `value` to the left until output value's length be equal to `lengt Secretary supports most of the jinja2 control structure/flow tags. But please avoid using the following tags since they are not supported: `block`, `extends`, `macro`, `call`, `include` and `import`. ### Version History +* **0.2.15**: Fix bug reported in #39 escaping Line-Feed and Tab chars inside `text:` elements. * **0.2.14**: Implement dynamic links escaping and fix #33. * **0.2.13**: Fix reported bug in markdown filter outputing emply lists. * **0.2.11**: Fix bug when unescaping `"`, `'`, `<`, `>` and '&' inside Jinja expressions. From cf7489a1c04d90ef24176f8b8061408b3dc9bc61 Mon Sep 17 00:00:00 2001 From: xsetra Date: Thu, 13 Jul 2017 09:47:25 +0300 Subject: [PATCH 23/25] _pack_document() method changed. ODT files have to start mimetype with non-zipped --- secretary.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/secretary.py b/secretary.py index 0fae7ac..737a205 100644 --- a/secretary.py +++ b/secretary.py @@ -177,7 +177,13 @@ class Renderer(object): self.log.debug('packing document') zip_file = io.BytesIO() + mimetype = files['mimetype'] + del files['mimetype'] + zipdoc = zipfile.ZipFile(zip_file, 'a') + + zipdoc.writestr('mimetype', mimetype, zipfile.ZIP_STORED) + for fname, content in files.items(): if sys.version_info >= (2, 7): zipdoc.writestr(fname, content, zipfile.ZIP_DEFLATED) @@ -572,6 +578,7 @@ class Renderer(object): if not 'result' in locals(): result = xml_source near = result.split('\n')[e.lineno -1][e.offset-200:e.offset+200] + raise ExpatError('ExpatError "%s" at line %d, column %d\nNear of: "[...]%s[...]"' % \ (ErrorString(e.code), e.lineno, e.offset, near)) except: @@ -846,7 +853,7 @@ if __name__ == "__main__": ] render = Renderer() - result = render.render('simple_template.odt', countries=countries, document=document) + result = render.render('simple_template2.odt', countries=countries, document=document) output = open('rendered.odt', 'wb') output.write(result) From 647f5b4f6747b0b68924ef6262d8d05458ef7754 Mon Sep 17 00:00:00 2001 From: xsetra Date: Thu, 13 Jul 2017 10:01:52 +0300 Subject: [PATCH 24/25] typing error, edited. --- secretary.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/secretary.py b/secretary.py index 737a205..c0277b7 100644 --- a/secretary.py +++ b/secretary.py @@ -853,7 +853,7 @@ if __name__ == "__main__": ] render = Renderer() - result = render.render('simple_template2.odt', countries=countries, document=document) + result = render.render('simple_template.odt', countries=countries, document=document) output = open('rendered.odt', 'wb') output.write(result) From f74046fb09401facbece39056dd53dafe3f814e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Ram=C3=ADrez?= Date: Fri, 14 Jul 2017 12:11:40 -0600 Subject: [PATCH 25/25] Fix bug storing mimefiles. --- secretary.py | 13 +++++++------ tox.ini | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/secretary.py b/secretary.py index c0277b7..760be55 100644 --- a/secretary.py +++ b/secretary.py @@ -180,15 +180,16 @@ class Renderer(object): mimetype = files['mimetype'] del files['mimetype'] - zipdoc = zipfile.ZipFile(zip_file, 'a') + zipdoc = zipfile.ZipFile(zip_file, 'a', zipfile.ZIP_DEFLATED) - zipdoc.writestr('mimetype', mimetype, zipfile.ZIP_STORED) + # Store mimetype without without compression using a ZipInfo object + # for compatibility with Py2.6 which doesn't have compress_type + # parameter in ZipFile.writestr function + mime_zipinfo = zipfile.ZipInfo('mimetype') + zipdoc.writestr(mime_zipinfo, mimetype) for fname, content in files.items(): - if sys.version_info >= (2, 7): - zipdoc.writestr(fname, content, zipfile.ZIP_DEFLATED) - else: - zipdoc.writestr(fname, content) + zipdoc.writestr(fname, content) self.log.debug('Document packing completed') diff --git a/tox.ini b/tox.ini index 6f64342..fbb1117 100644 --- a/tox.ini +++ b/tox.ini @@ -3,4 +3,4 @@ envlist = py26, py27, py3, py33, py34, py35, py36 [testenv] deps = pytest -commands= py.test +commands = py.test