Include page numbers in chunks label, needed for long documents with many pages
This commit is contained in:
parent
5722dd1a04
commit
5027b079eb
|
@ -19,8 +19,8 @@ import System.Exit (die)
|
|||
import System.IO (BufferMode(..), hSetBuffering, stdout)
|
||||
import Text.Printf (printf)
|
||||
|
||||
displayPage :: Page -> FontCache IO ()
|
||||
displayPage = withResources (
|
||||
displayPage :: Int -> Page -> FontCache IO ()
|
||||
displayPage n = withResources (
|
||||
r Contents
|
||||
>=> sequence_ . mapi (\objectId ->
|
||||
r Chunks >=> sequence_ . mapWithKey (display objectId)
|
||||
|
@ -29,15 +29,16 @@ displayPage = withResources (
|
|||
where
|
||||
display a b v =
|
||||
liftIO . putStrLn $
|
||||
printf "%d@%d: %s" (getId a) (getId b) (Text.unpack v)
|
||||
printf "p#%d obj#%d instr#%d: %s" n (getId a) (getId b) (Text.unpack v)
|
||||
|
||||
getAll :: Layer -> IO ()
|
||||
getAll layer =
|
||||
r Pages layer
|
||||
>>= flip runReaderT layer . cacheFonts . mapM_ (displayPage . snd) . Map.toList
|
||||
Map.toList <$> r Pages layer
|
||||
>>= flip runReaderT layer . cacheFonts . mapM_ (uncurry displayPage)
|
||||
|
||||
get :: Int -> Layer -> IO ()
|
||||
get n layer = r (P n) layer >>= flip runReaderT layer . cacheFonts . displayPage
|
||||
get n layer =
|
||||
r (P n) layer >>= flip runReaderT layer . cacheFonts . displayPage n
|
||||
|
||||
onDoc :: FilePath -> (Layer -> IO ()) -> IO ()
|
||||
onDoc inputFile f = do
|
||||
|
|
Loading…
Reference in New Issue