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