- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 422
fix display(d, m, x) where m expects a json string #756
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
base: master
Are you sure you want to change the base?
Changes from 3 commits
fd2a82f
              f9aea33
              4e3a87e
              bd4afe7
              048f73b
              1dfd237
              92b55f5
              8a7da6c
              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 | 
|---|---|---|
|  | @@ -8,6 +8,7 @@ const ipy_mime = [ | |
| "application/vnd.dataresource+json", | ||
| "application/vnd.vegalite.v2+json", | ||
| "application/vnd.vega.v3+json", | ||
| "application/vnd.vega.v4+json", | ||
| "text/html", | ||
| "text/latex", | ||
| "image/svg+xml", | ||
|  | @@ -47,14 +48,29 @@ function limitstringmime(mime::MIME, x) | |
| return String(take!(buf)) | ||
| end | ||
|  | ||
| const ipy_mime_json = [ | ||
| "application/vnd.dataresource+json", | ||
| "application/vnd.vegalite.v2+json", | ||
| "application/vnd.vega.v3+json", | ||
| "application/vnd.vega.v4+json", | ||
| ] | ||
| _display_dict(m::MIME, m_str, x) = Dict(m_str=>limitstringmime(m, x)) | ||
| # escape JSON string correctly before send_ipython | ||
| for mime in ipy_mime_json | ||
| @eval begin | ||
| _display_dict(m::MIME{Symbol($mime)}, m_str, x) = Dict(m_str=>JSON.JSONText(limitstringmime(m, x))) | ||
| Base.Multimedia.istextmime(::MIME{Symbol($mime)}) = true | ||
|          | ||
| end | ||
| end | ||
|  | ||
| for mime in ipy_mime | ||
| @eval begin | ||
| function display(d::InlineDisplay, ::MIME{Symbol($mime)}, x) | ||
| send_ipython(publish[], | ||
| msg_pub(execute_msg, "display_data", | ||
| Dict( | ||
| "metadata" => metadata(x), # optional | ||
| "data" => Dict($mime => limitstringmime(MIME($mime), x))))) | ||
| "data" => _display_dict(MIME($mime), $mime, x)))) | ||
|          | ||
| end | ||
| displayable(d::InlineDisplay, ::MIME{Symbol($mime)}) = true | ||
| end | ||
|  | ||
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 also needs to be handled in the
display_dictfunction, I think.