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

fix parsing trailing quotes in backticked identifiers (#1408) #1483

Merged
merged 1 commit into from
May 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ takeIdentifier input = listToMaybe $ do
| otherwise = Nothing

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

-- | Parse an operator off the front of the input
Expand Down
3 changes: 3 additions & 0 deletions haddock-library/test/Documentation/Haddock/ParserSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ spec = do
it "can parse identifiers ending with a single quote" $ do
"'foo''" `shouldParseTo` DocIdentifier "foo'"

it "can parse identifiers in backticks ending with a single quote" $ do
"`foo'`" `shouldParseTo` DocIdentifier "foo'"

it "can parse an identifier containing a digit" $ do
"'f0'" `shouldParseTo` DocIdentifier "f0"

Expand Down