diff options
author | John MacFarlane <jgm@berkeley.edu> | 2019-01-24 16:51:56 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-01-24 16:51:56 -0800 |
commit | 2f54470266813866d30a68a75ee98c0de58fcd8d (patch) | |
tree | d9c608ba1051bbfda811e12fef9a0b017e2c9929 /src/Text/Pandoc | |
parent | 7167330a2a858fcfed313443a021aee90b13b8cc (diff) | |
download | pandoc-2f54470266813866d30a68a75ee98c0de58fcd8d.tar.gz |
Ipynb: Put all jupyter metadata under 'jupyter' key.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/Ipynb.hs | 2 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/Ipynb.hs | 7 |
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 |