@@ 2,6 2,7 @@ module Data.Text.ParagraphLayout.Internal.Paginable
( PageOptions (..)
, Paginable
, paginate
+ , paginateAll
)
where
@@ 78,3 79,12 @@ instance Paginable (ParagraphLayout d) where
paginate opts pl = case paginate opts (cutLines pl) of
(c, p, Nothing) -> (c, mergeLines p, Nothing)
(c, p, Just rest) -> (c, mergeLines p, Just (mergeLines rest))
+
+-- | Perform page breaking on the entire input, returning a list of pages.
+paginateAll :: Paginable a => PageOptions -> a -> [(PageContinuity, a)]
+paginateAll opts pl = case paginate opts pl of
+ (c, pl1, next) -> (c, pl1) : case next of
+ Just pl2 -> paginateAll opts' pl2
+ Nothing -> []
+ where
+ opts' = opts { pageCurrentHeight = pageNextHeight opts }
@@ 5,6 5,7 @@ import Test.Hspec
import System.FilePath ((</>))
import Data.Text.ParagraphLayout
import Data.Text.ParagraphLayout.FontLoader
+import Data.Text.ParagraphLayout.Internal.Paginable
import Data.Text.ParagraphLayout.Internal.Plain.ParagraphLayout
import Data.Text.ParagraphLayout.Plain
import Data.Text.ParagraphLayout.Plain.ParagraphData
@@ 12,22 13,12 @@ import Data.Text.ParagraphLayout.PrettyShow
import Data.Text.ParagraphLayout.PrettyShow.Golden
import Data.Text.ParagraphLayout.Rect
-type Page d = (PageContinuity, ParagraphLayout d)
-
emptyLayout :: ParagraphLayout d
emptyLayout = ParagraphLayout (Rect 0 0 0 0) []
emptySpanLayout :: ParagraphLayout d
emptySpanLayout = ParagraphLayout (Rect 0 0 0 0) [SpanLayout []]
-paginateAll :: PageOptions -> ParagraphLayout d -> [Page d]
-paginateAll opts pl = case paginate opts pl of
- (c, pl1, next) -> (c, pl1) : case next of
- Just pl2 -> paginateAll opts' pl2
- Nothing -> []
- where
- opts' = opts { pageCurrentHeight = pageNextHeight opts }
-
spec :: Spec
spec = do