[Erp5-report] r45321 nicolas - /erp5/trunk/products/ERP5OOo/transforms/
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Apr 12 10:54:30 CEST 2011
Author: nicolas
Date: Tue Apr 12 10:54:29 2011
New Revision: 45321
URL: http://svn.erp5.org?rev=45321&view=rev
Log:
Rely on include_meta_content_type parameter of lxml.html.tostring API to setup correct
meta tag.
Previous implementation was not adding the content-type meta tag in all cases.
Modified:
erp5/trunk/products/ERP5OOo/transforms/html_to_odt.py
erp5/trunk/products/ERP5OOo/transforms/oood_commandtransform.py
Modified: erp5/trunk/products/ERP5OOo/transforms/html_to_odt.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/transforms/html_to_odt.py?rev=45321&r1=45320&r2=45321&view=diff
==============================================================================
--- erp5/trunk/products/ERP5OOo/transforms/html_to_odt.py [utf8] (original)
+++ erp5/trunk/products/ERP5OOo/transforms/html_to_odt.py [utf8] Tue Apr 12 10:54:29 2011
@@ -32,17 +32,8 @@ class HTMLToOdt:
def convert(self, orig, data, cache=None, filename=None, context=None, **kwargs):
# Try to recover broken HTML documents, specially regarding encoding used
html_node = etree.XML(orig, parser=html_parser)
- html_tree = html_node.getroottree()
- head = html_tree.find('head')
- if head is None:
- # This part of code is supposed to be useless
- # lxml.html.tostring function with include_meta_content_type
- # parameter to True, should do the same things. But it does not.
- head = Element('head')
- html_node.insert(0, head)
- SubElement(head, 'meta', **{'http-equiv': 'Content-Type',
- 'content': 'text/html; charset=utf-8'})
- orig = html.tostring(html_node, encoding='utf-8', method='xml')
+ orig = html.tostring(html_node, encoding='utf-8', method='xml',
+ include_meta_content_type=True)
# workaround a Bug in LibreOffice HTML import filter.
# https://bugs.freedesktop.org/show_bug.cgi?id=36080
Modified: erp5/trunk/products/ERP5OOo/transforms/oood_commandtransform.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/transforms/oood_commandtransform.py?rev=45321&r1=45320&r2=45321&view=diff
==============================================================================
--- erp5/trunk/products/ERP5OOo/transforms/oood_commandtransform.py [utf8] (original)
+++ erp5/trunk/products/ERP5OOo/transforms/oood_commandtransform.py [utf8] Tue Apr 12 10:54:29 2011
@@ -194,7 +194,8 @@ class OOOdCommandTransform(commandtransf
parent_node.append(style_node)
style_node.attrib.update({'type': 'text/css'})
parent_node.remove(css_link_tag)
- xml_output = html.tostring(xml_doc, encoding='utf-8', method='xml')
+ xml_output = html.tostring(xml_doc, encoding='utf-8', method='xml',
+ include_meta_content_type=True)
xml_output = xml_output.replace('<title/>', '<title></title>')
return xml_output
More information about the Erp5-report
mailing list