@@ -294,24 +294,22 @@ verseBlock blockType = try $ do
294294codeBlock :: PandocMonad m => BlockAttributes -> Text -> OrgParser m (F Blocks)
295295codeBlock blockAttrs blockType = do
296296 skipSpaces
297− (classes, kv) <- codeHeaderArgs <|> (mempty <$ ignHeaders)
298− content <- rawBlockContent blockType
299− resultsContent <- option mempty babelResultsBlock
300− let id' = fromMaybe mempty $ blockAttrName blockAttrs
301− let codeBlck = B.codeBlockWith ( id', classes, kv ) content
302− let labelledBlck = maybe (pure codeBlck)
303− (labelDiv codeBlck)
304− (blockAttrCaption blockAttrs)
297+ (classes, kv) <- codeHeaderArgs <|> (mempty <$ ignHeaders)
298+ content <- rawBlockContent blockType
299+ resultsContent <- option mempty babelResultsBlock
300+ let identifier = fromMaybe mempty $ blockAttrName blockAttrs
301+ let codeBlk = B.codeBlockWith (identifier, classes, kv) content
302+ let wrap = maybe pure addCaption (blockAttrCaption blockAttrs)
305303 return $
306− (if exportsCode kv then labelledBlck else mempty) <>
304+ (if exportsCode kv then wrap codeBlk else mempty) <>
307305 (if exportsResults kv then resultsContent else mempty)
308306 where
309− labelDiv :: Blocks -> F Inlines -> F Blocks
310− labelDiv blk value =
311− B.divWith nullAttr <$> (mappend <$> labelledBlock value <*> pure blk)
307+ addCaption :: F Inlines -> Blocks -> F Blocks
308+ addCaption caption blk = B.divWith ("", ["captioned-content"], [])
309+ <$> (mkCaptionBlock caption <> pure blk)
312310
313− labelledBlock :: F Inlines -> F Blocks
314− labelledBlock = fmap (B.plain . B.spanWith ("", ["label"], []))
311+ mkCaptionBlock :: F Inlines -> F Blocks
312+ mkCaptionBlock = fmap (B.divWith ("", ["caption"], []) . B.plain)
315313
316314 exportsResults :: [(Text, Text)] -> Bool
317315 exportsResults = maybe False (`elem` ["results", "both"]) . lookup "exports"