forked from marko/svitak
epub3 nav support
This commit is contained in:
parent
8ebfc59d2b
commit
0a43a51205
1 changed files with 6 additions and 1 deletions
|
|
@ -25,7 +25,7 @@ import Data.Maybe (fromMaybe)
|
|||
import qualified Data.Text as T
|
||||
import qualified Data.Text.Encoding as TE
|
||||
import System.FilePath (normalise, takeDirectory, (</>))
|
||||
import Text.HTML.Scalpel (Scraper, ScraperT, anySelector, attr, chroot, chroots, html, innerHTML, scrapeStringLike, text)
|
||||
import Text.HTML.Scalpel (Scraper, ScraperT, anySelector, attr, chroot, chroots, html, innerHTML, scrapeStringLike, text, (@:), (@=))
|
||||
import Types (Chapter (..), EpubAction, EpubEnv (..))
|
||||
|
||||
openEpub :: FilePath -> IO (Either String EpubEnv)
|
||||
|
|
@ -87,6 +87,7 @@ resolveSpine = do
|
|||
Right (DSpin.Spine maybeTocId refs) -> do
|
||||
let lookupHref ident = DMan.mfiHref <$> find (\mi -> DMan.mfiId mi == ident) items
|
||||
let maybeTocPath = lookupHref maybeTocId
|
||||
let mNav = scrapeStringLike xmlStr navFinder
|
||||
|
||||
tocMap <- case maybeTocPath of
|
||||
Nothing -> pure []
|
||||
|
|
@ -156,3 +157,7 @@ chapterScraper = do
|
|||
title <- chTitleScraper <|> pure "Untitled Chapter"
|
||||
content <- chroot "body" (innerHTML anySelector) <|> innerHTML anySelector
|
||||
pure (title, content)
|
||||
|
||||
-- needed for epub3 support, find the nav file
|
||||
navFinder :: Scraper String FilePath
|
||||
navFinder = attr "href" ("item" @: ["properties" @= "nav"])
|
||||
|
|
|
|||
Loading…
Reference in a new issue