forked from marko/svitak
Documentation
This commit is contained in:
parent
a41828dbbd
commit
a53ef52902
1 changed files with 4 additions and 3 deletions
|
|
@ -121,6 +121,7 @@ getMimeFromManifest (DMan.Manifest items) relPath =
|
||||||
Just item -> T.pack $ DMan.mfiMediaType item
|
Just item -> T.pack $ DMan.mfiMediaType item
|
||||||
Nothing -> "image/jpeg"
|
Nothing -> "image/jpeg"
|
||||||
|
|
||||||
|
-- Replace img tags with base64
|
||||||
embedImages :: EpubEnv -> [Tag T.Text] -> [Tag T.Text]
|
embedImages :: EpubEnv -> [Tag T.Text] -> [Tag T.Text]
|
||||||
embedImages env = map processTag
|
embedImages env = map processTag
|
||||||
where
|
where
|
||||||
|
|
@ -128,7 +129,7 @@ embedImages env = map processTag
|
||||||
processTag other = other
|
processTag other = other
|
||||||
|
|
||||||
replaceSrc (name, value)
|
replaceSrc (name, value)
|
||||||
| name == "src" = ("src", findImage value)
|
| name == "src" = ("src", findImage value) -- guards to check for src otherwise output the argument it was given without changes
|
||||||
| otherwise = (name, value)
|
| otherwise = (name, value)
|
||||||
|
|
||||||
findImage path =
|
findImage path =
|
||||||
|
|
@ -145,7 +146,7 @@ filterJunk :: [Tag T.Text] -> [Tag T.Text]
|
||||||
filterJunk = go
|
filterJunk = go
|
||||||
where
|
where
|
||||||
go [] = []
|
go [] = []
|
||||||
go (TagOpen name _ : xs) | name `elem` ["script", "style", "head", "link", "meta"] =
|
go (TagOpen name _ : xs) | name `elem` ["script", "style", "head", "link", "meta"] = -- these are elems we want to filter out
|
||||||
go (dropUntilClose name xs)
|
go (dropUntilClose name xs)
|
||||||
go (x:xs) = x : go xs
|
go (x:xs) = x : go xs
|
||||||
|
|
||||||
|
|
@ -156,7 +157,7 @@ filterJunk = go
|
||||||
getChapterTitle :: [Tag T.Text] -> T.Text
|
getChapterTitle :: [Tag T.Text] -> T.Text
|
||||||
getChapterTitle tags =
|
getChapterTitle tags =
|
||||||
case dropWhile (not . ishding) tags of
|
case dropWhile (not . ishding) tags of
|
||||||
(TagOpen x _ : xs ) -> T.strip $ innerText (takeWhile (not . isclose x) xs)
|
(TagOpen x _ : xs ) -> T.strip $ innerText (takeWhile (not . isclose x) xs) -- get the raw heading content, remove nested tags
|
||||||
_ -> "Untitled Chapter"
|
_ -> "Untitled Chapter"
|
||||||
where
|
where
|
||||||
ishding (TagOpen n _ ) = n `elem` ["h1", "h2", "h3"]
|
ishding (TagOpen n _ ) = n `elem` ["h1", "h2", "h3"]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue