@@ -133,7 +133,7 @@ extractCells opts (Div (_id,classes,kvs) xs : bs)
133133 , cellAttachments = Nothing } :) <$> extractCells opts bs
134134 | "cell" `elem` classes
135135 , "raw" `elem` classes =
136− case xs of
136+ case consolidateAdjacentRawBlocks xs of
137137 [RawBlock (Format f) raw] -> do
138138 let format' =
139139 case f of
@@ -195,7 +195,7 @@ blockToOutput _ = return Nothing
195195
196196extractData :: PandocMonad m => [Block] -> m (MimeBundle, JSONMeta)
197197extractData bs = do
198− (mmap, meta) <- foldM go mempty bs
198+ (mmap, meta) <- foldM go mempty $ consolidateAdjacentRawBlocks bs
199199 return (MimeBundle mmap, meta)
200200 where
201201 go (mmap, meta) b@(Para [Image (_,_,kvs) _ (src,_)]) = do
@@ -227,3 +227,11 @@ pairsToJSONMeta kvs =
227227 | (k,v) <- kvs
228228 , k /= "execution_count"
229229 ]
230+
231+consolidateAdjacentRawBlocks :: [Block] -> [Block]
232+consolidateAdjacentRawBlocks [] = []
233+consolidateAdjacentRawBlocks (RawBlock f1 x : RawBlock f2 y : xs)
234+ | f1 == f2
235+ = consolidateAdjacentRawBlocks (RawBlock f1 (x <> "\n" <> y) : xs)
236+consolidateAdjacentRawBlocks (x : xs) =
237+ x : consolidateAdjacentRawBlocks xs