@pytest.mark.skipif('not HAS_BLEACH')
def test_raw_html_write_clean():
 import bleach
 t = Table([['<script>x</script>'], ['<p>y</p>'], ['<em>y</em>']], names=['a', 'b', 'c'])
 out = StringIO()
 t.write(out, format='ascii.html', htmldict={'raw_html_cols': t.colnames})
 expected = '   <tr>\n    <td>&lt;script&gt;x&lt;/script&gt;</td>\n    <td>&lt;p&gt;y&lt;/p&gt;</td>\n    <td><em>y</em></td>\n   </tr>'
 assert (expected in out.getvalue())
 out = StringIO()
 t.write(out, format='ascii.html', htmldict={'raw_html_cols': t.colnames, 'raw_html_clean_kwargs': {'tags': (bleach.ALLOWED_TAGS + ['p'])}})
 expected = '   <tr>\n    <td>&lt;script&gt;x&lt;/script&gt;</td>\n    <td><p>y</p></td>\n    <td><em>y</em></td>\n   </tr>'
 assert (expected in out.getvalue())

@ pytest . mark . skipif ( 'not HAS_BLEACH' ) def test_raw_html_write_clean ( ) : import bleach t = Table ( [ [ '<script>x</script>' ] , [ '<p>y</p>' ] , [ '<em>y</em>' ] ] , names = [ 'a' , 'b' , 'c' ] ) out = StringIO ( ) t . write ( out , format = 'ascii.html' , htmldict = { 'raw_html_cols' : t . colnames } ) expected = '   <tr>\n    <td>&lt;script&gt;x&lt;/script&gt;</td>\n    <td>&lt;p&gt;y&lt;/p&gt;</td>\n    <td><em>y</em></td>\n   </tr>' assert ( expected in out . getvalue ( ) ) out = StringIO ( ) t . write ( out , format = 'ascii.html' , htmldict = { 'raw_html_cols' : t . colnames , 'raw_html_clean_kwargs' : { 'tags' : ( bleach . ALLOWED_TAGS + [ 'p' ] ) } } ) expected = '   <tr>\n    <td>&lt;script&gt;x&lt;/script&gt;</td>\n    <td><p>y</p></td>\n    <td><em>y</em></td>\n   </tr>' assert ( expected in out . getvalue ( ) )
test that columns can contain raw html which is not escaped .