git.iko.soy/typeable/pandoc
on master help sign in
Added error message for illegal call to Pretty.block
6246d6eBjörn Peemöller
src/Text/Pandoc/Pretty.hs+6−3
@@ -419,9 +419,6 @@ offset d = case map realLength . lines . render Nothing $ d of
419 [] -> 0
419 [] -> 0
420 os -> maximum os
420 os -> maximum os
421
421
422−block :: (String -> String) -> Int -> Doc -> Doc
423−block filler width = Doc . singleton . Block width .
424− map filler . chop width . render (Just width)
425
422
426-- | @lblock n d@ is a block of width @n@ characters, with
423-- | @lblock n d@ is a block of width @n@ characters, with
427-- text derived from @d@ and aligned to the left.
424-- 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
440height :: Doc -> Int
437height :: Doc -> Int
441height = length . lines . render Nothing
438height = length . lines . render Nothing
442
439
440+block :: (String -> String) -> Int -> Doc -> Doc
441+block filler width d
442+ | width < 1 && not (isEmpty d) = error "Text.Pandoc.Pretty.block: width < 1"
443+ | otherwise = Doc $ singleton $ Block width $ map filler
444+ $ chop width $ render (Just width) d
445+
443chop :: Int -> String -> [String]
446chop :: Int -> String -> [String]
444chop _ [] = []
447chop _ [] = []
445chop n cs = case break (=='\n') cs of
448chop n cs = case break (=='\n') cs of