diff options
| author | Étienne Loks <etienne.loks@proxience.com> | 2015-01-25 18:05:09 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@proxience.com> | 2015-01-25 18:06:07 +0100 | 
| commit | 643f42e69cbae6e8b89c939e903b1fa95ed1935d (patch) | |
| tree | 1bd9f1ca7890418159ae77aa46b91fbfa7e40d89 /ishtar_common/views.py | |
| parent | 41b382ce948a6cfa17ff91441f1141bcc2ccd3e0 (diff) | |
| download | Ishtar-643f42e69cbae6e8b89c939e903b1fa95ed1935d.tar.bz2 Ishtar-643f42e69cbae6e8b89c939e903b1fa95ed1935d.zip  | |
Adapt xhtml2odt call with new tidylib
Diffstat (limited to 'ishtar_common/views.py')
| -rw-r--r-- | ishtar_common/views.py | 21 | 
1 files changed, 8 insertions, 13 deletions
diff --git a/ishtar_common/views.py b/ishtar_common/views.py index b5f56652c..6f18f8daa 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -1,6 +1,6 @@  #!/usr/bin/env python  # -*- coding: utf-8 -*- -# Copyright (C) 2010-2014  Étienne Loks  <etienne.loks_AT_peacefrogsDOTnet> +# Copyright (C) 2010-2015  Étienne Loks  <etienne.loks_AT_peacefrogsDOTnet>  # This program is free software: you can redistribute it and/or modify  # it under the terms of the GNU Affero General Public License as @@ -17,10 +17,7 @@  # See the file COPYING for details. -try: -    import tidy -except: -    from tidylib import tidy_document as tidy +from tidylib import tidy_document as tidy  import re  import csv @@ -519,17 +516,15 @@ def show_item(model, name):              filename = item.history_object.associated_filename          else:              filename = item.associated_filename -        if doc_type == "odt" and settings.XHTML2ODT_PATH and \ -           settings.ODT_TEMPLATE: +        if doc_type == "odt" and settings.ODT_TEMPLATE:              tpl = loader.get_template('ishtar/sheet_%s.html' % name)              content = tpl.render(context_instance)              try: -                tidy_options = dict(output_xhtml=1, add_xml_decl=1, indent=1, -                        tidy_mark=0, output_encoding='utf8', doctype='auto', -                        wrap=0, char_encoding='utf8') -                html = str(tidy.parseString(content.encode('utf-8'), -                                            **tidy_options)) -                html = html.replace(" ", " ") +                tidy_options = {'output-xhtml':1, 'indent':1, +                                'tidy-mark':0, 'doctype':'auto', +                                'add-xml-decl':1, 'wrap':1} +                html, errors = tidy(content, options=tidy_options) +                html = html.encode('utf-8').replace(" ", " ")                  html = re.sub('<pre([^>]*)>\n', '<pre\\1>', html)                  odt = NamedTemporaryFile()  | 
