git.iko.soy/typeable/pandoc
on master help sign in
Markdown reader tables: Fixed bug in alignments.

Previously pandoc got confused by blank rows in the header.

commit8a3fd7606fdc82fa476553a53e4b54f5ef9d5de9 authorJohn MacFarlane <jgm@berkeley.edu> dateSat 29 Jan 2011, 23:09 (16 years ago) parentcaa091e
1 file changed+5−4
src/Text/Pandoc/Readers/Markdown.hs+5−4
src/Text/Pandoc/Readers/Markdown.hs+5−4
@@ -869,10 +869,11 @@ alignType :: [String]
869869 -> Alignment
870870alignType [] _ = AlignDefault
871871alignType strLst len =
872− let s = head $ sortBy (comparing length) $
873− map removeTrailingSpace strLst
874− leftSpace = if null s then False else (s !! 0) `elem` " \t"
875− rightSpace = length s < len || (s !! (len - 1)) `elem` " \t"
872+ let nonempties = filter (not . null) $ map removeTrailingSpace strLst
873+ (leftSpace, rightSpace) =
874+ case sortBy (comparing length) nonempties of
875+ (x:_) -> (head x `elem` " \t", length x < len)
876+ [] -> (False, False)
876877 in case (leftSpace, rightSpace) of
877878 (True, False) -> AlignRight
878879 (False, True) -> AlignLeft