@@ -62,8 +62,16 @@ pandocToNotebook opts (Pandoc meta blocks) = do
6262 opts{ writerTemplate = Nothing } (Pandoc nullMeta [Plain ils])
6363 let jupyterMeta =
6464 case lookupMeta "jupyter" meta of
65− Just (MetaMap m) -> (Meta m <> B.deleteMeta "jupyter" meta)
65+ Just (MetaMap m) -> Meta m
6666 _ -> mempty
67+ let nbformat =
68+ case (lookupMeta "nbformat" jupyterMeta,
69+ lookupMeta "nbformat_minor" jupyterMeta) of
70+ (Just (MetaString "4"), Just (MetaString y)) ->
71+ case safeRead y of
72+ Just z -> (4, z)
73+ Nothing -> (4, 5)
74+ _ -> (4, 5) -- write as v4.5
6775 metadata' <- metaToJSON' blockWriter inlineWriter $
6876 B.deleteMeta "nbformat" $
6977 B.deleteMeta "nbformat_minor" $ jupyterMeta
@@ -74,7 +82,7 @@ pandocToNotebook opts (Pandoc meta blocks) = do
7482 cells <- extractCells opts blocks
7583 return $ Notebook{
7684 notebookMetadata = metadata
77− , notebookFormat = (4, 5)
85+ , notebookFormat = nbformat
7886 , notebookCells = cells }
7987
8088addAttachment :: PandocMonad m