Skip to content

Commit

Permalink
ENH: Add display.html.use_mathjax option (pandas-dev#19824).
Browse files Browse the repository at this point in the history
Default value is True to maintain existing behavior.
  • Loading branch information
David Hall committed Feb 24, 2018
1 parent f48f587 commit 9d97bfd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions doc/source/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@ display.html.table_schema False Whether to publish a Table
display.html.border 1 A ``border=value`` attribute is
inserted in the ``<table>`` tag
for the DataFrame HTML repr.
display.html.use_mathjax True When True, IPython notebook will process
table contents using MathJax, rendering
mathematical expressions enclosed by the
dollar symbol.
io.excel.xls.writer xlwt The default Excel writer engine for
'xls' files.
io.excel.xlsm.writer openpyxl The default Excel writer engine for
Expand Down
8 changes: 8 additions & 0 deletions pandas/core/config_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ def use_numexpr_cb(key):
(currently both are identical)
"""

pc_html_use_mathjax_doc = """\
: boolean
When True, IPython notebook will process table contents using MathJax,
rendering mathematical expressions enclosed by the dollar symbol.
(default: True)
"""

pc_width_doc = """
: int
Expand Down Expand Up @@ -358,6 +364,8 @@ def table_schema_cb(key):
validator=is_bool, cb=table_schema_cb)
cf.register_option('html.border', 1, pc_html_border_doc,
validator=is_int)
cf.register_option('html.use_mathjax', True, pc_html_use_mathjax_doc,
validator=is_bool)

with cf.config_prefix('html'):
cf.register_option('border', 1, pc_html_border_doc,
Expand Down
6 changes: 6 additions & 0 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,14 @@ def _repr_html_(self):
max_rows = get_option("display.max_rows")
max_cols = get_option("display.max_columns")
show_dimensions = get_option("display.show_dimensions")
use_mathjax = get_option("display.html.use_mathjax")

classes = []
if not use_mathjax:
classes.append('tex2jax_ignore')

return self.to_html(max_rows=max_rows, max_cols=max_cols,
classes=classes,
show_dimensions=show_dimensions, notebook=True)
else:
return None
Expand Down

0 comments on commit 9d97bfd

Please sign in to comment.