From 8af6bdb677b6fc91752a5276e8f7a7c17f5881e7 Mon Sep 17 00:00:00 2001 From: Ɓukasz Hanuszczak Date: Wed, 5 Aug 2015 17:58:08 +0200 Subject: Incorporate link stripping to output diffing mechanism. --- html-test/run.hs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/html-test/run.hs b/html-test/run.hs index f416f07c..06f20ee6 100755 --- a/html-test/run.hs +++ b/html-test/run.hs @@ -168,18 +168,16 @@ checkModule mdl = do then Pass else Fail else return NoRef - where - readXml = liftM Xml.parseXMLDoc . readFile diffModule :: FilePath -> String -> IO () diffModule diff mdl = do - out <- readFile $ outFile mdl - ref <- readFile $ refFile mdl - let out' = stripLinks . dropVersion $ out - let ref' = stripLinks . dropVersion $ ref - writeFile outFile' out' - writeFile refFile' ref' + Just outXml <- readXml $ outFile mdl + Just refXml <- readXml $ refFile mdl + let outXml' = strip outXml + let refXml' = strip refXml + writeFile outFile' $ Xml.ppElement outXml' + writeFile refFile' $ Xml.ppElement refXml' putStrLn $ "Diff for module " ++ show mdl ++ ":" handle <- runProcess' diff $ processConfig @@ -265,12 +263,16 @@ deriving instance Eq Xml.Element deriving instance Eq Xml.CData +readXml :: FilePath -> IO (Maybe Xml.Element) +readXml = liftM Xml.parseXMLDoc . readFile + + strip :: Xml.Element -> Xml.Element strip = everywhere (mkT unlink) where unlink attr@(Xml.Attr { attrKey = key }) - | Xml.qName key == "href" = attr { Xml.attrVal = "" } + | Xml.qName key == "href" = attr { Xml.attrVal = "#" } | otherwise = attr -- cgit v1.2.3