Get rid of wrapper PageContents structure returned by PageContent in the PDF.Text module (and return directly [ByteString] instead)

This commit is contained in:
Tissevert 2019-11-29 11:48:28 +01:00
parent 42a02808c1
commit 08a9717b3a

View file

@ -1,8 +1,7 @@
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
module PDF.Text (
PageContents(..)
, pageContents
pageContents
) where
import Control.Applicative ((<|>))
@ -76,15 +75,11 @@ nameArg = Typed . NameObject <$> name <* blank
stringArg :: MonadParser m => m Argument
stringArg = Typed . StringObject <$> stringObject <* blank
data PageContents = PageContents {
chunks :: [ByteString]
}
type ParserWithFont = ReaderT CMappers (Parser CMap)
pageContents :: CMappers -> ByteString -> Either String PageContents
pageContents :: CMappers -> ByteString -> Either String [ByteString]
pageContents font input =
evalParser (runReaderT (PageContents <$> page) font) emptyCMap input
evalParser (runReaderT page font) emptyCMap input
page :: ParserWithFont [ByteString]
page = graphicState <|> text <?> "Text page contents"