Added function to compute the minimal width of a document

This commit is contained in:
Björn Peemöller 2015-02-03 14:30:46 +01:00 committed by John MacFarlane
parent 6246d6e213
commit 18f5d25abe

View file

@ -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.