aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Readers/Ipynb.hs2
-rw-r--r--src/Text/Pandoc/Writers/Ipynb.hs7
2 files changed, 7 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/Ipynb.hs b/src/Text/Pandoc/Readers/Ipynb.hs
index 2497e6a0a..ad0652ed0 100644
--- a/src/Text/Pandoc/Readers/Ipynb.hs
+++ b/src/Text/Pandoc/Readers/Ipynb.hs
@@ -83,7 +83,7 @@ notebookToPandoc opts notebook = do
_ -> "python"
bs <- mconcat <$> mapM (cellToBlocks opts lang) cells
let Pandoc _ blocks = B.doc bs
- return $ Pandoc (Meta m) blocks
+ return $ Pandoc (Meta $ M.insert "jupyter" (MetaMap m) mempty) blocks
cellToBlocks :: PandocMonad m
=> ReaderOptions -> String -> Cell a -> m B.Blocks
diff --git a/src/Text/Pandoc/Writers/Ipynb.hs b/src/Text/Pandoc/Writers/Ipynb.hs
index c9d71e180..509e60aa0 100644
--- a/src/Text/Pandoc/Writers/Ipynb.hs
+++ b/src/Text/Pandoc/Writers/Ipynb.hs
@@ -77,9 +77,14 @@ pandocToNotebook opts (Pandoc meta blocks) = do
opts{ writerTemplate = Nothing } (Pandoc nullMeta bs)
let inlineWriter ils = T.stripEnd <$> writeMarkdown
opts{ writerTemplate = Nothing } (Pandoc nullMeta [Plain ils])
+ let jupyterMeta =
+ case lookupMeta "jupyter" meta of
+ Just (MetaMap m) -> (Meta m <> B.deleteMeta "jupyter" meta)
+ _ -> meta
metadata' <- metaToJSON' blockWriter inlineWriter $
B.deleteMeta "nbformat" $
- B.deleteMeta "nbformat_minor" $ meta
+ B.deleteMeta "nbformat_minor" $ jupyterMeta
+ -- convert from a Value (JSON object) to a M.Map Text Value:
let metadata = case fromJSON metadata' of
Error _ -> mempty -- TODO warning here? shouldn't happen
Success x -> x