@@ -190,15 +190,15 @@ table = do
190 caption <- option mempty tableCaption
190 caption <- option mempty tableCaption
191 optional rowsep
191 optional rowsep
192 hasheader <- option False $ True <$ (lookAhead (char '!'))
192 hasheader <- option False $ True <$ (lookAhead (char '!'))
193− hdr <- tableRow
193+ (aligns,hdr) <- unzip <$> tableRow
194− rows' <- many $ try $ rowsep *> tableRow
194+ rows' <- many $ try $ rowsep *> (map snd <$> tableRow)
196 -- TODO handle cellspecs from styles and aligns...
196 -- TODO handle cellspecs from styles and aligns...
197 let cols = length hdr
197 let cols = length hdr
198 let (headers,rows) = if hasheader
198 let (headers,rows) = if hasheader
199 then (hdr, rows')
199 then (hdr, rows')
200 else (replicate cols mempty, hdr:rows')
200 else (replicate cols mempty, hdr:rows')
201− let cellspecs = replicate cols (AlignDefault, 0.0)
201+ let cellspecs = zip aligns (repeat 0.0)
202 return $ B.table caption cellspecs headers rows
202 return $ B.table caption cellspecs headers rows
204parseAttrs :: String -> [(String,String)]
204parseAttrs :: String -> [(String,String)]
@@ -238,10 +238,10 @@ tableCaption = try $ do
238 res <- manyTill anyChar newline >>= parseFromString (many inline)
238 res <- manyTill anyChar newline >>= parseFromString (many inline)
239 return $ trimInlines $ mconcat res
239 return $ trimInlines $ mconcat res
241−tableRow :: MWParser [Blocks]
241+tableRow :: MWParser [(Alignment, Blocks)]
242tableRow = try $ many tableCell
242tableRow = try $ many tableCell
244−tableCell :: MWParser Blocks
244+tableCell :: MWParser (Alignment, Blocks)
245tableCell = try $ do
245tableCell = try $ do
247 skipMany spaceChar
247 skipMany spaceChar
@@ -249,7 +249,13 @@ tableCell = try $ do
249 manyTill (satisfy (/='\n')) (char '|' <* notFollowedBy (char '|'))
249 manyTill (satisfy (/='\n')) (char '|' <* notFollowedBy (char '|'))
250 skipMany spaceChar
250 skipMany spaceChar
251 ls <- many (notFollowedBy (cellsep <|> rowsep <|> tableEnd) *> anyChar)
251 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
254template :: MWParser String
260template :: MWParser String
255template = try $ do
261template = try $ do