From 6246d6e213fb8de8ba6561459c80088374853ee6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Peem=C3=B6ller?= Date: Tue, 3 Feb 2015 14:30:28 +0100 Subject: Added error message for illegal call to Pretty.block --- src/Text/Pandoc/Pretty.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/Text/Pandoc/Pretty.hs') 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 -- cgit v1.2.3