aboutsummaryrefslogtreecommitdiff
path: root/haddock-library/src/Documentation
diff options
context:
space:
mode:
authorXia Li-yao <Lysxia@users.noreply.github.com>2020-12-08 10:42:17 -0500
committerGitHub <noreply@github.com>2020-12-08 16:42:17 +0100
commit1bedd20b94359728c25f64f7643a0ca0fb0f9fa2 (patch)
treee20d28802925407da6984d17ad615297722a0a4a /haddock-library/src/Documentation
parent1e0ad7350290fad4f8c7728c8b879113b669397a (diff)
Allow more characters in anchor following module reference (#1220)
Diffstat (limited to 'haddock-library/src/Documentation')
-rw-r--r--haddock-library/src/Documentation/Haddock/Parser.hs10
1 files changed, 8 insertions, 2 deletions
diff --git a/haddock-library/src/Documentation/Haddock/Parser.hs b/haddock-library/src/Documentation/Haddock/Parser.hs
index 149ff93d..bd01f354 100644
--- a/haddock-library/src/Documentation/Haddock/Parser.hs
+++ b/haddock-library/src/Documentation/Haddock/Parser.hs
@@ -242,12 +242,18 @@ monospace = DocMonospaced . parseParagraph
-- Note that we allow '#' and '\' to support anchors (old style anchors are of
-- the form "SomeModule\#anchor").
moduleName :: Parser (DocH mod a)
-moduleName = DocModule <$> ("\"" *> modid <* "\"")
+moduleName = DocModule <$> ("\"" *> (modid `maybeFollowedBy` anchor_) <* "\"")
where
modid = intercalate "." <$> conid `Parsec.sepBy1` "."
+ anchor_ = (++)
+ <$> (Parsec.string "#" <|> Parsec.string "\\#")
+ <*> many (Parsec.satisfy (\c -> c /= '"' && not (isSpace c)))
+
+ maybeFollowedBy pre suf = (\x -> maybe x (x ++)) <$> pre <*> optional suf
+
conid = (:)
<$> Parsec.satisfy (\c -> isAlpha c && isUpper c)
- <*> many (conChar <|> Parsec.oneOf "\\#")
+ <*> many conChar
conChar = Parsec.alphaNum <|> Parsec.char '_'