aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Peemöller <bjp@informatik.uni-kiel.de>2015-02-03 14:30:28 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2016-11-19 23:03:53 +0100
commit6246d6e213fb8de8ba6561459c80088374853ee6 (patch)
treeffeb659979003a22da620d90209e4e1b9fb40bc8
parentd905551b12ebbf1071c26a404e24dcbd4577488f (diff)
downloadpandoc-6246d6e213fb8de8ba6561459c80088374853ee6.tar.gz
Added error message for illegal call to Pretty.block
-rw-r--r--src/Text/Pandoc/Pretty.hs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Pretty.hs b/src/Text/Pandoc/Pretty.hs
index 0bac628af..cce5d3d5a 100644
--- a/src/Text/Pandoc/Pretty.hs
+++ b/src/Text/Pandoc/Pretty.hs
@@ -419,9 +419,6 @@ offset d = case map realLength . lines . render Nothing $ d of
[] -> 0
os -> maximum os
-block :: (String -> String) -> Int -> Doc -> Doc
-block filler width = Doc . singleton . Block width .
- map filler . chop width . render (Just width)
-- | @lblock n d@ is a block of width @n@ characters, with
-- text derived from @d@ and aligned to the left.
@@ -440,6 +437,12 @@ cblock w = block (\s -> replicate ((w - realLength s) `div` 2) ' ' ++ s) w
height :: Doc -> Int
height = length . lines . render Nothing
+block :: (String -> String) -> Int -> Doc -> Doc
+block filler width d
+ | width < 1 && not (isEmpty d) = error "Text.Pandoc.Pretty.block: width < 1"
+ | otherwise = Doc $ singleton $ Block width $ map filler
+ $ chop width $ render (Just width) d
+
chop :: Int -> String -> [String]
chop _ [] = []
chop n cs = case break (=='\n') cs of