Added error message for illegal call to Pretty.block
This commit is contained in:
parent
d905551b12
commit
6246d6e213
1 changed files with 6 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue