@@ -1221,11 +1221,20 @@ removeOneLeadingSpace xs =
1221gridTableFooter :: MarkdownParser [Char]
1221gridTableFooter :: MarkdownParser [Char]
1222gridTableFooter = blanklines
1222gridTableFooter = blanklines
1224+pipeBreak :: MarkdownParser [Alignment]
1225+pipeBreak = try $ do
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 '|')
1234+ return (first:rest)
1224pipeTable :: MarkdownParser ([Alignment], [Double], F [Blocks], F [[Blocks]])
1236pipeTable :: MarkdownParser ([Alignment], [Double], F [Blocks], F [[Blocks]])
1225pipeTable = try $ do
1237pipeTable = try $ do
1226− let pipeBreak = nonindentSpaces *> optional (char '|') *>
1227− pipeTableHeaderPart `sepBy1` sepPipe <*
1228− optional (char '|') <* blankline
1229 (heads,aligns) <- try ( pipeBreak >>= \als ->
1238 (heads,aligns) <- try ( pipeBreak >>= \als ->
1230 return (return $ replicate (length als) mempty, als))
1239 return (return $ replicate (length als) mempty, als))
1231 <|> ( pipeTableRow >>= \row -> pipeBreak >>= \als ->
1240 <|> ( pipeTableRow >>= \row -> pipeBreak >>= \als ->
@@ -1244,12 +1253,13 @@ sepPipe = try $ do
1244pipeTableRow :: MarkdownParser (F [Blocks])
1253pipeTableRow :: MarkdownParser (F [Blocks])
1245pipeTableRow = do
1254pipeTableRow = do
1246 nonindentSpaces
1255 nonindentSpaces
1247− optional (char '|')
1256+ openPipe <- (True <$ char '|') <|> return False
1248 let cell = mconcat <$>
1257 let cell = mconcat <$>
1249 many (notFollowedBy (blankline <|> char '|') >> inline)
1258 many (notFollowedBy (blankline <|> char '|') >> inline)
1250 first <- cell
1259 first <- cell
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)
1253 optional (char '|')
1263 optional (char '|')
1254 blankline
1264 blankline
1255 let cells = sequence (first:rest)
1265 let cells = sequence (first:rest)