module Utils
( stripLocalAnchors
, stripLocalLinks
, stripLocalReferences
) where
import Data.List
replaceBetween :: Eq a => [a] -> a -> [a] -> [a] -> [a]
replaceBetween _ _ _ [] = []
replaceBetween pref end val html@(x:xs') = case stripPrefix pref html of
Just strip -> pref ++ val ++ (replaceBetween' . dropWhile (/= end)) strip
Nothing -> x:(replaceBetween' xs')
where
replaceBetween' = replaceBetween pref end val
stripLocalAnchors :: String -> String
stripLocalAnchors = replaceBetween " String
stripLocalLinks = replaceBetween " String
stripLocalReferences = stripLocalLinks . stripLocalAnchors