From 7df656089f960b5c0f329776d6ebc0094b0fef30 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Tue, 21 Jun 2016 21:11:28 +0200 Subject: Org reader: remove partial functions Partial functions like `head` lead to avoidable errors and should be avoided. They are replaced with total functions. This fixes #2991. --- src/Text/Pandoc/Readers/Org/Blocks.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Readers/Org/Blocks.hs') diff --git a/src/Text/Pandoc/Readers/Org/Blocks.hs b/src/Text/Pandoc/Readers/Org/Blocks.hs index 75e564f2f..f8ff3f928 100644 --- a/src/Text/Pandoc/Readers/Org/Blocks.hs +++ b/src/Text/Pandoc/Readers/Org/Blocks.hs @@ -219,7 +219,7 @@ rawBlockContent blockType = try $ do stripIndent strs = map (drop (shortestIndent strs)) strs shortestIndent :: [String] -> Int - shortestIndent = minimum + shortestIndent = foldr min maxBound . map (length . takeWhile isSpace) . filter (not . null) @@ -727,7 +727,9 @@ normalizeTable (OrgTable aligns heads rows) = OrgTable aligns' heads rows where refRow = if heads /= mempty then heads - else if rows == mempty then mempty else head rows + else case rows of + (r:_) -> r + _ -> mempty cols = length refRow fillColumns base padding = take cols $ base ++ repeat padding aligns' = fillColumns aligns AlignDefault -- cgit v1.2.3