diff options
author | Alec Theriault <alec.theriault@gmail.com> | 2018-05-07 18:53:15 -0700 |
---|---|---|
committer | Simon Jakobi <simon.jakobi@gmail.com> | 2018-06-13 23:39:30 +0200 |
commit | 52405584f978c8d1afd6439b3ac0e3fd0f9b825e (patch) | |
tree | 98fe59480fe1cbe410423af6416ed31a37298844 | |
parent | 524566646723ced878d49c903358e7b5f25442b9 (diff) |
Filter out CRLFs in hyperlinker backend (#813)
This prevents spurious lines from appearing in the final output.
-rw-r--r-- | haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs | 9 |
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 8f77b8f5..92443bff 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. -- |