aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2011-01-29 23:09:07 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2011-01-29 23:09:07 -0800
commit8a3fd7606fdc82fa476553a53e4b54f5ef9d5de9 (patch)
tree20f40338a613a7fa81ee28105326c96eeecc1255 /src/Text
parentcaa091e8105aca357f0ef91b43d636ec62127d5f (diff)
downloadpandoc-8a3fd7606fdc82fa476553a53e4b54f5ef9d5de9.tar.gz
Markdown reader tables: Fixed bug in alignments.
Previously pandoc got confused by blank rows in the header.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 1b9094ab9..58d2158bf 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -869,10 +869,11 @@ alignType :: [String]
-> Alignment
alignType [] _ = AlignDefault
alignType strLst len =
- let s = head $ sortBy (comparing length) $
- map removeTrailingSpace strLst
- leftSpace = if null s then False else (s !! 0) `elem` " \t"
- rightSpace = length s < len || (s !! (len - 1)) `elem` " \t"
+ let nonempties = filter (not . null) $ map removeTrailingSpace strLst
+ (leftSpace, rightSpace) =
+ case sortBy (comparing length) nonempties of
+ (x:_) -> (head x `elem` " \t", length x < len)
+ [] -> (False, False)
in case (leftSpace, rightSpace) of
(True, False) -> AlignRight
(False, True) -> AlignLeft