aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Readers/Ipynb.hs5
-rw-r--r--src/Text/Pandoc/Writers/Ipynb.hs9
2 files changed, 9 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/Ipynb.hs b/src/Text/Pandoc/Readers/Ipynb.hs
index 10f3a0675..04e0b1595 100644
--- a/src/Text/Pandoc/Readers/Ipynb.hs
+++ b/src/Text/Pandoc/Readers/Ipynb.hs
@@ -90,10 +90,11 @@ cellToBlocks opts lang c = do
return $ B.divWith ("",["cell","markdown"],kvs)
$ B.fromList bs
Ipynb.Raw -> do
- let format = fromMaybe "html" $ lookup "format" kvs
+ -- we use ipynb to indicate no format given (a wildcard in nbformat)
+ let format = fromMaybe "ipynb" $ lookup "format" kvs
let format' =
case format of
- "text/html" -> "html"
+ "text/html" -> "html"
"text/latex" -> "latex"
"application/pdf" -> "latex"
"text/markdown" -> "markdown"
diff --git a/src/Text/Pandoc/Writers/Ipynb.hs b/src/Text/Pandoc/Writers/Ipynb.hs
index 2a95f669e..4f088f7fc 100644
--- a/src/Text/Pandoc/Writers/Ipynb.hs
+++ b/src/Text/Pandoc/Writers/Ipynb.hs
@@ -19,6 +19,7 @@ where
import Prelude
import Control.Monad.State
import qualified Data.Map as M
+import Data.Char (toLower)
import Data.Maybe (catMaybes, fromMaybe)
import Text.Pandoc.Options
import Text.Pandoc.Definition
@@ -136,7 +137,7 @@ extractCells opts (Div (_id,classes,kvs) xs : bs)
case consolidateAdjacentRawBlocks xs of
[RawBlock (Format f) raw] -> do
let format' =
- case f of
+ case map toLower f of
"html" -> "text/html"
"revealjs" -> "text/html"
"latex" -> "text/latex"
@@ -146,8 +147,10 @@ extractCells opts (Div (_id,classes,kvs) xs : bs)
(Cell{
cellType = Raw
, cellSource = Source $ breakLines $ T.pack raw
- , cellMetadata = M.insert "format"
- (Aeson.String $ T.pack format') mempty
+ , cellMetadata = if format' == "ipynb" -- means no format given
+ then mempty
+ else M.insert "format"
+ (Aeson.String $ T.pack format') mempty
, cellAttachments = Nothing } :) <$> extractCells opts bs
_ -> extractCells opts bs
extractCells opts (CodeBlock (_id,classes,kvs) raw : bs)