@@ -133,7 +133,7 @@ extractCells opts (Div (_id,classes,kvs) xs : bs)
133 , cellAttachments = Nothing } :) <$> extractCells opts bs
133 , cellAttachments = Nothing } :) <$> extractCells opts bs
134 | "cell" `elem` classes
134 | "cell" `elem` classes
135 , "raw" `elem` classes =
135 , "raw" `elem` classes =
136− case xs of
136+ case consolidateAdjacentRawBlocks xs of
137 [RawBlock (Format f) raw] -> do
137 [RawBlock (Format f) raw] -> do
138 let format' =
138 let format' =
139 case f of
139 case f of
@@ -195,7 +195,7 @@ blockToOutput _ = return Nothing
196extractData :: PandocMonad m => [Block] -> m (MimeBundle, JSONMeta)
196extractData :: PandocMonad m => [Block] -> m (MimeBundle, JSONMeta)
197extractData bs = do
197extractData bs = do
198− (mmap, meta) <- foldM go mempty bs
198+ (mmap, meta) <- foldM go mempty $ consolidateAdjacentRawBlocks bs
199 return (MimeBundle mmap, meta)
199 return (MimeBundle mmap, meta)
201 go (mmap, meta) b@(Para [Image (_,_,kvs) _ (src,_)]) = do
201 go (mmap, meta) b@(Para [Image (_,_,kvs) _ (src,_)]) = do
@@ -227,3 +227,11 @@ pairsToJSONMeta kvs =
227 | (k,v) <- kvs
227 | (k,v) <- kvs
228 , k /= "execution_count"
228 , k /= "execution_count"
231+consolidateAdjacentRawBlocks :: [Block] -> [Block]
232+consolidateAdjacentRawBlocks [] = []
233+consolidateAdjacentRawBlocks (RawBlock f1 x : RawBlock f2 y : xs)
235+ = consolidateAdjacentRawBlocks (RawBlock f1 (x <> "\n" <> y) : xs)
236+consolidateAdjacentRawBlocks (x : xs) =
237+ x : consolidateAdjacentRawBlocks xs