diff options
-rw-r--r-- | src/Text/Pandoc/Readers/Org/Blocks.hs | 14 | ||||
-rw-r--r-- | test/command/3706.md | 2 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/Org/Blocks.hs b/src/Text/Pandoc/Readers/Org/Blocks.hs index de51dec3d..785811da8 100644 --- a/src/Text/Pandoc/Readers/Org/Blocks.hs +++ b/src/Text/Pandoc/Readers/Org/Blocks.hs @@ -33,7 +33,7 @@ import Text.Pandoc.Definition import Text.Pandoc.Options import Text.Pandoc.Shared (compactify, compactifyDL, safeRead) -import Control.Monad (foldM, guard, mzero, void) +import Control.Monad (foldM, guard, mplus, mzero, void) import Data.Char (isSpace) import Data.Default (Default) import Data.List (foldl') @@ -615,8 +615,16 @@ orgTable = try $ do lookAhead tableStart do rows <- tableRows - let caption = fromMaybe (return mempty) $ blockAttrCaption blockAttrs - return $ (<$> caption) . orgToPandocTable . normalizeTable =<< rowsToTable rows + let captionMb = blockAttrCaption blockAttrs + -- amend caption with span as ID tag iff both are present + let amendedCaption = do + caption' <- captionMb + name <- blockAttrName blockAttrs `mplus` blockAttrLabel blockAttrs + let tag = B.spanWith (name, mempty, mempty) mempty + return $ fmap (tag <>) caption' + let caption = fromMaybe mempty (amendedCaption `mplus` captionMb) + return $ (<$> caption) . orgToPandocTable . normalizeTable + =<< rowsToTable rows orgToPandocTable :: OrgTable -> Inlines diff --git a/test/command/3706.md b/test/command/3706.md index 00f53279e..5b2e32f7f 100644 --- a/test/command/3706.md +++ b/test/command/3706.md @@ -15,7 +15,7 @@ pandoc -f org -t native | 2 | La | | 3 | La | ^D -[Table [Str "Lalelu."] [AlignDefault,AlignDefault] [0.0,0.0] +[Table [Span ("tab",[],[]) [],Str "Lalelu."] [AlignDefault,AlignDefault] [0.0,0.0] [[Plain [Str "Id"]] ,[Plain [Str "Desc"]]] [[[Plain [Str "1"]] |