Added error message for illegal call to Pretty.block

This commit is contained in:
Björn Peemöller 2015-02-03 14:30:28 +01:00 committed by John MacFarlane
parent d905551b12
commit 6246d6e213

View file

@ -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