@@ -21,6 +21,7 @@ import System.Environment
21import System.Exit
21import System.Exit
22import Text.Printf
22import Text.Printf
23import Data.Algorithm.Diff
23import Data.Algorithm.Diff
24+import Data.String.Utils ( replace )
24import Prelude hiding ( readFile )
25import Prelude hiding ( readFile )
25import qualified Data.ByteString.Lazy as B
26import qualified Data.ByteString.Lazy as B
26import Data.ByteString.Lazy.UTF8 (toString, fromString)
27import Data.ByteString.Lazy.UTF8 (toString, fromString)
@@ -166,7 +167,8 @@ runLatexCitationTests o n
167 o' = o ++ ["--" ++ n]
168 o' = o ++ ["--" ++ n]
168 f = n ++ "-citations.latex"
169 f = n ++ "-citations.latex"
169− rt = runTest
170+ normalize = replace "\160" " " . replace "\8211" "-"
171+ rt = runTestWithNormalize normalize
171runWriterTest :: String -> IO Bool
173runWriterTest :: String -> IO Bool
172runWriterTest format = do
174runWriterTest format = do
@@ -178,13 +180,23 @@ runS5WriterTest :: String -> [String] -> String -> IO Bool
178runS5WriterTest modifier opts format = runTest (format ++ " writer (" ++ modifier ++ ")")
180runS5WriterTest modifier opts format = runTest (format ++ " writer (" ++ modifier ++ ")")
179 (["-r", "native", "-w", format] ++ opts) "s5.native" ("s5." ++ modifier <.> "html")
181 (["-r", "native", "-w", format] ++ opts) "s5.native" ("s5." ++ modifier <.> "html")
181−-- | Run a test, return True if test passed.
184+-- | Run a test without normalize function, return True if test passed.
185+runTest :: String -- ^ Title of test
186+ -> [String] -- ^ Options to pass to pandoc
187+ -> String -- ^ Input filepath
188+ -> FilePath -- ^ Norm (for test results) filepath
190+runTest = runTestWithNormalize id
192+-- | Run a test with normalize function, return True if test passed.
193+runTestWithNormalize :: (String -> String) -- ^ Normalize function for output
182−runTest :: String -- ^ Title of test
194+ -> String -- ^ Title of test
183− -> [String] -- ^ Options to pass to pandoc
195+ -> [String] -- ^ Options to pass to pandoc
184− -> String -- ^ Input filepath
196+ -> String -- ^ Input filepath
185− -> FilePath -- ^ Norm (for test results) filepath
197+ -> FilePath -- ^ Norm (for test results) filepath
186− -> IO Bool
198+ -> IO Bool
187−runTest testname opts inp norm = do
199+runTestWithNormalize normalize testname opts inp norm = do
188 putStr $ printf "%-28s ---> " testname
200 putStr $ printf "%-28s ---> " testname
189 (outputPath, hOut) <- openTempFile "" "pandoc-test"
201 (outputPath, hOut) <- openTempFile "" "pandoc-test"
190 let inpPath = inp
202 let inpPath = inp
@@ -197,7 +209,7 @@ runTest testname opts inp norm = do
197 result <- if ec == ExitSuccess
209 result <- if ec == ExitSuccess
199 -- filter \r so the tests will work on Windows machines
211 -- filter \r so the tests will work on Windows machines
200− outputContents <- readFile' outputPath >>= return . filter (/='\r')
212+ outputContents <- readFile' outputPath >>= return . filter (/='\r') . normalize
201 normContents <- readFile' normPath >>= return . filter (/='\r')
213 normContents <- readFile' normPath >>= return . filter (/='\r')
202 if outputContents == normContents
214 if outputContents == normContents
203 then return TestPassed
215 then return TestPassed