Complete mapping from spine to full path in manifest
This commit is contained in:
parent
4bc89a49c1
commit
a9e774676e
1 changed files with 5 additions and 5 deletions
|
|
@ -8,7 +8,7 @@ import Text.HTML.Scalpel (scrape, text, tagSelector, attr, attrs, Scraper, chroo
|
|||
import System.FilePath (takeDirectory, (</>))
|
||||
import Control.Monad.Reader
|
||||
import qualified Data.Text as T
|
||||
import Data.Maybe (fromMaybe)
|
||||
import Data.Maybe (fromMaybe, catMaybes)
|
||||
import qualified Data.Map as M
|
||||
|
||||
type EpubAction a = ReaderT EpubEnv IO a
|
||||
|
|
@ -62,7 +62,6 @@ getTagText tagName tags =
|
|||
let scraper = text (tagSelector tagName)
|
||||
in T.pack $ fromMaybe "" (scrape scraper tags)
|
||||
|
||||
|
||||
getSpine :: [Tag String] -> [T.Text]
|
||||
getSpine tags =
|
||||
map T.pack . fromMaybe [] $ scrape (attrs "idref" (tagSelector "itemref")) tags
|
||||
|
|
@ -81,7 +80,8 @@ resolvePath spineId = do
|
|||
m <- asks manifestMap
|
||||
p <- asks rootPrefix
|
||||
|
||||
let mHref = M.lookup spineId m
|
||||
pure $ fmap (\href -> p </> T.unpack href) (M.lookup spineId m)
|
||||
|
||||
|
||||
pure $ fmap (\href -> p </> T.unpack href) mHref
|
||||
resolveSpine :: EpubAction [FilePath]
|
||||
resolveSpine =
|
||||
catMaybes <$> (asks spine >>= mapM resolvePath)
|
||||
|
|
|
|||
Loading…
Reference in a new issue