示例#1
0
        def to_safe_html(markup):
            # keep empty data (whatever it is), it makes transform unhappy
            if not markup:
                return markup

            markup = markup.decode('utf-8')
            markup = trix2sablon.convert(markup)
            return trix_strip_whitespace(markup)
示例#2
0
        def to_safe_html(markup):
            # keep empty data (whatever it is), it makes transform unhappy
            if not markup:
                return markup

            markup = markup.decode('utf-8')
            markup = trix2sablon.convert(markup)
            return trix_strip_whitespace(markup)
 def test_strips_trailing_whitespace(self):
     self.assertEqual(
         u'<div>b\xe4r\t\r\nqux</div>',
         trix_strip_whitespace(
             u'<div>b\xe4r\t\r\nqux&nbsp;&nbsp;<br /><br/> \n</div>'))
 def test_strips_leading_whitepace(self):
     self.assertEqual(
         u'<div>f\xf6  \nbar</div>',
         trix_strip_whitespace(
             u'<div>\t&nbsp; <br> \n\r\v  f\xf6  \nbar</div>'))
 def test_preserves_empty_string(self):
     self.assertEqual(u'', trix_strip_whitespace(u''))
 def test_preserves_none(self):
     self.assertIsNone(trix_strip_whitespace(None))
示例#7
0
 def test_strips_leading_whitepace(self):
     self.assertEqual(
         u'<div>f\xf6  \nbar</div>',
         trix_strip_whitespace(u'<div>\t&nbsp; <br> \n\r\v  f\xf6  \nbar</div>'))
示例#8
0
 def test_preserves_empty_string(self):
     self.assertEqual(u'', trix_strip_whitespace(u''))
示例#9
0
 def test_preserves_none(self):
     self.assertIsNone(trix_strip_whitespace(None))
示例#10
0
 def test_strips_trailing_whitespace(self):
     self.assertEqual(
         u'<div>b\xe4r\t\r\nqux</div>',
         trix_strip_whitespace(u'<div>b\xe4r\t\r\nqux&nbsp;&nbsp;<br /><br/> \n</div>'))