From 5269724ad39dfbbd473ae559aa2fff9ba7e5ee3b Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 21 Feb 2017 21:28:24 +0100 Subject: [PATCH] MediaWiki reader: fixed more table issues. Closes #2649. --- src/Text/Pandoc/Readers/MediaWiki.hs | 16 ++-- test/command/2649.md | 109 +++++++++++++++++++++++++++ 2 files changed, 116 insertions(+), 9 deletions(-) create mode 100644 test/command/2649.md diff --git a/src/Text/Pandoc/Readers/MediaWiki.hs b/src/Text/Pandoc/Readers/MediaWiki.hs index f0d01136f..cdd1ce99f 100644 --- a/src/Text/Pandoc/Readers/MediaWiki.hs +++ b/src/Text/Pandoc/Readers/MediaWiki.hs @@ -219,7 +219,9 @@ para = do table :: PandocMonad m => MWParser m Blocks table = do tableStart - styles <- option [] parseAttrs <* blanklines + styles <- option [] parseAttrs + skipMany spaceChar + optional blanklines let tableWidth = case lookup "width" styles of Just w -> fromMaybe 1.0 $ parseWidth w Nothing -> 1.0 @@ -267,14 +269,10 @@ rowsep = try $ guardColumnOne *> skipSpaces *> sym "|-" <* many (char '-') <* optional parseAttr <* blanklines cellsep :: PandocMonad m => MWParser m () -cellsep = try $ - (guardColumnOne *> skipSpaces <* - ( (char '|' <* notFollowedBy (oneOf "-}+")) - <|> (char '!') - ) - ) - <|> (() <$ try (string "||")) - <|> (() <$ try (string "!!")) +cellsep = try $ do + skipSpaces + (char '|' *> notFollowedBy (oneOf "-}+") *> optional (char '|')) + <|> (char '!' *> optional (char '!')) tableCaption :: PandocMonad m => MWParser m Inlines tableCaption = try $ do diff --git a/test/command/2649.md b/test/command/2649.md new file mode 100644 index 000000000..af84693c4 --- /dev/null +++ b/test/command/2649.md @@ -0,0 +1,109 @@ +``` +% pandoc -f mediawiki -t html5 +{| class="wikitable" style="line-height: 1.0" + +|- bgcolor="#efefef" +|} +^D + + + + + +
+``` + +``` +% pandoc -f mediawiki -t html5 +{| border="4" cellspacing="2" cellpadding="0" WIDTH="100%" +|----- +| peildatum Simbase || november 2005 || '''uitslagen Flohrgambiet''' || +|----- +| totaal aantal partijen Simbase || 7.316.773 +| wit wint || 53% +|----- +| percentage (en partijen) Flohrgambiet +| 0.023 % (1.699) || zwart wint || 27% +|----- +| percentage Flohrgambiet in aug 2003 +| 0.035 % || remise || 20% +|} +^D + + + + + + + + + + + + + + + + + + + + + + + + + + + +

peildatum Simbase

november 2005

uitslagen Flohrgambiet

totaal aantal partijen Simbase

7.316.773

wit wint

53%

percentage (en partijen) Flohrgambiet

0.023 % (1.699)

zwart wint

27%

percentage Flohrgambiet in aug 2003

0.035 %

remise

20%

+``` + +``` +% pandoc -f mediawiki -t html5 +{| class="wikitable" style="text-align:center; font-size:95%" valign="top" | +! Plaats +! Rijder +! Aantal +|- +| 1 +|align=left| {{FR-VLAG}} [[Sébastien Loeb]] | 78 +|- +| 2 +|align=left| {{FR-VLAG}} '''[[Sébastien Ogier]]''' +| 38 +|- +| 10 +|align=left| {{FI-VLAG}} [[Hannu Mikkola]] +| 18 +|} +^D + + + + + + + + + + + + + + + + + + + + + + + + +

Plaats

Rijder

Aantal

1

+

Sébastien Loeb

78

2

+

Sébastien Ogier

38

10

+

Hannu Mikkola

18

+```