@@ -33,7 +33,7 @@ import Text.Pandoc.Definition
3333import Text.Pandoc.Options
3434import Text.Pandoc.Shared (compactify, compactifyDL, safeRead)
3535
36−import Control.Monad (foldM, guard, mzero, void)
36+import Control.Monad (foldM, guard, mplus, mzero, void)
3737import Data.Char (isSpace)
3838import Data.Default (Default)
3939import Data.List (foldl')
@@ -615,8 +615,16 @@ orgTable = try $ do
615615 lookAhead tableStart
616616 do
617617 rows <- tableRows
618− let caption = fromMaybe (return mempty) $ blockAttrCaption blockAttrs
619− return $ (<$> caption) . orgToPandocTable . normalizeTable =<< rowsToTable rows
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
620628
621629orgToPandocTable :: OrgTable
622630 -> Inlines