git.iko.soy/typeable/pandoc
on master help sign in
Parsing: Fixed bug in grid table parser.

Spaces at end of line were not being stripped properly, resulting in unintended LineBreaks.

commitba1d0d30707d64b783fba5428dc8abd7dddca45b authorJohn MacFarlane <jgm@berkeley.edu> dateFri 14 Jan 2011, 14:16 (16 years ago) parent10747b7
1 file changed+5−5
src/Text/Pandoc/Parsing.hs+5−5
src/Text/Pandoc/Parsing.hs+5−5
@@ -488,8 +488,8 @@ gridTableWith block tableCaption headless =
488488 tableWith (gridTableHeader headless block) (gridTableRow block) (gridTableSep '-') gridTableFooter tableCaption
489489
490490gridTableSplitLine :: [Int] -> String -> [String]
491−gridTableSplitLine indices line =
492− map removeFinalBar $ tail $ splitByIndices (init indices) line
491+gridTableSplitLine indices line = map removeFinalBar $ tail $
492+ splitByIndices (init indices) $ removeTrailingSpace line
493493
494494gridPart :: Char -> GenParser Char st (Int, Int)
495495gridPart ch = do
@@ -501,8 +501,8 @@ gridDashedLines :: Char -> GenParser Char st [(Int,Int)]
501501gridDashedLines ch = try $ char '+' >> many1 (gridPart ch) >>~ blankline
502502
503503removeFinalBar :: String -> String
504−removeFinalBar = reverse . dropWhile (=='|') . dropWhile (`elem` " \t") .
505− reverse
504+removeFinalBar =
505+ reverse . dropWhile (`elem` " \t") . dropWhile (=='|') . reverse
506506
507507-- | Separator between rows of grid table.
508508gridTableSep :: Char -> GenParser Char ParserState Char
@@ -539,7 +539,7 @@ gridTableRawLine :: [Int] -> GenParser Char ParserState [String]
539539gridTableRawLine indices = do
540540 char '|'
541541 line <- many1Till anyChar newline
542− return (gridTableSplitLine indices $ removeTrailingSpace line)
542+ return (gridTableSplitLine indices line)
543543
544544-- | Parse row of grid table.
545545gridTableRow :: GenParser Char ParserState Block