From a53ef529024c7122543cb9636a6b10bba0df2d88 Mon Sep 17 00:00:00 2001 From: Marko Andjelic Date: Wed, 4 Feb 2026 02:12:28 +0000 Subject: [PATCH] Documentation --- app/EpubParser.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/EpubParser.hs b/app/EpubParser.hs index 8a06d95..e3c99d3 100644 --- a/app/EpubParser.hs +++ b/app/EpubParser.hs @@ -121,6 +121,7 @@ getMimeFromManifest (DMan.Manifest items) relPath = Just item -> T.pack $ DMan.mfiMediaType item Nothing -> "image/jpeg" +-- Replace img tags with base64 embedImages :: EpubEnv -> [Tag T.Text] -> [Tag T.Text] embedImages env = map processTag where @@ -128,7 +129,7 @@ embedImages env = map processTag processTag other = other 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) findImage path = @@ -145,7 +146,7 @@ filterJunk :: [Tag T.Text] -> [Tag T.Text] filterJunk = go where 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 (x:xs) = x : go xs @@ -156,7 +157,7 @@ filterJunk = go getChapterTitle :: [Tag T.Text] -> T.Text getChapterTitle tags = 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" where ishding (TagOpen n _ ) = n `elem` ["h1", "h2", "h3"]