From 18f5d25abe174683f73ddc177a9a7506d94a8236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Peem=C3=B6ller?= <bjp@informatik.uni-kiel.de> Date: Tue, 3 Feb 2015 14:30:46 +0100 Subject: [PATCH] Added function to compute the minimal width of a document --- src/Text/Pandoc/Pretty.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Text/Pandoc/Pretty.hs b/src/Text/Pandoc/Pretty.hs index cce5d3d5a..e81f4012b 100644 --- a/src/Text/Pandoc/Pretty.hs +++ b/src/Text/Pandoc/Pretty.hs @@ -46,6 +46,7 @@ module Text.Pandoc.Pretty ( , beforeNonBlank , nowrap , offset + , minOffset , height , lblock , cblock @@ -419,6 +420,9 @@ offset d = case map realLength . lines . render Nothing $ d of [] -> 0 os -> maximum os +-- | Returns the minimal width of a 'Doc' when reflowed at breakable spaces. +minOffset :: Doc -> Int +minOffset d = maximum (0: map realLength (lines $ render (Just 0) d)) -- | @lblock n d@ is a block of width @n@ characters, with -- text derived from @d@ and aligned to the left.