@@ -840,7 +840,6 @@ simpleTable headless = do
840 Table c a _w h l <- tableWith (simpleTableHeader headless) tableLine
840 Table c a _w h l <- tableWith (simpleTableHeader headless) tableLine
841 (return ())
841 (return ())
842 (if headless then tableFooter else tableFooter <|> blanklines)
842 (if headless then tableFooter else tableFooter <|> blanklines)
844 -- Simple tables get 0s for relative column widths (i.e., use default)
843 -- Simple tables get 0s for relative column widths (i.e., use default)
845 return $ Table c a (replicate (length a) 0) h l
844 return $ Table c a (replicate (length a) 0) h l
@@ -851,7 +850,7 @@ simpleTable headless = do
851multilineTable :: Bool -- ^ Headerless table
850multilineTable :: Bool -- ^ Headerless table
852 -> Parser [Char] ParserState Block
851 -> Parser [Char] ParserState Block
853multilineTable headless =
852multilineTable headless =
854− tableWith (multilineTableHeader headless) multilineRow blanklines tableFooter tableCaption
853+ tableWith (multilineTableHeader headless) multilineRow blanklines tableFooter
856multilineTableHeader :: Bool -- ^ Headerless table
855multilineTableHeader :: Bool -- ^ Headerless table
857 -> Parser [Char] ParserState ([[Block]], [Alignment], [Int])
856 -> Parser [Char] ParserState ([[Block]], [Alignment], [Int])
@@ -903,12 +902,12 @@ alignType strLst len =
904gridTable :: Bool -- ^ Headerless table
903gridTable :: Bool -- ^ Headerless table
905 -> Parser [Char] ParserState Block
904 -> Parser [Char] ParserState Block
906−gridTable = gridTableWith block tableCaption
905+gridTable = gridTableWith block
908pipeTable :: Bool -- ^ Headerless table
907pipeTable :: Bool -- ^ Headerless table
909 -> Parser [Char] ParserState Block
908 -> Parser [Char] ParserState Block
910pipeTable headless = tableWith (pipeTableHeader headless)
909pipeTable headless = tableWith (pipeTableHeader headless)
911− (\_ -> pipeTableRow) (return ()) blanklines tableCaption
910+ (\_ -> pipeTableRow) (return ()) blanklines
913-- | Parse header for an pipe table.
912-- | Parse header for an pipe table.
914pipeTableHeader :: Bool -- ^ Headerless table
913pipeTableHeader :: Bool -- ^ Headerless table
@@ -961,12 +960,19 @@ scanForPipe :: Parser [Char] st ()
961scanForPipe = lookAhead (manyTill (satisfy (/='\n')) (char '|')) >> return ()
960scanForPipe = lookAhead (manyTill (satisfy (/='\n')) (char '|')) >> return ()
963table :: Parser [Char] ParserState Block
962table :: Parser [Char] ParserState Block
964+ frontCaption <- option [] tableCaption
965+ Table _ aligns widths heads lines' <-
964−table = multilineTable False <|> simpleTable True <|>
966+ multilineTable False <|> simpleTable True <|>
965− simpleTable False <|> multilineTable True <|>
967+ simpleTable False <|> multilineTable True <|>
966− pipeTable False <|> pipeTable True <|>
968+ pipeTable False <|> pipeTable True <|>
967− gridTable False <|> gridTable True <?> "table"
969+ gridTable False <|> gridTable True <?> "table"
970+ caption <- if null frontCaption
971+ then option [] tableCaption
972+ else return frontCaption
973+ return $ Table caption aligns widths heads lines'