Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Add option to disable MathJax (#19824). #19856

Merged
merged 11 commits into from
Mar 1, 2018
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IPython -> Jupyter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll change this, but just want to let you know that I used IPython instead of Jupyter for consistency with the documentation for other options. Perhaps these also need updating?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that'd be good to correct them all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are 148 matches across 41 files for IPython (case sensitive). Not all of these need changing – it's quite nuanced. This is probably better left for a separate PR.

With regards to this PR, shall I use Jupyter or IPython when documenting this new option?

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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.23.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ Other Enhancements
- :class:`IntervalIndex` and its associated constructor methods (``from_arrays``, ``from_breaks``, ``from_tuples``) have gained a ``dtype`` parameter (:issue:`19262`)
- Added :func:`SeriesGroupBy.is_monotonic_increasing` and :func:`SeriesGroupBy.is_monotonic_decreasing` (:issue:`17015`)
- :func:`DataFrame.from_dict` now accepts a ``columns`` argument that can be used to specify the column names when ``orient='index'`` is used (:issue:`18529`)
- Added option ``display.html.use_mathjax`` so that MathJax can be disabled when rendering DataFrames in Jupyter notebooks (:issue:`19856`, :issue:`#19824`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no # in the issue number

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double backticks on DataFrame and Jupyter

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a link for MathJax?


.. _whatsnew_0230.api_breaking:

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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IPython -> Jupyter

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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this only should be here an not in HTMLFormatter itself?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about Series._repr_html ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the reason it is not in HTMLFormatter is that MathJax is a feature of the Jupyter environment, and so this is specific to _repr_html_. See #19824 (comment).

I agree that this should apply to Series too.

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