Back to index

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

List of all members.

Public Member Functions

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

Detailed Description

Definition at line 26 of file htmldiff.py.


Constructor & Destructor Documentation

def CMFDiffTool.libs.htmldiff.HTMLMatcher.__init__ (   self,
  source1,
  source2 
)

Definition at line 28 of file htmldiff.py.

00028 
00029     def __init__(self, source1, source2):
00030         SequenceMatcher.__init__(self, None, source1, source2)


Member Function Documentation

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

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 in CMFDiffTool.libs.htmldiff.SimpleHTMLMatcher.

Definition at line 144 of file htmldiff.py.

00144 
00145     def endDeleteText(self):
        return '</span> '

Here is the caller graph for this function:

Reimplemented in CMFDiffTool.libs.htmldiff.SimpleHTMLMatcher.

Definition at line 140 of file htmldiff.py.

00140 
00141     def endInsertText(self):
        return '</span> '

Here is the caller graph for this function:

Reimplemented in CMFDiffTool.libs.htmldiff.SimpleHTMLMatcher, and CMFDiffTool.libs.htmldiff.NoTagHTMLMatcher.

Definition at line 148 of file htmldiff.py.

00148 
00149     def formatDeleteTag(self, tag):
00150         return '<span class="tagDelete">delete: <tt>%s</tt></span> ' % htmlEncode(tag)

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented in CMFDiffTool.libs.htmldiff.SimpleHTMLMatcher, and CMFDiffTool.libs.htmldiff.NoTagHTMLMatcher.

Definition at line 146 of file htmldiff.py.

00146 
00147     def formatInsertTag(self, tag):
        return '<span class="tagInsert">insert: <tt>%s</tt></span> ' % htmlEncode(tag)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFDiffTool.libs.htmldiff.HTMLMatcher.htmlDiff (   self,
  addStylesheet = False 
)

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:

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:

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:

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:

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:

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 in CMFDiffTool.libs.htmldiff.SimpleHTMLMatcher.

Definition at line 142 of file htmldiff.py.

00142 
00143     def startDeleteText(self):
        return '<span class="delete">'

Here is the caller graph for this function:

Reimplemented in CMFDiffTool.libs.htmldiff.SimpleHTMLMatcher.

Definition at line 138 of file htmldiff.py.

00138 
00139     def startInsertText(self):
        return '<span class="insert">'

Here is the caller graph for this function:

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 
)

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 
)

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: