diff options
author | John MacFarlane <jgm@berkeley.edu> | 2012-09-15 00:23:24 -0400 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2012-09-15 00:23:24 -0400 |
commit | 9a54a949c7a527d87958c2fc00d4712f7adb5d1e (patch) | |
tree | 15902f87c2cf94296d6e2a11110c9e0199e0e32c /src/Text/Pandoc/Readers | |
parent | aa476b42cb84cf1f0bdf187574e0f584dc5fea91 (diff) | |
download | pandoc-9a54a949c7a527d87958c2fc00d4712f7adb5d1e.tar.gz |
MediaWiki reader: Parse styles after '{|' table start.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r-- | src/Text/Pandoc/Readers/MediaWiki.hs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/MediaWiki.hs b/src/Text/Pandoc/Readers/MediaWiki.hs index d18a98bc0..89564f504 100644 --- a/src/Text/Pandoc/Readers/MediaWiki.hs +++ b/src/Text/Pandoc/Readers/MediaWiki.hs @@ -164,6 +164,9 @@ para = B.para . trimInlines . mconcat <$> many1 inline table :: MWParser Blocks table = do tableStart + styles <- manyTill anyChar newline + let tableWidth = maybe (1.0 :: Double) read + $ lookup "width" $ parseAttrs styles caption <- option mempty tableCaption optional rowsep hasheader <- option False $ True <$ (lookAhead (char '!')) @@ -178,8 +181,22 @@ table = do let cellspecs = replicate cols (AlignDefault, 0.0) return $ B.table caption cellspecs headers rows +parseAttrs :: String -> [(String,String)] +parseAttrs s = case parse (many parseAttr) "attributes" s of + Right r -> r + Left _ -> [] + +parseAttr :: Parser String () (String, String) +parseAttr = try $ do + skipMany spaceChar + k <- many1 letter + char '=' + char '"' + v <- many1Till anyChar (char '"') + return (k,v) + tableStart :: MWParser () -tableStart = try $ guardColumnOne *> sym "{|" <* blanklines +tableStart = try $ guardColumnOne *> sym "{|" tableEnd :: MWParser () tableEnd = try $ guardColumnOne *> sym "|}" <* blanklines |