git.iko.soy/typeable/pandoc
on master help sign in
Added error message for illegal call to Pretty.block
commit6246d6e213fb8de8ba6561459c80088374853ee6 authorBjörn Peemöller <bjp@informatik.uni-kiel.de> dateTue 3 Feb 2015, 14:30 (12 years ago) parentd905551
1 file changed+6−3
src/Text/Pandoc/Pretty.hs+6−3
src/Text/Pandoc/Pretty.hs+6−3
@@ -419,9 +419,6 @@ offset d = case map realLength . lines . render Nothing $ d of
419419 [] -> 0
420420 os -> maximum os
421421
422−block :: (String -> String) -> Int -> Doc -> Doc
423−block filler width = Doc . singleton . Block width .
424− map filler . chop width . render (Just width)
425422
426423-- | @lblock n d@ is a block of width @n@ characters, with
427424-- 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
440437height :: Doc -> Int
441438height = length . lines . render Nothing
442439
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+
443446chop :: Int -> String -> [String]
444447chop _ [] = []
445448chop n cs = case break (=='\n') cs of