diff options
-rw-r--r-- | src/Text/Pandoc/Pretty.hs | 9 |
1 files changed, 6 insertions, 3 deletions
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 |