@@ -992,29 +992,19 @@ removeOneLeadingSpace xs =
992992gridTableFooter :: Parser [Char] ParserState [Char]
993993gridTableFooter = blanklines
994994
995−pipeTable :: Bool -- ^ Headerless table
996− -> Parser [Char] ParserState ([Alignment], [Double], F [Blocks], F [[Blocks]])
997−pipeTable headless =
998− tableWith (pipeTableHeader headless)
999− (\_ -> pipeTableRow) (return ()) blanklines
1000−
1001−-- | Parse header for an pipe table.
1002−pipeTableHeader :: Bool -- ^ Headerless table
1003− -> Parser [Char] ParserState (F [Blocks], [Alignment], [Int])
1004−pipeTableHeader headless = do
1005− try $ do
1006− heads <- if headless
1007− then return $ return $ repeat mempty
1008− else pipeTableRow
1009− aligns <- nonindentSpaces >> optional (char '|') >>
1010− pipeTableHeaderPart `sepBy1` sepPipe
1011− optional (char '|')
1012− newline
1013− let cols = length aligns
1014− let heads' = if headless
1015− then return (replicate cols mempty)
1016− else heads
1017− return (heads', aligns, [])
995+pipeTable :: Parser [Char] ParserState ([Alignment], [Double], F [Blocks], F [[Blocks]])
996+pipeTable = try $ do
997+ let pipeBreak = nonindentSpaces *> optional (char '|') *>
998+ pipeTableHeaderPart `sepBy1` sepPipe <*
999+ optional (char '|') <* blankline
1000+ (heads,aligns) <- try ( pipeBreak >>= \als ->
1001+ return (return $ replicate (length als) mempty, als))
1002+ <|> ( pipeTableRow >>= \row -> pipeBreak >>= \als ->
1003+ return (row, als) )
1004+ lines' <- fmap sequence $ many1 pipeTableRow
1005+ blanklines
1006+ let widths = replicate (length aligns) 0.0
1007+ return $ (aligns, widths, heads, lines')
10181008
10191009sepPipe :: Parser [Char] ParserState ()
10201010sepPipe = try $ char '|' >> notFollowedBy blankline
@@ -1078,8 +1068,7 @@ table :: Parser [Char] ParserState (F Blocks)
10781068table = try $ do
10791069 frontCaption <- option Nothing (Just <$> tableCaption)
10801070 (aligns, widths, heads, lns) <-
1081− try (guardEnabled Ext_pipe_tables >> scanForPipe >>
1082− (pipeTable True <|> pipeTable False)) <|>
1071+ try (guardEnabled Ext_pipe_tables >> scanForPipe >> pipeTable) <|>
10831072 try (guardEnabled Ext_multiline_tables >>
10841073 multilineTable False) <|>
10851074 try (guardEnabled Ext_simple_tables >>