@@ -11,17 +11,18 @@ import Data.List (isPrefixOf)
1111import System.FilePath (splitPath, takeDirectory, joinPath)
1212import qualified Data.Set as S
1313
14−import Text.HTML.TagSoup (Tag (..), renderTags, parseTags)
14+import qualified Text.HTML.TagSoup as TS
1515
1616-- | Apply a function to each URL on a webpage
1717--
1818withUrls :: (String -> String) -> String -> String
19−withUrls f = renderTags . map tag . parseTags
19+withUrls f = TS.renderTagsOptions opts . map tag . TS.parseTags
2020 where
21− tag (TagOpen s a) = TagOpen s $ map attr a
22− tag x = x
23− attr (k, v) = (k, if k `S.member` refs then f v else v)
24− refs = S.fromList ["src", "href"]
21+ tag (TS.TagOpen s a) = TS.TagOpen s $ map attr a
22+ tag x = x
23+ attr (k, v) = (k, if k `S.member` refs then f v else v)
24+ refs = S.fromList ["src", "href"]
25+ opts = TS.renderOptions {TS.optEscape = id}
2526
2627-- | Convert a filepath to an URL starting from the site root
2728--
@@ -43,12 +44,12 @@ toSiteRoot :: String -> String
4344toSiteRoot = emptyException . joinPath . map parent
4445 . filter relevant . splitPath . takeDirectory
4546 where
46− parent = const ".."
47+ parent = const ".."
4748 emptyException [] = "."
4849 emptyException x = x
49− relevant "." = False
50− relevant "/" = False
51− relevant _ = True
50+ relevant "." = False
51+ relevant "/" = False
52+ relevant _ = True
5253
5354-- | Check if an URL links to an external HTTP(S) source
5455--