html

Some HTML Utilities

source

td

 td (obj)

Create a table entry from string or object with html representation.

If an object is not a string, try to use its _repr_html_ method:

test_eq(td("abc"), '<td style="text-align:left;">abc</td>')

class MyClass:
    def _repr_html_(self): return "<span>blah</span>"
test_eq(td(MyClass()), '<td style="text-align:left;"><span>blah</span></td>')

source

th

 th (cells)

Create a table header


source

tr

 tr (cells)

Create a table row


source

ROW

 ROW (cells)

source

row

 row (cells)

Create a table with a single row


source

table

 table (rows, header='', cls:str='gtbook_table')

Create a table from rows

Create a table row

test_eq(tr(["a", "b"]),'<tr>\n<td style="text-align:left;">a</td>\n<td style="text-align:left;">b</td>\n</tr>')
from IPython.display import HTML
1 2
a b
c d
HTML(table([tr(["a", "b"]), tr(["c", "d"])], header=th(["1", "2"])))
HTML(table([tr(["a", "b"]) for j in range(4)]))
a b
a b
a b
a b
import gtsam
from gtbook.display import show
prior = gtsam.DiscreteDistribution((0,2),"3/1")
HTML(row([prior, prior]))

P(0):

0 value
0 0.75
1 0.25

P(0):

0 value
0 0.75
1 0.25
ROW([prior, show(prior)])

P(0):

0 value
0 0.75
1 0.25
G 0x106c1ce80 0 0x106c15460 0.75 0x106c1ce80->0x106c15460 0x106c1bca0 0.25 0x106c1ce80->0x106c1bca0