From 7b8c005d0789cc397b99c3be7a936a016b01f7f2 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 10 Aug 2015 16:35:43 -0700 Subject: EPUB reader: stop mangling external URLs. Closes #2284. Note the changes to the test suite. In each case, a mangled external link has been fixed, so these are all positive. --- src/Text/Pandoc/Readers/EPUB.hs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Readers/EPUB.hs b/src/Text/Pandoc/Readers/EPUB.hs index 338540533..aefc32e0e 100644 --- a/src/Text/Pandoc/Readers/EPUB.hs +++ b/src/Text/Pandoc/Readers/EPUB.hs @@ -181,7 +181,6 @@ getManifest archive = do fixInternalReferences :: FilePath -> Pandoc -> Pandoc fixInternalReferences pathToFile = (walk $ renameImages root) - . (walk normalisePath) . (walk $ fixBlockIRs filename) . (walk $ fixInlineIRs filename) where @@ -196,12 +195,6 @@ fixInlineIRs s (Link t ('#':url, tit)) = Link t (addHash s url, tit) fixInlineIRs _ v = v -normalisePath :: Inline -> Inline -normalisePath (Link t (url, tit)) = - let (path, uid) = span (/= '#') url in - Link t (takeFileName path ++ uid, tit) -normalisePath s = s - prependHash :: [String] -> Inline -> Inline prependHash ps l@(Link is (url, tit)) | or [s `isPrefixOf` url | s <- ps] = @@ -223,7 +216,7 @@ fixAttrs s (ident, cs, kvs) = (addHash s ident, filter (not . null) cs, removeEP addHash :: String -> String -> String addHash _ "" = "" -addHash s ident = s ++ "#" ++ ident +addHash s ident = takeFileName s ++ "#" ++ ident removeEPUBAttrs :: [(String, String)] -> [(String, String)] removeEPUBAttrs kvs = filter (not . isEPUBAttr) kvs -- cgit v1.2.3