@@ -375,11 +375,15 @@ def _translate(self):
375
375
cellstyle_map : DefaultDict [Tuple [CSSPair , ...], List [str ]] = defaultdict (list )
376
376
377
377
# copied attributes
378
- table_styles = self .table_styles or []
379
- caption = self .caption
380
378
hidden_index = self .hidden_index
381
379
hidden_columns = self .hidden_columns
382
- uuid = self .uuid
380
+
381
+ # construct render dict
382
+ d = {
383
+ "uuid" : self .uuid ,
384
+ "table_styles" : _format_table_styles (self .table_styles or []),
385
+ "caption" : self .caption ,
386
+ }
383
387
384
388
# for sparsifying a MultiIndex
385
389
idx_lengths = _get_level_lengths (self .index )
@@ -468,6 +472,7 @@ def _translate(self):
468
472
)
469
473
470
474
head .append (index_header_row )
475
+ d .update ({"head" : head })
471
476
472
477
body = []
473
478
for r , row_tup in enumerate (self .data .itertuples ()):
@@ -517,11 +522,13 @@ def _translate(self):
517
522
if props : # (), [] won't be in cellstyle_map, cellstyle respectively
518
523
cellstyle_map [tuple (props )].append (f"row{ r } _col{ c } " )
519
524
body .append (row_es )
525
+ d .update ({"body" : body })
520
526
521
527
cellstyle : List [Dict [str , Union [CSSList , List [str ]]]] = [
522
528
{"props" : list (props ), "selectors" : selectors }
523
529
for props , selectors in cellstyle_map .items ()
524
530
]
531
+ d .update ({"cellstyle" : cellstyle })
525
532
526
533
table_attr = self .table_attributes
527
534
use_mathjax = get_option ("display.html.use_mathjax" )
@@ -531,16 +538,8 @@ def _translate(self):
531
538
table_attr = table_attr .replace ('class="' , 'class="tex2jax_ignore ' )
532
539
else :
533
540
table_attr += ' class="tex2jax_ignore"'
541
+ d .update ({"table_attributes" : table_attr })
534
542
535
- d = {
536
- "head" : head ,
537
- "cellstyle" : cellstyle ,
538
- "body" : body ,
539
- "uuid" : uuid ,
540
- "table_styles" : _format_table_styles (table_styles ),
541
- "caption" : caption ,
542
- "table_attributes" : table_attr ,
543
- }
544
543
if self .tooltips :
545
544
d = self .tooltips ._translate (self .data , self .uuid , d )
546
545
0 commit comments