fix!(ipynb writer): improve round trip identity

for raw cell output

BREAKING CHANGE:
The Jupyter ecosystem, including nbconvert, lab and notebook,
deviated from their own spec in nbformat,
where they used the key `raw_mimetype` instead of `format`.

Moreover, the mime-type of rst used in Jupyter
deviated from that suggested by
https://docutils.sourceforge.io/FAQ.html
and is defined as `text/restructuredtext`
when chosen from "Raw NBConvert Format" in Jupyter.

So while this is backward-compatible,
it should matches the real world usage better,
hence improving the round-trip "identity" in raw-cell.

See #229, jupyter/nbformat#229.
This commit is contained in:
Kolen Cheung 2021-09-10 18:35:22 -07:00 committed by John MacFarlane
parent 17092454c5
commit c66cedaa71

View file

@ -147,7 +147,7 @@ extractCells opts (Div (_id,classes,kvs) xs : bs)
"revealjs" -> "text/html"
"latex" -> "text/latex"
"markdown" -> "text/markdown"
"rst" -> "text/x-rst"
"rst" -> "text/restructuredtext"
"asciidoc" -> "text/asciidoc"
_ -> f
(Ipynb.Cell{
@ -155,7 +155,7 @@ extractCells opts (Div (_id,classes,kvs) xs : bs)
, cellSource = Source $ breakLines raw
, cellMetadata = if format' == "ipynb" -- means no format given
then mempty
else M.insert "format"
else M.insert "raw_mimetype"
(Aeson.String format') mempty
, cellAttachments = Nothing } :) <$> extractCells opts bs
_ -> extractCells opts bs