@@ -63,6 +63,8 @@ class Styler(object):
63
63
a unique identifier to avoid CSS collisons; generated automatically
64
64
caption: str, default None
65
65
caption to attach to the table
66
+ disabled_mathjax: bool, default False
67
+ prevent MathJax from processing table contents
66
68
67
69
Attributes
68
70
----------
@@ -111,7 +113,7 @@ class Styler(object):
111
113
template = env .get_template ("html.tpl" )
112
114
113
115
def __init__ (self , data , precision = None , table_styles = None , uuid = None ,
114
- caption = None , table_attributes = None ):
116
+ caption = None , disabled_mathjax = False , table_attributes = None ):
115
117
self .ctx = defaultdict (list )
116
118
self ._todo = []
117
119
@@ -129,6 +131,7 @@ def __init__(self, data, precision=None, table_styles=None, uuid=None,
129
131
self .uuid = uuid
130
132
self .table_styles = table_styles
131
133
self .caption = caption
134
+ self .disabled_mathjax = disabled_mathjax
132
135
if precision is None :
133
136
precision = get_option ('display.precision' )
134
137
self .precision = precision
@@ -181,6 +184,7 @@ def _translate(self):
181
184
"""
182
185
table_styles = self .table_styles or []
183
186
caption = self .caption
187
+ disabled_mathjax = self .disabled_mathjax
184
188
ctx = self .ctx
185
189
precision = self .precision
186
190
hidden_index = self .hidden_index
@@ -327,7 +331,8 @@ def format_attr(pair):
327
331
328
332
return dict (head = head , cellstyle = cellstyle , body = body , uuid = uuid ,
329
333
precision = precision , table_styles = table_styles ,
330
- caption = caption , table_attributes = self .table_attributes )
334
+ caption = caption , disabled_mathjax = disabled_mathjax ,
335
+ table_attributes = self .table_attributes )
331
336
332
337
def format (self , formatter , subset = None ):
333
338
"""
@@ -431,6 +436,7 @@ def render(self, **kwargs):
431
436
* precision
432
437
* table_styles
433
438
* caption
439
+ * disabled_mathjax
434
440
* table_attributes
435
441
"""
436
442
self ._compute ()
@@ -465,6 +471,7 @@ def _update_ctx(self, attrs):
465
471
def _copy (self , deepcopy = False ):
466
472
styler = Styler (self .data , precision = self .precision ,
467
473
caption = self .caption , uuid = self .uuid ,
474
+ disabled_mathjax = self .disabled_mathjax ,
468
475
table_styles = self .table_styles )
469
476
if deepcopy :
470
477
styler .ctx = copy .deepcopy (self .ctx )
@@ -794,6 +801,17 @@ def set_table_styles(self, table_styles):
794
801
self .table_styles = table_styles
795
802
return self
796
803
804
+ def disable_mathjax (self ):
805
+ """
806
+ Prevent MathJax from processing table contents.
807
+
808
+ Returns
809
+ -------
810
+ self : Styler
811
+ """
812
+ self .disabled_mathjax = True
813
+ return self
814
+
797
815
def hide_index (self ):
798
816
"""
799
817
Hide any indices from rendering.
0 commit comments