Example #1
0
def aim_to_xhtml(s):
    '''Wraps AIM HTML which might have <html> and <body> with a <span>.'''

    s, bgcolor = _remove_html_cruft(s)

    if bgcolor:
        bgstyle = ' style="background: %s;"' % dequote(bgcolor)
    else:
        bgstyle = ''

    return u'<div%s>%s</div>' % (bgstyle, preserve_whitespace(s))
    def test_preserve_whitespace(self):
        cases = [
            ('', ''),
            ('test', 'test'),
            ('<b>test</b>', '<b>test</b>'),
            (' ', ' '),
            ('  ', '&nbsp;&nbsp;'),
            ('   ', '&nbsp;&nbsp;&nbsp;'),
            ('test abc\ndef', 'test abc<br />def'),
        ]

        for inp, expected in cases:
            self.expect_equal(expected, preserve_whitespace(inp))
Example #3
0
    def test_preserve_whitespace(self):
        cases = [
            ('', ''),
            ('test', 'test'),
            ('<b>test</b>', '<b>test</b>'),
            (' ', ' '),
            ('  ', '&nbsp;&nbsp;'),
            ('   ', '&nbsp;&nbsp;&nbsp;'),
            ('test abc\ndef', 'test abc<br />def'),
        ]

        for inp, expected in cases:
            self.expect_equal(expected, preserve_whitespace(inp))