MediaWiki reader: fixed more table issues.

Closes #2649.
This commit is contained in:
John MacFarlane 2017-02-21 21:28:24 +01:00
parent 1d06e8c5a5
commit 5269724ad3
2 changed files with 116 additions and 9 deletions

View file

@ -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

109
test/command/2649.md Normal file
View file

@ -0,0 +1,109 @@
```
% pandoc -f mediawiki -t html5
{| class="wikitable" style="line-height: 1.0"
|- bgcolor="#efefef"
|}
^D
<table>
<tbody>
<tr class="odd">
</tr>
</tbody>
</table>
```
```
% 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
<table>
<tbody>
<tr class="odd">
<td><p>peildatum Simbase</p></td>
<td><p>november 2005</p></td>
<td><p><strong>uitslagen Flohrgambiet</strong></p></td>
<td></td>
</tr>
<tr class="even">
<td><p>totaal aantal partijen Simbase</p></td>
<td><p>7.316.773</p></td>
<td><p>wit wint</p></td>
<td><p>53%</p></td>
</tr>
<tr class="odd">
<td><p>percentage (en partijen) Flohrgambiet</p></td>
<td><p>0.023 % (1.699)</p></td>
<td><p>zwart wint</p></td>
<td><p>27%</p></td>
</tr>
<tr class="even">
<td><p>percentage Flohrgambiet in aug 2003</p></td>
<td><p>0.035 %</p></td>
<td><p>remise</p></td>
<td><p>20%</p></td>
</tr>
</tbody>
</table>
```
```
% 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
<table>
<tbody>
<tr class="odd">
<td></td>
<td><p>Plaats</p></td>
<td><p>Rijder</p></td>
<td><p>Aantal</p></td>
</tr>
<tr class="even">
<td><p>1</p></td>
<td>
<p><a href="Sébastien_Loeb" title="wikilink">Sébastien Loeb</a></p></td>
<td><p>78</p></td>
</tr>
<tr class="odd">
<td><p>2</p></td>
<td>
<p><strong><a href="Sébastien_Ogier" title="wikilink">Sébastien Ogier</a></strong></p></td>
<td><p>38</p></td>
</tr>
<tr class="even">
<td><p>10</p></td>
<td>
<p><a href="Hannu_Mikkola" title="wikilink">Hannu Mikkola</a></p></td>
<td><p>18</p></td>
</tr>
</tbody>
</table>
```