Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The appearance of tables strongly depends of the active CSS attributes applying to them. For example, as shown in the screen capture below, if you add and evaluate the following code in a Jupyter notebook, you will get tables more similar to those in SageCell:

%%html
<style>
table.table_form{
    border: 1px solid gray;
    border-collapse: separate;
    border-spacing: 2px;}
table.table_form td {
    border: 1px solid gray;
    padding: 5px 15px; 
    color: #00a;
    background-color: #f8f8f8;
    text-align: left;
    font-size:medium}
</style>

image description

Now, consider the code

rows = [[100,2,3], [4,5,60]]
t = table(rows, frame=True)
print(html(t))

The output is

<div class="notruncate">
<table border="1" class="table_form">
<tbody>
<tr class ="row-a">
<td><script type="math/tex">100</script></td>
<td><script type="math/tex">2</script></td>
<td><script type="math/tex">3</script></td>
</tr>
<tr class ="row-b">
<td><script type="math/tex">4</script></td>
<td><script type="math/tex">5</script></td>
<td><script type="math/tex">60</script></td>
</tr>
</tbody>
</table>
</div>

Look at the second line. The border attribute of table is not longer supported in HTML5. Since it has no effect in a modern browser, the frame is not shown.

In SageCell, however, the frame option works. So I imagine that the base code has been modified somehow. Quite surely the same patch could be applied for Jupyter notebooks.

Reading $SAGE_SRC/sage/misc/table.py, it seems that the problem comes from lines 720-723, that is,

if self._options['frame']:
        frame = 'border="1"'
    else:
        frame = ''

Perhaps it would suffice to replace frame = 'border="1"' by

frame = 'style="border-style: solid"'

or something similar.