> module Href

- >        (hrefs)

>         where

> import Codec.Binary.Base64.String (encode)
> import Data.List.Utils
> import Data.List.Split

> import Sorttags
> import Delimiters

> markenc s = [inv1] ++  (encode s) ++ [inv2]

> pound s = replace " " "£" s

-  > markenc' s = [inv1] ++ (pound s) ++ [inv2] -- testing only

> ishref s = (take 4 s == "http" && '[' `elem` s) || (take 3 s == "ftp" && '[' `elem` s)

> encdescs line = sorttags "[" "]" markenc line

> urlpart s | ishref s = takeWhile (/= '[') s
>           | otherwise = s

> getdesc s | ishref s = takeWhile (/=']') ((splitOn "[" s)!!1)
>           | otherwise = s

> href w  | ishref w = "<href>"  ++ urlpart w ++ "</href>" ++
>                       "<desc>" ++ getdesc w ++ "</desc>" ++ (splitOn "]" w)!!1
>         | otherwise = w

> hrefline = unwords    .
>            (map href) .
>            words      .
>            encdescs

> hrefs = unlines . (map hrefline) . lines




> a = "http://foo.bar"
> b = "hello yes, this http://www.bbc.co.uk[The BBC]!). and the http://www.itv.com[commerical television station] is"
> c = "Here is the http://www.bbc.co.uk[BBC Web Site], and here is \n\n something else http://crap.com[this that the other]...-- moo."
