aboutsummaryrefslogtreecommitdiff
path: root/haddock-api/src/Haddock
diff options
context:
space:
mode:
authorAlec Theriault <alec.theriault@gmail.com>2018-05-07 18:53:15 -0700
committerAlexander Biehl <alexbiehl@gmail.com>2018-05-07 18:53:15 -0700
commit143094b0badbeb217e33e7da4ad4ba669c4e7bd5 (patch)
treeb3da08447da0a1aef24789b4b2bab4b7172711f2 /haddock-api/src/Haddock
parent79c7159101c03bbbc7350e07963896ca2bb97c02 (diff)
Filter out CRLFs in hyperlinker backend (#813)
This prevents spurious lines from appearing in the final output.
Diffstat (limited to 'haddock-api/src/Haddock')
-rw-r--r--haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs9
1 files changed, 7 insertions, 2 deletions
diff --git a/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs b/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
index 34512de8..277634b9 100644
--- a/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
+++ b/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
@@ -24,8 +24,13 @@ import Haddock.Backends.Hyperlinker.Types as T
-- (In reality, this only holds for input not containing '\r', '\t', '\f', '\v',
-- characters, since GHC transforms those into ' ' and '\n')
parse :: DynFlags -> FilePath -> String -> [T.Token]
-parse dflags fp s = ghcToks (processCPP dflags fp s)
-
+parse dflags fp = ghcToks . processCPP dflags fp . filterCRLF
+ where
+ -- Remove CRLFs from source
+ filterCRLF :: String -> String
+ filterCRLF ('\r':'\n':cs) = '\n' : filterCRLF cs
+ filterCRLF (c:cs) = c : filterCRLF cs
+ filterCRLF [] = []
-- | Parse the source into tokens using the GHC lexer.
--