appy.shared.diff: bugfix: work internally on unicode representations of strings to diff: this way, we are sure every char is one char length.
This commit is contained in:
parent
40e8a5f258
commit
abdd0ee52d
|
@ -189,7 +189,8 @@
|
||||||
<table width="100%" class="summary">
|
<table width="100%" class="summary">
|
||||||
<tr>
|
<tr>
|
||||||
<tal:comment replace="nothing">Title</tal:comment>
|
<tal:comment replace="nothing">Title</tal:comment>
|
||||||
<td colspan="2" class="objectTitle" tal:content="contextObj/title_or_id"></td>
|
<td colspan="2" class="objectTitle"
|
||||||
|
tal:content="python: contextObj.getFieldValue('title', layoutType='view')"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="underTitle">
|
<tr class="underTitle">
|
||||||
<td colspan="2" class="by">
|
<td colspan="2" class="by">
|
||||||
|
|
10
pod/parts.py
10
pod/parts.py
|
@ -31,11 +31,11 @@ class OdtTable:
|
||||||
self.html = html
|
self.html = html
|
||||||
|
|
||||||
def dumpCell(self, content, span=1, header=False,
|
def dumpCell(self, content, span=1, header=False,
|
||||||
paraStyle=None, cellStyle=None):
|
paraStyle=None, cellStyle=None, align=None):
|
||||||
'''Dumps a cell in the table. If no specific p_paraStyle (p_cellStyle)
|
'''Dumps a cell in the table. If no specific p_paraStyle (p_cellStyle)
|
||||||
is given, self.paraStyle (self.cellStyle) is used, excepted if
|
is given, self.paraStyle (self.cellStyle) is used, excepted if
|
||||||
p_header is True: in that case, self.paraHeaderStyle
|
p_header is True: in that case, self.paraHeaderStyle
|
||||||
(self.cellHeaderStyle) is used.'''
|
(self.cellHeaderStyle) is used. p_align is used only for HTML.'''
|
||||||
if not paraStyle:
|
if not paraStyle:
|
||||||
if header: paraStyle = self.paraHeaderStyle
|
if header: paraStyle = self.paraHeaderStyle
|
||||||
else: paraStyle = self.paraStyle
|
else: paraStyle = self.paraStyle
|
||||||
|
@ -52,8 +52,10 @@ class OdtTable:
|
||||||
self.res += '</%stable-cell>' % self.tns
|
self.res += '</%stable-cell>' % self.tns
|
||||||
else:
|
else:
|
||||||
tag = header and 'th' or 'td'
|
tag = header and 'th' or 'td'
|
||||||
self.res += '<%s colspan="%d">%s</%s>' % \
|
palign = ''
|
||||||
(tag, span, cgi.escape(str(content)), tag)
|
if align: palign = ' align="%s"' % align
|
||||||
|
self.res += '<%s colspan="%d"%s>%s</%s>' % \
|
||||||
|
(tag, span, palign, cgi.escape(str(content)), tag)
|
||||||
|
|
||||||
def startRow(self):
|
def startRow(self):
|
||||||
if not self.html:
|
if not self.html:
|
||||||
|
|
|
@ -16,6 +16,7 @@ mimeTypesExts = {
|
||||||
'application/pdf' : 'pdf',
|
'application/pdf' : 'pdf',
|
||||||
'image/png' : 'png',
|
'image/png' : 'png',
|
||||||
'image/jpeg' : 'jpg',
|
'image/jpeg' : 'jpg',
|
||||||
|
'image/pjpeg' : 'jpg',
|
||||||
'image/gif' : 'gif'
|
'image/gif' : 'gif'
|
||||||
}
|
}
|
||||||
xmlPrologue = '<?xml version="1.0" encoding="utf-8" ?>\n'
|
xmlPrologue = '<?xml version="1.0" encoding="utf-8" ?>\n'
|
||||||
|
|
|
@ -245,19 +245,27 @@ class HtmlDiff:
|
||||||
deleteStyle = 'color: red; text-decoration: line-through; cursor: help'
|
deleteStyle = 'color: red; text-decoration: line-through; cursor: help'
|
||||||
|
|
||||||
def __init__(self, old, new,
|
def __init__(self, old, new,
|
||||||
insertMsg='Inserted text', deleteMsg='Deleted text',
|
insertMsg=u'Inserted text', deleteMsg=u'Deleted text',
|
||||||
insertCss=None, deleteCss=None, insertName='insert',
|
insertCss=None, deleteCss=None, insertName='insert',
|
||||||
deleteName='delete', diffRatio=0.7):
|
deleteName='delete', diffRatio=0.7):
|
||||||
# p_old and p_new are strings containing chunks of HTML.
|
# p_old and p_new are strings containing chunks of HTML. If they are not
|
||||||
|
# unicode strings, we convert them to unicode; this way, every char is
|
||||||
|
# only one char lenght.
|
||||||
self.old = old.strip()
|
self.old = old.strip()
|
||||||
|
if isinstance(self.old, str): self.old = self.old.decode('utf-8')
|
||||||
self.new = new.strip()
|
self.new = new.strip()
|
||||||
|
if isinstance(self.new, str): self.new = self.new.decode('utf-8')
|
||||||
# Every time an "insert" or "delete" difference will be detected from
|
# Every time an "insert" or "delete" difference will be detected from
|
||||||
# p_old to p_new, the impacted chunk will be surrounded by a tag that
|
# p_old to p_new, the impacted chunk will be surrounded by a tag that
|
||||||
# will get, respectively, a 'title' attribute filled p_insertMsg or
|
# will get, respectively, a 'title' attribute filled p_insertMsg or
|
||||||
# p_deleteMsg. The message will give an explanation about the change
|
# p_deleteMsg. The message will give an explanation about the change
|
||||||
# (who made it and at what time, for example).
|
# (who made it and at what time, for example).
|
||||||
self.insertMsg = insertMsg
|
self.insertMsg = insertMsg
|
||||||
|
if isinstance(self.insertMsg, str):
|
||||||
|
self.insertMsg = self.insertMsg.decode('utf-8')
|
||||||
self.deleteMsg = deleteMsg
|
self.deleteMsg = deleteMsg
|
||||||
|
if isinstance(self.deleteMsg, str):
|
||||||
|
self.deleteMsg = self.deleteMsg.decode('utf-8')
|
||||||
# This tag will get a CSS class p_insertCss or p_deleteCss for
|
# This tag will get a CSS class p_insertCss or p_deleteCss for
|
||||||
# highlighting the change. If no class is provided, default styles will
|
# highlighting the change. If no class is provided, default styles will
|
||||||
# be used (see HtmlDiff.insertStyle and HtmlDiff.deleteStyle).
|
# be used (see HtmlDiff.insertStyle and HtmlDiff.deleteStyle).
|
||||||
|
|
Loading…
Reference in a new issue