-
-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
Changes from 9 commits
3df97e3
f48f587
9d97bfd
89659cd
95f7d14
5c71bf1
9b287aa
400f211
15961e1
771e9a6
42224c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1434,6 +1434,13 @@ def test_repr_html(self): | |
|
||
tm.reset_display_options() | ||
|
||
def test_repr_html_mathjax(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add a test for Series as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't have a repr_html for series yet. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok then! |
||
df = DataFrame([[1, 2], [3, 4]]) | ||
assert 'tex2jax_ignore' not in df._repr_html_() | ||
|
||
with pd.option_context('display.html.use_mathjax', False): | ||
assert 'tex2jax_ignore' in df._repr_html_() | ||
|
||
def test_repr_html_wide(self): | ||
max_cols = get_option('display.max_columns') | ||
df = DataFrame(tm.rands_array(25, size=(10, max_cols - 1))) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, I'm not sure about the option affecting
Styler
. Does anyone else (@jorisvandenbossche, @chris-b1) have thoughts?Adding classes to the
Styler
is pretty easy, and you're always able to add them since you're generating the Styler. WithDataFrame._repr_html
, you don't have that option.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's true this issue is solved by
df.style.set_table_attributes('class="tex2jax_ignore"')
. One could argue that this PR is unnecessary because the solution is already possible in pandas.But this solution requires knowledge of how MathJax works – something that I've learnt whilst making this PR. The new option
display.html.use_mathjax
is there to make it easier for users to find the solution.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be clear, the changes to frames repr html are great.
I just worry about injecting “noise” into Styler’s generated HTML from a config option, when it’s relatively easy to do that yourself.
That said, an extra class isn’t the worst thing in the world, and it’s simple to toggle on and off. Your current PR is probably fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I could see the argument for not doing it in
Styler
but I agree the PR is fine, especially where it is off by default, and is sort of an obscure thing to look up.