@@ -38,13 +38,14 @@ tableToOpenXML blocksToOpenXML gridTable = do
3838 gridTable
3939 let (Caption _maybeShortCaption captionBlocks) = caption
4040 let captionStr = stringify captionBlocks
41+ let aligns = map fst $ elems colspecs
4142 captionXml <- if null captionBlocks
4243 then return []
4344 else withParaPropM (pStyleM "Table Caption")
4445 $ blocksToOpenXML captionBlocks
45− head' <- cellGridToOpenXML blocksToOpenXML HeadRow thead
46− bodies <- mapM (cellGridToOpenXML blocksToOpenXML BodyRow) tbodies
47− foot' <- cellGridToOpenXML blocksToOpenXML FootRow tfoot
46+ head' <- cellGridToOpenXML blocksToOpenXML HeadRow aligns thead
47+ bodies <- mapM (cellGridToOpenXML blocksToOpenXML BodyRow aligns) tbodies
48+ foot' <- cellGridToOpenXML blocksToOpenXML FootRow aligns tfoot
4849
4950 let hasHeader = not . null . indices . partRowAttrs $ thead
5051 let hasFooter = not . null . indices . partRowAttrs $ tfoot
@@ -110,12 +111,14 @@ tableLayout specs =
110111cellGridToOpenXML :: PandocMonad m
111112 => ([Block] -> WS m [Content])
112113 -> RowType
114+ -> [Alignment]
113115 -> Part
114116 -> WS m [Element]
115−cellGridToOpenXML blocksToOpenXML rowType part@(Part _ _ rowAttrs) =
117+cellGridToOpenXML blocksToOpenXML rowType aligns part@(Part _ _ rowAttrs) =
116118 if null (indices rowAttrs)
117119 then return mempty
118− else mapM (rowToOpenXML blocksToOpenXML) $ partToRows rowType part
120+ else mapM (rowToOpenXML blocksToOpenXML) $
121+ partToRows rowType aligns part
119122
120123data OOXMLCell
121124 = OOXMLCell Attr Alignment RowSpan ColSpan [Block]
@@ -123,13 +126,17 @@ data OOXMLCell
123126
124127data OOXMLRow = OOXMLRow RowType Attr [OOXMLCell]
125128
126−partToRows :: RowType -> Part -> [OOXMLRow]
127−partToRows rowType part =
129+partToRows :: RowType -> [Alignment] -> Part -> [OOXMLRow]
130+partToRows rowType aligns part =
128131 let
129− toOOXMLCell :: RowIndex -> ColIndex -> GridCell -> [OOXMLCell]
130− toOOXMLCell ridx cidx = \case
132+ toOOXMLCell :: Alignment -> RowIndex -> ColIndex -> GridCell -> [OOXMLCell]
133+ toOOXMLCell columnAlign ridx cidx = \case
131134 ContentCell attr align rowspan colspan blocks ->
132− [OOXMLCell attr align rowspan colspan blocks]
135+ -- Respect non-default, cell specific alignment.
136+ let align' = case align of
137+ AlignDefault -> columnAlign
138+ _ -> align
139+ in [OOXMLCell attr align' rowspan colspan blocks]
133140 ContinuationCell idx'@(ridx',cidx') | ridx /= ridx', cidx == cidx' ->
134141 case (partCellArray part)!idx' of
135142 (ContentCell _ _ _ colspan _) -> [OOXMLCellMerge colspan]
@@ -138,7 +145,9 @@ partToRows rowType part =
138145 _ -> mempty
139146 mkRow :: (RowIndex, Attr) -> OOXMLRow
140147 mkRow (ridx, attr) = OOXMLRow rowType attr
141− . concatMap (uncurry $ toOOXMLCell ridx)
148+ . mconcat
149+ . zipWith (\align -> uncurry $ toOOXMLCell align ridx)
150+ aligns
142151 . assocs
143152 . rowArray ridx
144153 $ partCellArray part
@@ -155,9 +164,6 @@ rowToOpenXML blocksToOpenXML (OOXMLRow rowType _attr cells) = do
155164 [mknode "w:tblHeader" [("w:val", "true")] ()] :)
156165 BodyRow -> id
157166 FootRow -> id
158− -- let align' = case align of
159− -- AlignDefault -> colAlign
160− -- _ -> align
161167 return $ mknode "w:tr" [] (addTrPr xmlcells)
162168
163169ooxmlCellToOpenXML :: PandocMonad m