git.iko.soy/typeable/pandoc
on master help sign in
Remove another foldr1 partial function use.
commit67e173bda116ba9793dd625f782a12ab8e35839b authorJohn MacFarlane <jgm@berkeley.edu> dateThu 18 Mar 2021, 21:10 (6 years ago) parentfd76e60
1 file changed+6−5
src/Text/Pandoc/Readers/Txt2Tags.hs+6−5
src/Text/Pandoc/Readers/Txt2Tags.hs+6−5
@@ -261,7 +261,7 @@ table = try $ do
261261 rows <- many1 (many commentLine *> tableRow)
262262 let columns = transpose rows
263263 let ncolumns = length columns
264− let aligns = map (foldr1 findAlign . map fst) columns
264+ let aligns = map (fromMaybe AlignDefault . foldr findAlign Nothing) columns
265265 let rows' = map (map snd) rows
266266 let size = maximum (map length rows')
267267 let rowsPadded = map (pad size) rows'
@@ -278,10 +278,11 @@ pad :: (Monoid a) => Int -> [a] -> [a]
278278pad n xs = xs ++ replicate (n - length xs) mempty
279279
280280
281−findAlign :: Alignment -> Alignment -> Alignment
282−findAlign x y
283− | x == y = x
284− | otherwise = AlignDefault
281+findAlign :: (Alignment, a) -> Maybe Alignment -> Maybe Alignment
282+findAlign (x,_) (Just y)
283+ | x == y = Just x
284+ | otherwise = Just AlignDefault
285+findAlign (x,_) Nothing = Just x
285286
286287headerRow :: T2T [(Alignment, Blocks)]
287288headerRow = genericRow (string "||")