diff options
author | Xia Li-yao <Lysxia@users.noreply.github.com> | 2020-12-08 10:42:17 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-08 16:42:17 +0100 |
commit | 1bedd20b94359728c25f64f7643a0ca0fb0f9fa2 (patch) | |
tree | e20d28802925407da6984d17ad615297722a0a4a /haddock-library/src | |
parent | 1e0ad7350290fad4f8c7728c8b879113b669397a (diff) |
Allow more characters in anchor following module reference (#1220)
Diffstat (limited to 'haddock-library/src')
-rw-r--r-- | haddock-library/src/Documentation/Haddock/Parser.hs | 10 |
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 '_' |