import Test.Framework.Providers.HUnit (testCase)
import Text.Regex.Posix ((=~))
import Text.XML.HXT.Core (
- (>>>),
- arr,
- hread,
selem,
none,
runX,
to_xml (Byline Nothing) = none
instance XML BodyHtml where
- to_xml (BodyHtml bh) =
- (arr $ const bh) >>> hread
+ -- Don't question this. I tried to do it correctly and
+ -- all hell broke loose.
+ to_xml (BodyHtml bh) = txt bh
data Article = Article { title :: Title,
byline :: Byline,
where
abs_current = try_make_absolute_url ("/" ++ path)
abs_article = try_make_absolute_url ("Articles/" ++ path)
+ abs_full_article = try_make_absolute_url path
check_cases :: String
check_cases
| is_lwn_url path = make_https path
| isPrefixOf "current" path = abs_current
| path =~ "^[0-9]+$" = abs_article
+ | path =~ "^/Articles/[0-9]+/?$" = abs_full_article
| otherwise = path -- Give up