From af3b1444239027170f5e99a6dd67c1e2c6c44432 Mon Sep 17 00:00:00 2001 From: Mateusz Kowalczyk Date: Fri, 11 Apr 2014 16:58:34 +0100 Subject: Parse identifiers with ^ and ⋆ in them. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #298. --- src/Haddock/Parser.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/Haddock') diff --git a/src/Haddock/Parser.hs b/src/Haddock/Parser.hs index bd5cd200..ece9291f 100644 --- a/src/Haddock/Parser.hs +++ b/src/Haddock/Parser.hs @@ -419,13 +419,21 @@ autoUrl = mkLink <$> url -- characters and does no actual validation itself. parseValid :: Parser String parseValid = do - vs <- many' $ satisfy (`elem` "_.!#$%&*+/<=>?@\\|-~:") <|> digit <|> letter_ascii + vs' <- many' $ utf8String "⋆" <|> return <$> idChar + let vs = concat vs' c <- peekChar case c of Just '`' -> return vs Just '\'' -> (\x -> vs ++ "'" ++ x) <$> ("'" *> parseValid) <|> return vs _ -> fail "outofvalid" + where + idChar = satisfy (`elem` "_.!#$%&*+/<=>?@\\|-~:^") + <|> digit <|> letter_ascii + +-- | Parses UTF8 strings from ByteString streams. +utf8String :: String -> Parser String +utf8String x = decodeUtf8 <$> string (encodeUtf8 x) -- | Parses identifiers with help of 'parseValid'. Asks GHC for 'RdrName' from the -- string it deems valid. -- cgit v1.2.3