Пример #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
 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))