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