@@ -190,15 +190,15 @@ table = do
190190 caption <- option mempty tableCaption
191191 optional rowsep
192192 hasheader <- option False $ True <$ (lookAhead (char '!'))
193− hdr <- tableRow
194− rows' <- many $ try $ rowsep *> tableRow
193+ (aligns,hdr) <- unzip <$> tableRow
194+ rows' <- many $ try $ rowsep *> (map snd <$> tableRow)
195195 tableEnd
196196 -- TODO handle cellspecs from styles and aligns...
197197 let cols = length hdr
198198 let (headers,rows) = if hasheader
199199 then (hdr, rows')
200200 else (replicate cols mempty, hdr:rows')
201− let cellspecs = replicate cols (AlignDefault, 0.0)
201+ let cellspecs = zip aligns (repeat 0.0)
202202 return $ B.table caption cellspecs headers rows
203203
204204parseAttrs :: String -> [(String,String)]
@@ -238,10 +238,10 @@ tableCaption = try $ do
238238 res <- manyTill anyChar newline >>= parseFromString (many inline)
239239 return $ trimInlines $ mconcat res
240240
241−tableRow :: MWParser [Blocks]
241+tableRow :: MWParser [(Alignment, Blocks)]
242242tableRow = try $ many tableCell
243243
244−tableCell :: MWParser Blocks
244+tableCell :: MWParser (Alignment, Blocks)
245245tableCell = try $ do
246246 cellsep
247247 skipMany spaceChar
@@ -249,7 +249,13 @@ tableCell = try $ do
249249 manyTill (satisfy (/='\n')) (char '|' <* notFollowedBy (char '|'))
250250 skipMany spaceChar
251251 ls <- many (notFollowedBy (cellsep <|> rowsep <|> tableEnd) *> anyChar)
252− parseFromString (mconcat <$> many block) ls
252+ bs <- parseFromString (mconcat <$> many block) ls
253+ let align = case lookup "align" attrs of
254+ Just "left" -> AlignLeft
255+ Just "right" -> AlignRight
256+ Just "center" -> AlignCenter
257+ _ -> AlignDefault
258+ return (align, bs)
253259
254260template :: MWParser String
255261template = try $ do