diff options
author | Björn Peemöller <bjp@informatik.uni-kiel.de> | 2015-02-03 14:30:46 +0100 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2016-11-19 23:04:29 +0100 |
commit | 18f5d25abe174683f73ddc177a9a7506d94a8236 (patch) | |
tree | 44279ea5e7595f3f92d1467c21fc4e56c675fe0d /src | |
parent | 6246d6e213fb8de8ba6561459c80088374853ee6 (diff) |
Added function to compute the minimal width of a document
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Pretty.hs | 4 |
1 files changed, 4 insertions, 0 deletions
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. |