This repository was archived by the owner on Aug 3, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
src/Documentation/Haddock
test/Documentation/Haddock Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -242,12 +242,18 @@ monospace = DocMonospaced . parseParagraph
242
242
-- Note that we allow '#' and '\' to support anchors (old style anchors are of
243
243
-- the form "SomeModule\#anchor").
244
244
moduleName :: Parser (DocH mod a )
245
- moduleName = DocModule <$> (" \" " *> modid <* " \" " )
245
+ moduleName = DocModule <$> (" \" " *> ( modid `maybeFollowedBy` anchor_) <* " \" " )
246
246
where
247
247
modid = intercalate " ." <$> conid `Parsec.sepBy1` " ."
248
+ anchor_ = (++)
249
+ <$> (Parsec. string " #" <|> Parsec. string " \\ #" )
250
+ <*> many (Parsec. satisfy (\ c -> c /= ' "' && not (isSpace c)))
251
+
252
+ maybeFollowedBy pre suf = (\ x -> maybe x (x ++ )) <$> pre <*> optional suf
253
+
248
254
conid = (:)
249
255
<$> Parsec. satisfy (\ c -> isAlpha c && isUpper c)
250
- <*> many ( conChar <|> Parsec. oneOf " \\ # " )
256
+ <*> many conChar
251
257
252
258
conChar = Parsec. alphaNum <|> Parsec. char ' _'
253
259
Original file line number Diff line number Diff line change @@ -431,6 +431,9 @@ spec = do
431
431
it " accepts anchor reference syntax as DocModule" $ do
432
432
" \" Foo#bar\" " `shouldParseTo` DocModule " Foo#bar"
433
433
434
+ it " accepts anchor with hyphen as DocModule" $ do
435
+ " \" Foo#bar-baz\" " `shouldParseTo` DocModule " Foo\\ #bar-baz"
436
+
434
437
it " accepts old anchor reference syntax as DocModule" $ do
435
438
" \" Foo\\ #bar\" " `shouldParseTo` DocModule " Foo\\ #bar"
436
439
You can’t perform that action at this time.
0 commit comments