From 5bd2d28b1946baf37ba880578b3b01d9b36a36d3 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Wed, 18 Dec 2019 21:57:14 +0100 Subject: Org reader: wrap named table in div, using name as id Closes: #5984 --- src/Text/Pandoc/Readers/Org/Blocks.hs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'src/Text/Pandoc/Readers/Org/Blocks.hs') diff --git a/src/Text/Pandoc/Readers/Org/Blocks.hs b/src/Text/Pandoc/Readers/Org/Blocks.hs index 785811da8..dc7a26aca 100644 --- a/src/Text/Pandoc/Readers/Org/Blocks.hs +++ b/src/Text/Pandoc/Readers/Org/Blocks.hs @@ -613,18 +613,16 @@ orgTable = try $ do guard =<< not . isFirstInListItem <$> getState blockAttrs <- blockAttributes lookAhead tableStart - do - rows <- tableRows - 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 + rows <- tableRows + + let caption = fromMaybe mempty (blockAttrCaption blockAttrs) + let orgTbl = normalizeTable <$> rowsToTable rows + -- wrap table in div if a name or label is given + let identMb = blockAttrName blockAttrs `mplus` blockAttrLabel blockAttrs + let wrap = case identMb of + Just ident -> B.divWith (ident, mempty, mempty) + Nothing -> id + return . fmap wrap $ (orgToPandocTable <$> orgTbl <*> caption) orgToPandocTable :: OrgTable -> Inlines -- cgit v1.2.3