@@ -913,17 +913,18 @@ pipeTable headless = tableWith (pipeTableHeader headless)
913-- | Parse header for an pipe table.
913-- | Parse header for an pipe table.
914pipeTableHeader :: Bool -- ^ Headerless table
914pipeTableHeader :: Bool -- ^ Headerless table
915 -> Parser [Char] ParserState ([[Block]], [Alignment], [Int])
915 -> Parser [Char] ParserState ([[Block]], [Alignment], [Int])
916−pipeTableHeader headless = try $ do
916+pipeTableHeader headless = do
917− optional blanklines
917+ scanForPipe
918− heads <- if headless
919+ heads <- if headless
919− then return $ repeat []
920+ then return $ repeat []
920− else pipeTableRow
921+ else pipeTableRow
921− aligns <- nonindentSpaces >> optional (char '|') >>
922+ aligns <- nonindentSpaces >> optional (char '|') >>
922− pipeTableHeaderPart `sepBy1` sepPipe
923+ pipeTableHeaderPart `sepBy1` sepPipe
923− optional (char '|')
924+ optional (char '|')
925− let cols = length aligns
926+ let cols = length aligns
926− return (take cols heads, aligns, [])
927+ return (take cols heads, aligns, [])
928sepPipe :: Parser [Char] ParserState ()
929sepPipe :: Parser [Char] ParserState ()
929sepPipe = try $ char '|' >> notFollowedBy blankline
930sepPipe = try $ char '|' >> notFollowedBy blankline
@@ -955,6 +956,10 @@ pipeTableHeaderPart = do
955 (Nothing,Just _) -> AlignRight
956 (Nothing,Just _) -> AlignRight
956 (Just _,Just _) -> AlignCenter
957 (Just _,Just _) -> AlignCenter
959+-- Succeed only if current line contains a pipe.
960+scanForPipe :: Parser [Char] st ()
961+scanForPipe = lookAhead (manyTill (satisfy (/='\n')) (char '|')) >> return ()
958table :: Parser [Char] ParserState Block
963table :: Parser [Char] ParserState Block
959table = multilineTable False <|> simpleTable True <|>
964table = multilineTable False <|> simpleTable True <|>
960 simpleTable False <|> multilineTable True <|>
965 simpleTable False <|> multilineTable True <|>