@@ -613,18 +613,16 @@ orgTable = try $ do
613613 guard =<< not . isFirstInListItem <$> getState
614614 blockAttrs <- blockAttributes
615615 lookAhead tableStart
616− do
617− rows <- tableRows
618− let captionMb = blockAttrCaption blockAttrs
619− -- amend caption with span as ID tag iff both are present
620− let amendedCaption = do
621− caption' <- captionMb
622− name <- blockAttrName blockAttrs `mplus` blockAttrLabel blockAttrs
623− let tag = B.spanWith (name, mempty, mempty) mempty
624− return $ fmap (tag <>) caption'
625− let caption = fromMaybe mempty (amendedCaption `mplus` captionMb)
626− return $ (<$> caption) . orgToPandocTable . normalizeTable
627− =<< rowsToTable rows
616+ rows <- tableRows
617+
618+ let caption = fromMaybe mempty (blockAttrCaption blockAttrs)
619+ let orgTbl = normalizeTable <$> rowsToTable rows
620+ -- wrap table in div if a name or label is given
621+ let identMb = blockAttrName blockAttrs `mplus` blockAttrLabel blockAttrs
622+ let wrap = case identMb of
623+ Just ident -> B.divWith (ident, mempty, mempty)
624+ Nothing -> id
625+ return . fmap wrap $ (orgToPandocTable <$> orgTbl <*> caption)
628626
629627orgToPandocTable :: OrgTable
630628 -> Inlines