aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorŁukasz Hanuszczak <lukasz.hanuszczak@gmail.com>2015-06-17 23:43:31 +0200
committerŁukasz Hanuszczak <lukasz.hanuszczak@gmail.com>2015-06-30 22:37:49 +0200
commitebd60c5cd0c3642c2d5542c0e126be0a4ec111d9 (patch)
tree79449e3b58f21462e2ddb79f52046355932b51cb
parenta85224a68b51b70035446ad8e5565d571c4a10d4 (diff)
Fix parsing of single line comments with broken up newlines.
-rw-r--r--haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs12
1 files changed, 11 insertions, 1 deletions
diff --git a/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs b/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
index 70a69279..3ecfc7e7 100644
--- a/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
+++ b/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
@@ -47,13 +47,23 @@ chunk [] = []
chunk str@(c:_)
| isSpace c = chunk' $ span isSpace str
chunk str
- | "--" `isPrefixOf` str = chunk' $ span (not . (== '\n')) str
+ | "--" `isPrefixOf` str = chunk' $ spanToNewline str
| "{-" `isPrefixOf` str = chunk' $ chunkComment 0 str
| otherwise = chunk' $ head $ lex str
chunk' :: (String, String) -> [String]
chunk' (c, rest) = c:(chunk rest)
+spanToNewline :: String -> (String, String)
+spanToNewline [] = ([], [])
+spanToNewline ('\\':'\n':str) =
+ let (str', rest) = spanToNewline str
+ in ('\\':'\n':str', rest)
+spanToNewline ('\n':str) = ("\n", str)
+spanToNewline (c:str) =
+ let (str', rest) = spanToNewline str
+ in (c:str', rest)
+
chunkComment :: Int -> String -> (String, String)
chunkComment _ [] = ("", "")
chunkComment depth ('{':'-':str) =