Internal Link Canonicalisation Pluing

> module URLFormat (plugin) where
> 
> -- This plugin converts links so that they are spaced by
> -- hyphens rather than escaped html spaces ("%20").
> -- It also maps the characters to lowercase
>  
> import Network.Gitit.Interface
> import Data.List.Utils (replace)
> import Data.List (isPrefixOf)
> import Data.Char (toLower)
> 
> plugin :: Plugin
> plugin = mkPageTransform linkTransform
> 
> format url = if ("http" `isPrefixOf` url) then
> 		 url
> 		 else map toLower (replace "%20" "-" url)
> 
> formatLink:: Inline -> Inline
> formatLink (Link text (url, title)) = Link text (format url, title)
> formatLink x = x
> 
> linkTransform :: [Inline] -> [Inline]
> linkTransform ((Link x y):xs) = formatLink (Link x y):linkTransform xs
> linkTransform (x:xs)        = x : linkTransform xs
> linkTransform []            = []