Back to index

plone3  3.1.7
Public Member Functions
CMFDiffTool.libs.htmldiff.SimpleHTMLMatcher Class Reference
Inheritance diagram for CMFDiffTool.libs.htmldiff.SimpleHTMLMatcher:
Inheritance graph
[legend]
Collaboration diagram for CMFDiffTool.libs.htmldiff.SimpleHTMLMatcher:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def startInsertText
def endInsertText
def startDeleteText
def endDeleteText
def formatInsertTag
def formatDeleteTag
def set_seq1
def set_seq2
def splitTags
def splitWords
def splitHTML
def htmlDiff
def textDelete
def textInsert
def stylesheet
def addStylesheet

Detailed Description

Like HTMLMatcher, but returns a simpler diff

Definition at line 176 of file htmldiff.py.


Member Function Documentation

def CMFDiffTool.libs.htmldiff.HTMLMatcher.addStylesheet (   self,
  html,
  ss 
) [inherited]

Definition at line 129 of file htmldiff.py.

00129 
00130     def addStylesheet(self, html, ss):
00131         match = headRE.search(html)
00132         if match:
00133             pos = match.end()
00134         else:
00135             pos = 0
00136         return ('%s<style type="text/css"><!--\n%s\n--></style>%s'
00137                 % (html[:pos], ss, html[pos:]))

Here is the caller graph for this function:

Reimplemented from CMFDiffTool.libs.htmldiff.HTMLMatcher.

Definition at line 186 of file htmldiff.py.

00186 
00187     def endDeleteText(self):
        return ']'

Reimplemented from CMFDiffTool.libs.htmldiff.HTMLMatcher.

Definition at line 182 of file htmldiff.py.

00182 
00183     def endInsertText(self):
        return ']'

Reimplemented from CMFDiffTool.libs.htmldiff.HTMLMatcher.

Definition at line 190 of file htmldiff.py.

00190 
00191     def formatDeleteTag(self, tag):
00192         return '-[%s]' % tag

Reimplemented from CMFDiffTool.libs.htmldiff.HTMLMatcher.

Definition at line 188 of file htmldiff.py.

00188 
00189     def formatInsertTag(self, tag):
        return '+[%s]' % tag
def CMFDiffTool.libs.htmldiff.HTMLMatcher.htmlDiff (   self,
  addStylesheet = False 
) [inherited]

Reimplemented in CMFDiffTool.libs.htmldiff.TextMatcher.

Definition at line 64 of file htmldiff.py.

00064 
00065     def htmlDiff(self, addStylesheet=False):
00066         opcodes = self.get_opcodes()
00067         a = self.a
00068         b = self.b
00069         out = StringIO()
00070         #print [o[0] for o in opcodes]
00071         for tag, i1, i2, j1, j2 in opcodes:
00072             if tag == 'equal':
00073                 for item in a[i1:i2]:
00074                     out.write(item)
00075                     out.write(' ')
00076             if tag == 'delete' or tag == 'replace':
00077                 self.textDelete(a[i1:i2], out)
00078             if tag == 'insert' or tag == 'replace':
00079                 self.textInsert(b[j1:j2], out)
00080         html = out.getvalue()
00081         out.close()
00082         if addStylesheet:
00083             html = self.addStylesheet(html, self.stylesheet())
00084         return html

Here is the call graph for this function:

def CMFDiffTool.libs.htmldiff.HTMLMatcher.set_seq1 (   self,
  a 
) [inherited]

Reimplemented in CMFDiffTool.libs.htmldiff.TextMatcher.

Definition at line 31 of file htmldiff.py.

00031 
00032     def set_seq1(self, a):
00033         SequenceMatcher.set_seq1(self, self.splitHTML(a))

Here is the call graph for this function:

def CMFDiffTool.libs.htmldiff.HTMLMatcher.set_seq2 (   self,
  b 
) [inherited]

Reimplemented in CMFDiffTool.libs.htmldiff.TextMatcher.

Definition at line 34 of file htmldiff.py.

00034 
00035     def set_seq2(self, b):
00036         SequenceMatcher.set_seq2(self, self.splitHTML(b))
        

Here is the call graph for this function:

def CMFDiffTool.libs.htmldiff.HTMLMatcher.splitHTML (   self,
  t 
) [inherited]

Definition at line 53 of file htmldiff.py.

00053 
00054     def splitHTML(self, t):
00055         t = commentRE.sub('', t)
00056         r = self.splitTags(t)
00057         result = []
00058         for item in r:
00059             if item.startswith('<'):
00060                 result.append(item)
00061             else:
00062                 result.extend(self.splitWords(item))
00063         return result

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFDiffTool.libs.htmldiff.HTMLMatcher.splitTags (   self,
  t 
) [inherited]

Definition at line 37 of file htmldiff.py.

00037 
00038     def splitTags(self, t):
00039         result = []
00040         pos = 0
00041         while 1:
00042             match = tagRE.search(t, pos=pos)
00043             if not match:
00044                 result.append(t[pos:])
00045                 break
00046             result.append(t[pos:match.start()])
00047             result.append(match.group(0))
00048             pos = match.end()
00049         return result

Here is the caller graph for this function:

def CMFDiffTool.libs.htmldiff.HTMLMatcher.splitWords (   self,
  t 
) [inherited]

Definition at line 50 of file htmldiff.py.

00050 
00051     def splitWords(self, t):
00052         return t.strip().split()

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from CMFDiffTool.libs.htmldiff.HTMLMatcher.

Definition at line 184 of file htmldiff.py.

00184 
00185     def startDeleteText(self):
        return '-['

Reimplemented from CMFDiffTool.libs.htmldiff.HTMLMatcher.

Definition at line 180 of file htmldiff.py.

00180 
00181     def startInsertText(self):
        return '+['

Definition at line 121 of file htmldiff.py.

00121 
00122     def stylesheet(self):
00123         return '''
00124 .insert { background-color: #aaffaa }
00125 .delete { background-color: #ff8888 }
00126 .tagInsert { background-color: #007700; color: #ffffff }
00127 .tagDelete { background-color: #770000; color: #ffffff }
00128 '''

Here is the caller graph for this function:

def CMFDiffTool.libs.htmldiff.HTMLMatcher.textDelete (   self,
  lst,
  out 
) [inherited]

Definition at line 85 of file htmldiff.py.

00085 
00086     def textDelete(self, lst, out):
00087         inSpan = False
00088         for item in lst:
00089             if item.startswith('<'):
00090                 if inSpan:
00091                     out.write(self.endDeleteText())
00092                     inSpan = False
00093                 out.write(self.formatDeleteTag(item))
00094             else:
00095                 if not inSpan:
00096                     out.write(self.startDeleteText())
00097                     inSpan = True
00098                 out.write(item)
00099                 out.write(' ')
00100         if inSpan:
00101             out.write(self.endDeleteText())

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFDiffTool.libs.htmldiff.HTMLMatcher.textInsert (   self,
  lst,
  out 
) [inherited]

Definition at line 102 of file htmldiff.py.

00102 
00103     def textInsert(self, lst, out):
00104         inSpan = False
00105         for item in lst:
00106             if item.startswith('<'):
00107                 if inSpan:
00108                     out.write(self.endInsertText())
00109                     inSpan = False
00110                 out.write(self.formatInsertTag(item))
00111                 out.write(item)
00112                 out.write(' ')
00113             else:
00114                 if not inSpan:
00115                     out.write(self.startInsertText())
00116                     inSpan = True
00117                 out.write(item)
00118                 out.write(' ')
00119         if inSpan:
00120             out.write(self.endInsertText())

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following file: