@@ -1221,11 +1221,20 @@ removeOneLeadingSpace xs =
12211221gridTableFooter :: MarkdownParser [Char]
12221222gridTableFooter = blanklines
12231223
1224+pipeBreak :: MarkdownParser [Alignment]
1225+pipeBreak = try $ do
1226+ nonindentSpaces
1227+ openPipe <- (True <$ char '|') <|> return False
1228+ first <- pipeTableHeaderPart
1229+ rest <- many $ sepPipe *> pipeTableHeaderPart
1230+ -- surrounding pipes needed for a one-column table:
1231+ guard $ not (null rest && not openPipe)
1232+ optional (char '|')
1233+ blankline
1234+ return (first:rest)
1235+
12241236pipeTable :: MarkdownParser ([Alignment], [Double], F [Blocks], F [[Blocks]])
12251237pipeTable = try $ do
1226− let pipeBreak = nonindentSpaces *> optional (char '|') *>
1227− pipeTableHeaderPart `sepBy1` sepPipe <*
1228− optional (char '|') <* blankline
12291238 (heads,aligns) <- try ( pipeBreak >>= \als ->
12301239 return (return $ replicate (length als) mempty, als))
12311240 <|> ( pipeTableRow >>= \row -> pipeBreak >>= \als ->
@@ -1244,12 +1253,13 @@ sepPipe = try $ do
12441253pipeTableRow :: MarkdownParser (F [Blocks])
12451254pipeTableRow = do
12461255 nonindentSpaces
1247− optional (char '|')
1256+ openPipe <- (True <$ char '|') <|> return False
12481257 let cell = mconcat <$>
12491258 many (notFollowedBy (blankline <|> char '|') >> inline)
12501259 first <- cell
1251− sepPipe
1252− rest <- cell `sepBy1` sepPipe
1260+ rest <- many $ sepPipe *> cell
1261+ -- surrounding pipes needed for a one-column table:
1262+ guard $ not (null rest && not openPipe)
12531263 optional (char '|')
12541264 blankline
12551265 let cells = sequence (first:rest)