aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Waern <david.waern@gmail.com>2009-11-22 14:48:47 +0000
committerDavid Waern <david.waern@gmail.com>2009-11-22 14:48:47 +0000
commite67ed9a76dcdf9d4d98659559ed108d1c6325d1d (patch)
tree298ef0b678d9bdc11840cfa66c880afa60fb881d
parent805fd6913075dcf13a366fbe94c22cf95578568a (diff)
Make copy.hs strip link contents before copying
No more updating of reference files when URLs in links changes.
-rw-r--r--tests/copy.hs13
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/copy.hs b/tests/copy.hs
index d19dff7b..fa18fe9c 100644
--- a/tests/copy.hs
+++ b/tests/copy.hs
@@ -5,6 +5,8 @@ import System.Exit
import System.Directory
import Data.List
import Control.Monad
+import Text.Regex
+
main = do
args <- getArgs
@@ -13,11 +15,16 @@ main = do
if not $ null args
then
mapM copy [ "output" </> file | file <- contents, ".html" `isSuffixOf` file, takeBaseName file `elem` args ]
- else
+ else
mapM copy [ "output" </> file | file <- contents, ".html" `isSuffixOf` file ]
+
copy file = do
let new = "tests" </> takeFileName file <.> ".ref"
- print file
+ print file
print new
- copyFile file ("tests" </> takeFileName file <.> ".ref")
+ contents <- readFile file
+ writeFile new (stripLinks contents)
+
+
+stripLinks f = subRegex (mkRegexWithOpts "<A HREF=[^>]*>" False False) f "<A HREF=\"\">"