Commit cb4ac95d authored by Vaibhav Sagar's avatar Vaibhav Sagar

ipython-kernel: support custom mimetypes

parent d98969dc
...@@ -779,6 +779,7 @@ data MimeType = PlainText ...@@ -779,6 +779,7 @@ data MimeType = PlainText
| MimeVega | MimeVega
| MimeVegalite | MimeVegalite
| MimeVdom | MimeVdom
| MimeCustom Text
deriving (Eq, Typeable, Generic) deriving (Eq, Typeable, Generic)
-- Extract the plain text from a list of displays. -- Extract the plain text from a list of displays.
...@@ -806,6 +807,7 @@ instance Show MimeType where ...@@ -806,6 +807,7 @@ instance Show MimeType where
show MimeVega = "application/vnd.vega.v2+json" show MimeVega = "application/vnd.vega.v2+json"
show MimeVegalite = "application/vnd.vegalite.v2+json" show MimeVegalite = "application/vnd.vegalite.v2+json"
show MimeVdom = "application/vdom.v1+json" show MimeVdom = "application/vdom.v1+json"
show (MimeCustom custom) = Text.unpack custom
instance Read MimeType where instance Read MimeType where
readsPrec _ "text/plain" = [(PlainText, "")] readsPrec _ "text/plain" = [(PlainText, "")]
...@@ -822,7 +824,7 @@ instance Read MimeType where ...@@ -822,7 +824,7 @@ instance Read MimeType where
readsPrec _ "application/vnd.vega.v2+json" = [(MimeVega, "")] readsPrec _ "application/vnd.vega.v2+json" = [(MimeVega, "")]
readsPrec _ "application/vnd.vegalite.v1+json" = [(MimeVegalite, "")] readsPrec _ "application/vnd.vegalite.v1+json" = [(MimeVegalite, "")]
readsPrec _ "application/vdom.v1+json" = [(MimeVdom, "")] readsPrec _ "application/vdom.v1+json" = [(MimeVdom, "")]
readsPrec _ _ = [] readsPrec _ t = [(MimeCustom (Text.pack t), "")]
-- | Convert a MIME type and value into a JSON dictionary pair. -- | Convert a MIME type and value into a JSON dictionary pair.
displayDataToJson :: DisplayData -> (Text, Value) displayDataToJson :: DisplayData -> (Text, Value)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment