summaryrefslogtreecommitdiff
path: root/bin/report/render/html2html
diff options
context:
space:
mode:
authorP. Christeas <p_christ@hol.gr>2009-07-09 21:12:53 +0300
committerP. Christeas <p_christ@hol.gr>2009-07-09 21:12:53 +0300
commit2d64ce69d07a55f827548e43cfcc73cd459dc39a (patch)
treeb217b2afe155395280d27a4c6cc0c43c89396c3b /bin/report/render/html2html
parentcb5e80507f5a8330ed4e0f2526343b97f8d506e6 (diff)
parenta2db1c09ba3a279a8d791c8914a19d2f0dbb2c18 (diff)
Merge origin/master into mdv-gpl3-py26
Conflicts: bin/addons/base_setup/i18n/base_setup.pot bin/openerp-server.py bin/report/preprocess.py bin/report/report_sxw.py bin/tools/translate.py bzr revid: p_christ@hol.gr-20090709181253-fu8nxy9b3ykrrd1c
Diffstat (limited to 'bin/report/render/html2html')
-rw-r--r--bin/report/render/html2html/html2html.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/bin/report/render/html2html/html2html.py b/bin/report/render/html2html/html2html.py
index d4fa8559720..fa07e9b4726 100644
--- a/bin/report/render/html2html/html2html.py
+++ b/bin/report/render/html2html/html2html.py
@@ -30,7 +30,7 @@ import re
from reportlab.lib.utils import ImageReader
_regex = re.compile('\[\[(.+?)\]\]')
-
+utils._regex = re.compile('\[\[\s*(.+?)\s*\]\]',re.DOTALL)
class html2html(object):
def __init__(self, html, localcontext):
self.localcontext = localcontext
@@ -47,6 +47,8 @@ class html2html(object):
new_node.append(new_child)
if len(child):
for n in new_child:
+ new_child.text = utils._process_text(self, child.text)
+ new_child.tail = utils._process_text(self, child.tail)
new_child.remove(n)
process_text(child, new_child)
else:
@@ -65,13 +67,30 @@ class html2html(object):
else :
new_child.getparent().remove(new_child)
new_child.text = utils._process_text(self, child.text)
+ new_child.tail = utils._process_text(self, child.tail)
self._node = copy.deepcopy(self.etree)
for n in self._node:
self._node.remove(n)
process_text(self.etree, self._node)
return self._node
+
+ def url_modify(self,root):
+ for n in root.getchildren():
+ if (n.text.find('<a ')>=0 or n.text.find('&lt;a')>=0) and n.text.find('href')>=0 and n.text.find('style')<=0 :
+ node = (n.tag=='span' and n.getparent().tag=='u') and n.getparent().getparent() or ((n.tag=='span') and n.getparent()) or n
+ style = node.get('color') and "style='color:%s; text-decoration: none;'"%node.get('color') or ''
+ if n.text.find('&lt;a')>=0:
+ t = '&lt;a '
+ else :
+ t = '<a '
+ href = n.text.split(t)[-1]
+ n.text = ' '.join([t,style,href])
+ self.url_modify(n)
+ return root
def parseString(node, localcontext = {}):
r = html2html(node, localcontext)
- return r.render()
+ root = r.render()
+ root = r.url_modify(root)
+ return root