-
Notifications
You must be signed in to change notification settings - Fork 568
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
Fixed latex export for svg data in python 3 #985
Conversation
not isinstance(data, text_type) | ||
or mime_type == 'application/json' | ||
): | ||
if mime_type == 'application/json': |
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.
This is too strict and will break some data types; compare with even a partial listing here: https://jupyter.readthedocs.io/en/latest/reference/mimetype.html
Also this change invalidates the follow-up comment, please keep them in sync.
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.
Fair point on the strictness.
In the original implementation I've relied on the nbformat spec that guaranteed that json data is parsed directly and not serialized. I don't actually understand why that bit requires changing to support svg: IIUC svg should be of text-type and shouldn't be treated as json by that code. |
If you only add the svg test I added you'll see if fails for python 3 in the same way the original issue describes. The I'll look into the test case I added and see if there's a less strict way to solve the issue. |
At the very least lists/dicts should be detected as definitely json |
I looked into the failing pattern, it's when the mimetype is I changed the implementation to mirror the original behavior more closely, with just logically moving the base64 data type checks in front of the json / text checks. Can you take a look again @akhmerov for any issue you can see? |
Thanks for the review! |
Fixes #981
Verified that the rendered latex output matches python 2 output visually. This will probably fix other python exports outside of latex svg given the code path involved in the fix.