Markdown reader: allow one-column pipe tables with pipe on right.
See #7919. We still need to implement this for gfm (commonmark). This must be done via changes in commonmark-hs.
This commit is contained in:
parent
495ae605e3
commit
85136b064f
2 changed files with 66 additions and 6 deletions
|
@ -1364,9 +1364,9 @@ pipeBreak = try $ do
|
|||
openPipe <- (True <$ char '|') <|> return False
|
||||
first <- pipeTableHeaderPart
|
||||
rest <- many $ sepPipe *> pipeTableHeaderPart
|
||||
-- surrounding pipes needed for a one-column table:
|
||||
guard $ not (null rest && not openPipe)
|
||||
optional (char '|')
|
||||
closePipe <- (True <$ char '|') <|> return False
|
||||
-- at least one pipe needed for a one-column table:
|
||||
guard $ not (null rest && not (openPipe || closePipe))
|
||||
blankline
|
||||
return $ unzip (first:rest)
|
||||
|
||||
|
@ -1406,9 +1406,10 @@ pipeTableRow = try $ do
|
|||
-- split into cells
|
||||
let chunk = void (code <|> math <|> rawHtmlInline <|> escapedChar <|> rawLaTeXInline')
|
||||
<|> void (noneOf "|\n\r")
|
||||
cells <- (snd <$> withRaw (many chunk)) `sepEndBy1` char '|'
|
||||
-- surrounding pipes needed for a one-column table:
|
||||
guard $ not (length cells == 1 && not openPipe)
|
||||
cells <- (snd <$> withRaw (many chunk)) `sepBy1` char '|'
|
||||
closePipe <- (True <$ char '|') <|> return False
|
||||
-- at least one pipe needed for a one-column table:
|
||||
guard $ not (length cells == 1 && not (openPipe || closePipe))
|
||||
blankline
|
||||
return cells
|
||||
|
||||
|
|
59
test/command/7919.md
Normal file
59
test/command/7919.md
Normal file
|
@ -0,0 +1,59 @@
|
|||
```
|
||||
% pandoc -f markdown
|
||||
single column table |
|
||||
------------------- |
|
||||
item 1 |
|
||||
item 2 |
|
||||
^D
|
||||
<table>
|
||||
<thead>
|
||||
<tr class="header">
|
||||
<th>single column table</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td>item 1</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td>item 2</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
```
|
||||
|
||||
```
|
||||
% pandoc -f markdown
|
||||
| single column table
|
||||
| -------------------
|
||||
| item 1
|
||||
| item 2
|
||||
^D
|
||||
<table>
|
||||
<thead>
|
||||
<tr class="header">
|
||||
<th>single column table</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td>item 1</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td>item 2</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
```
|
||||
|
||||
```
|
||||
% pandoc -f markdown
|
||||
single column table
|
||||
-------------------
|
||||
item 1
|
||||
item 2
|
||||
^D
|
||||
<h2 id="single-column-table">single column table</h2>
|
||||
<p>item 1 item 2</p>
|
||||
```
|
||||
|
Loading…
Reference in a new issue