@@ -185,8 +185,8 @@ para = do
185table :: MWParser Blocks
185table :: MWParser Blocks
186table = do
186table = do
187 tableStart
187 tableStart
188− styles <- anyLine
188+ styles <- option [] parseAttrs <* blankline
189− let tableWidth = case lookup "width" $ parseAttrs styles of
189+ let tableWidth = case lookup "width" styles of
190 Just w -> maybe 1.0 id $ parseWidth w
190 Just w -> maybe 1.0 id $ parseWidth w
191 Nothing -> 1.0
191 Nothing -> 1.0
192 caption <- option mempty tableCaption
192 caption <- option mempty tableCaption
@@ -209,18 +209,16 @@ table = do
209 else (replicate cols mempty, hdr:rows')
209 else (replicate cols mempty, hdr:rows')
210 return $ B.table caption cellspecs headers rows
210 return $ B.table caption cellspecs headers rows
212−parseAttrs :: String -> [(String,String)]
212+parseAttrs :: MWParser [(String,String)]
213−parseAttrs s = case parse (many parseAttr) "attributes" s of
213+parseAttrs = many1 parseAttr
217−parseAttr :: Parser String () (String, String)
215+parseAttr :: MWParser (String, String)
218parseAttr = try $ do
216parseAttr = try $ do
219 skipMany spaceChar
217 skipMany spaceChar
220 k <- many1 letter
218 k <- many1 letter
223− v <- many1Till anyChar (char '"')
221+ v <- many1Till (satisfy (/='\n')) (char '"')
224 return (k,v)
222 return (k,v)
226tableStart :: MWParser ()
224tableStart :: MWParser ()
@@ -258,8 +256,8 @@ tableCell :: MWParser ((Alignment, Double), Blocks)
258tableCell = try $ do
256tableCell = try $ do
260 skipMany spaceChar
258 skipMany spaceChar
261− attrs <- option [] $ try $ parseAttrs <$>
259+ attrs <- option [] $ try $ parseAttrs <* skipSpaces <* char '|' <*
262− manyTill (satisfy (/='\n')) (char '|' <* notFollowedBy (char '|'))
260+ notFollowedBy (char '|')
263 skipMany spaceChar
261 skipMany spaceChar
264 ls <- concat <$> many (notFollowedBy (cellsep <|> rowsep <|> tableEnd) *>
262 ls <- concat <$> many (notFollowedBy (cellsep <|> rowsep <|> tableEnd) *>
265 ((snd <$> withRaw table) <|> count 1 anyChar))
263 ((snd <$> withRaw table) <|> count 1 anyChar))