@@ -63,6 +63,8 @@ class Styler(object):
6363 a unique identifier to avoid CSS collisons; generated automatically
6464 caption: str, default None
6565 caption to attach to the table
66+ disabled_mathjax: bool, default False
67+ prevent MathJax from processing table contents
6668
6769 Attributes
6870 ----------
@@ -111,7 +113,7 @@ class Styler(object):
111113 template = env .get_template ("html.tpl" )
112114
113115 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 ):
115117 self .ctx = defaultdict (list )
116118 self ._todo = []
117119
@@ -129,6 +131,7 @@ def __init__(self, data, precision=None, table_styles=None, uuid=None,
129131 self .uuid = uuid
130132 self .table_styles = table_styles
131133 self .caption = caption
134+ self .disabled_mathjax = disabled_mathjax
132135 if precision is None :
133136 precision = get_option ('display.precision' )
134137 self .precision = precision
@@ -181,6 +184,7 @@ def _translate(self):
181184 """
182185 table_styles = self .table_styles or []
183186 caption = self .caption
187+ disabled_mathjax = self .disabled_mathjax
184188 ctx = self .ctx
185189 precision = self .precision
186190 hidden_index = self .hidden_index
@@ -327,7 +331,8 @@ def format_attr(pair):
327331
328332 return dict (head = head , cellstyle = cellstyle , body = body , uuid = uuid ,
329333 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 )
331336
332337 def format (self , formatter , subset = None ):
333338 """
@@ -431,6 +436,7 @@ def render(self, **kwargs):
431436 * precision
432437 * table_styles
433438 * caption
439+ * disabled_mathjax
434440 * table_attributes
435441 """
436442 self ._compute ()
@@ -465,6 +471,7 @@ def _update_ctx(self, attrs):
465471 def _copy (self , deepcopy = False ):
466472 styler = Styler (self .data , precision = self .precision ,
467473 caption = self .caption , uuid = self .uuid ,
474+ disabled_mathjax = self .disabled_mathjax ,
468475 table_styles = self .table_styles )
469476 if deepcopy :
470477 styler .ctx = copy .deepcopy (self .ctx )
@@ -794,6 +801,17 @@ def set_table_styles(self, table_styles):
794801 self .table_styles = table_styles
795802 return self
796803
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+
797815 def hide_index (self ):
798816 """
799817 Hide any indices from rendering.
0 commit comments