예제 #1
0
    def _render_change_replace_lines(self, differ, i1, i2, j1, j2, old_lines,
                                     new_lines):
        replace_new_lines = []

        for i, j in zip(range(i1, i2), range(j1, j2)):
            old_line = old_lines[i]
            new_line = new_lines[j]

            parser = HTMLParser()

            old_regions, new_regions = \
                get_line_changed_regions(parser.unescape(strip_tags(old_line)),
                                         parser.unescape(strip_tags(new_line)))

            old_line = highlightregion(old_line, old_regions)
            new_line = highlightregion(new_line, new_regions)

            yield ('<tr class="replace-old">'
                   ' <td class="marker">~</td>'
                   ' <td class="marker">&nbsp;</td>'
                   ' <td class="line rich-text">%s</td>'
                   '</tr>' % old_line)

            replace_new_lines.append(new_line)

        for line in replace_new_lines:
            yield ('<tr class="replace-new">'
                   ' <td class="marker">&nbsp;</td>'
                   ' <td class="marker">~</td>'
                   ' <td class="line rich-text">%s</td>'
                   '</tr>' % line)
예제 #2
0
    def _render_change_replace_lines(self, differ, i1, i2, j1, j2,
                                     old_lines, new_lines):
        replace_new_lines = []

        for i, j in zip(range(i1, i2), range(j1, j2)):
            old_line = old_lines[i]
            new_line = new_lines[j]

            parser = HTMLParser()

            old_regions, new_regions = \
                get_line_changed_regions(parser.unescape(strip_tags(old_line)),
                                         parser.unescape(strip_tags(new_line)))

            old_line = highlightregion(old_line, old_regions)
            new_line = highlightregion(new_line, new_regions)

            yield (
                '<tr class="replace-old">'
                ' <td class="marker">~</td>'
                ' <td class="marker">&nbsp;</td>'
                ' <td class="line rich-text">%s</td>'
                '</tr>'
                % old_line)

            replace_new_lines.append(new_line)

        for line in replace_new_lines:
            yield (
                '<tr class="replace-new">'
                ' <td class="marker">&nbsp;</td>'
                ' <td class="marker">~</td>'
                ' <td class="line rich-text">%s</td>'
                '</tr>'
                % line)
예제 #3
0
 def end_string(self):
     h = HTMLParser()
     data = h.unescape(force_text(self.getData()))
     if data == '__PyNone__':
         self.addObject(None)
     else:
         self.addObject(data)
 def test_is_html_escaped(self):
     """Unescape the escaped response to see if it's the original content"""
     h = HTMLParser()
     content = '*****@*****.**'
     self.assertEqual(h.unescape(
         force_text(self.middleware.process_response(None, HttpResponse(content)).content)),
         content)
예제 #5
0
 def end_string(self):
     h = HTMLParser()
     data = h.unescape(force_text(self.getData()))
     if data == '__PyNone__':
         self.addObject(None)
     else:
         self.addObject(data)
예제 #6
0
 def unescape(s):
     return HTMLParser().unescape(s)
예제 #7
0
def plain_text(html):
    h = HTMLParser()
    return h.unescape(strip_tags(html))
예제 #8
0
 def __init__(self):
     HTMLParser.__init__(self)
     self.html = str()
예제 #9
0
파일: renderer.py 프로젝트: maur1th/naxos
 def __init__(self):
     HTMLParser.__init__(self, convert_charrefs=False)
     self.html = str()
예제 #10
0
 def end_data(self):
     h = HTMLParser()
     value = h.unescape(force_text(
         plistlib.Data.fromBase64(self.getData()).data
     ))
     self.addObject(value)
예제 #11
0
 def __init__(self):
     HTMLParser.__init__(self, convert_charrefs=False)
     self.html = str()
예제 #12
0
    def setUpClass(cls):
        super(QuerystringTagTests, cls).setUpClass()

        cls.html_parser = HTMLParser()
예제 #13
0
 def __init__(self, *args, **kwargs):
     HTMLParser.__init__(self, *args, **kwargs)
     self.is_idle = 0
     self.last_abbr = None
     self.last_link = None
     self.text_fragments = []
예제 #14
0
 def __init__(self, *args, **kwargs):
     HTMLParser.__init__(self, *args, **kwargs)
     self.open_tags = []
예제 #15
0
 def end_data(self):
     h = HTMLParser()
     value = h.unescape(
         force_text(plistlib.Data.fromBase64(self.getData()).data))
     self.addObject(value)
예제 #16
0
def plain_text(html):
    h = HTMLParser()
    return h.unescape(strip_tags(html))