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 System.IO (BufferMode(..), hSetBuffering, stdout)
|
||||||
import Text.Printf (printf)
|
import Text.Printf (printf)
|
||||||
|
|
||||||
displayPage :: Page -> FontCache IO ()
|
displayPage :: Int -> Page -> FontCache IO ()
|
||||||
displayPage = withResources (
|
displayPage n = withResources (
|
||||||
r Contents
|
r Contents
|
||||||
>=> sequence_ . mapi (\objectId ->
|
>=> sequence_ . mapi (\objectId ->
|
||||||
r Chunks >=> sequence_ . mapWithKey (display objectId)
|
r Chunks >=> sequence_ . mapWithKey (display objectId)
|
||||||
|
@ -29,15 +29,16 @@ displayPage = withResources (
|
||||||
where
|
where
|
||||||
display a b v =
|
display a b v =
|
||||||
liftIO . putStrLn $
|
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 -> IO ()
|
||||||
getAll layer =
|
getAll layer =
|
||||||
r Pages layer
|
Map.toList <$> r Pages layer
|
||||||
>>= flip runReaderT layer . cacheFonts . mapM_ (displayPage . snd) . Map.toList
|
>>= flip runReaderT layer . cacheFonts . mapM_ (uncurry displayPage)
|
||||||
|
|
||||||
get :: Int -> Layer -> IO ()
|
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 :: FilePath -> (Layer -> IO ()) -> IO ()
|
||||||
onDoc inputFile f = do
|
onDoc inputFile f = do
|
||||||
|
|
Loading…
Reference in New Issue