summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Leung <29217594+leungbk@users.noreply.github.com>2022-05-02 08:25:57 -0700
committerGitHub <noreply@github.com>2022-05-02 17:25:57 +0200
commit67daf96bdd519b1e709d6ed2534d06203967bf97 (patch)
tree94a3ace6f960e26e772c00437f3ff9af7112f2b3 /src
parent843eeae13d4cb2a7e8c1ed0d151a691c83adf72f (diff)
Org reader: allow attrs for Org tables. (#8049)
Tables with attributes are no longer wrapped in Div elements; attributes are added directly to the table element.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/Org/Blocks.hs22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/Text/Pandoc/Readers/Org/Blocks.hs b/src/Text/Pandoc/Readers/Org/Blocks.hs
index f9fc4ce68..fbc5e6182 100644
--- a/src/Text/Pandoc/Readers/Org/Blocks.hs
+++ b/src/Text/Pandoc/Readers/Org/Blocks.hs
@@ -634,25 +634,23 @@ orgTable = try $ do
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)
+ let attr = (fromMaybe mempty identMb, [], blockAttrKeyValues blockAttrs)
+ return $ orgToPandocTable attr <$> orgTbl <*> caption
-orgToPandocTable :: OrgTable
+orgToPandocTable :: Attr
+ -> OrgTable
-> Inlines
-> Blocks
-orgToPandocTable (OrgTable colProps heads lns) caption =
+orgToPandocTable attr (OrgTable colProps heads lns) caption =
let totalWidth = if any (isJust . columnRelWidth) colProps
then Just . sum $ map (fromMaybe 1 . columnRelWidth) colProps
else Nothing
- in B.table (B.simpleCaption $ B.plain caption)
- (map (convertColProp totalWidth) colProps)
- (TableHead nullAttr $ toHeaderRow heads)
- [TableBody nullAttr 0 [] $ map toRow lns]
- (TableFoot nullAttr [])
+ in B.tableWith attr (B.simpleCaption $ B.plain caption)
+ (map (convertColProp totalWidth) colProps)
+ (TableHead nullAttr $ toHeaderRow heads)
+ [TableBody nullAttr 0 [] $ map toRow lns]
+ (TableFoot nullAttr [])
where
toRow = Row nullAttr . map B.simpleCell
toHeaderRow l = [toRow l | not (null l)]