-
-
Notifications
You must be signed in to change notification settings - Fork 425
Open
Description
display(::InlineDisplay, x) calls display_dict(x) which iterates through ijulia_mime_types and ijulia_jsonmime_types separately, and calls display_mimestring and display_mimejson as appropriate. In contrast, display(::InlineDisplay, ::MIME, x) always calls display_mimestring. The underlying problem is that there is no way of telling whether a given MIME type should be treated as JSON or not.
What's needed is a function isjsonmime which functions similarly to Base.istextmime. A simple implementation would just be to check whether the mime type is in ijulia_jsonmime_types.
I think a better implementation would be to encode JSON-ness in a type trait, like the following:
abstract type MIMEFormat end
struct TextMIME <: MIMEFormat end
struct BinaryMIME <: MIMEFormat end
struct JSONMIME <: MIMEFormat end
MIMEFormat(mime::MIME) = istextmime(mime) ? TextMIME() : BinaryMIME()
for M in ijulia_jsonmime_types
MIMEFormat(::M) = JSONMIME()
endThis would eliminate the need for separate JSON versions of many methods.
Metadata
Metadata
Assignees
Labels
No labels