Skip to content
This repository was archived by the owner on Aug 3, 2024. It is now read-only.

Commit 32ada2f

Browse files
committed
fix parsing trailing quotes in backticked identifiers (#1408)
1 parent ab53ccf commit 32ada2f

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

haddock-library/src/Documentation/Haddock/Parser/Identifier.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ takeIdentifier input = listToMaybe $ do
149149
| otherwise = Nothing
150150

151151
-- | Parse all but the last quote off the front of the input
152-
-- PRECONDITION: T.head t == '\''
152+
-- PRECONDITION: T.head t `elem` ['\'', '`']
153153
quotes :: Text -> (Int, Text)
154-
quotes t = let !n = T.length (T.takeWhile (== '\'') t) - 1
154+
quotes t = let !n = T.length (T.takeWhile (`elem` ['\'', '`']) t) - 1
155155
in (n, T.drop n t)
156156

157157
-- | Parse an operator off the front of the input

haddock-library/test/Documentation/Haddock/ParserSpec.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ spec = do
121121
it "can parse identifiers ending with a single quote" $ do
122122
"'foo''" `shouldParseTo` DocIdentifier "foo'"
123123

124+
it "can parse identifiers in backticks ending with a single quote" $ do
125+
"`foo'`" `shouldParseTo` DocIdentifier "foo'"
126+
124127
it "can parse an identifier containing a digit" $ do
125128
"'f0'" `shouldParseTo` DocIdentifier "f0"
126129

0 commit comments

Comments
 (0)