aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/markup.rst11
-rw-r--r--haddock-library/src/Documentation/Haddock/Parser.hs2
-rw-r--r--haddock-library/test/Documentation/Haddock/ParserSpec.hs46
3 files changed, 29 insertions, 30 deletions
diff --git a/doc/markup.rst b/doc/markup.rst
index abfeb52a..73ec22fd 100644
--- a/doc/markup.rst
+++ b/doc/markup.rst
@@ -1126,17 +1126,6 @@ followed by the URL enclosed in regular parentheses, for example: ::
The link text is used as a description for the URL if the output
format supports it.
-
-Hint: There's a `known issue <https://github.com/haskell/haddock/issues/774>`_
-that any inline link at the beginning of a line within a multi-line comment
-isn't rendered correctly: ::
-
- {-| Some multi-line comment that has a
- [link](https://example.com) and a
- [reference link]: https://example.com
- -}
-
-Adding a space or a word in front of such a link can be used as a workaround.
Images
~~~~~~
diff --git a/haddock-library/src/Documentation/Haddock/Parser.hs b/haddock-library/src/Documentation/Haddock/Parser.hs
index fa15c275..c6d7e59b 100644
--- a/haddock-library/src/Documentation/Haddock/Parser.hs
+++ b/haddock-library/src/Documentation/Haddock/Parser.hs
@@ -173,7 +173,7 @@ encodedChar = "&#" *> c <* ";"
-- Once we have checked for any of these and tried to parse the
-- relevant markup, we can assume they are used as regular text.
specialChar :: [Char]
-specialChar = "_/<@\"&'`# "
+specialChar = "_/<@\"&'`#[ "
-- | Plain, regular parser for text. Called as one of the last parsers
-- to ensure that we have already given a chance to more meaningful parsers
diff --git a/haddock-library/test/Documentation/Haddock/ParserSpec.hs b/haddock-library/test/Documentation/Haddock/ParserSpec.hs
index 5fa73ecd..9cf7c537 100644
--- a/haddock-library/test/Documentation/Haddock/ParserSpec.hs
+++ b/haddock-library/test/Documentation/Haddock/ParserSpec.hs
@@ -576,27 +576,37 @@ spec = do
it "turns it into a code block" $ do
"@foo@" `shouldParseTo` DocCodeBlock "foo"
- context "when a paragraph starts with a markdown link" $ do
- it "correctly parses it as a text paragraph (not a definition list)" $ do
- "[label](url)" `shouldParseTo`
- DocParagraph (hyperlink "url" "label")
+ context "when a paragraph contains a markdown link" $ do
+ it "correctly parses the link" $ do
+ "Blah [label](url)" `shouldParseTo`
+ DocParagraph ("Blah " <> hyperlink "url" "label")
- it "can be followed by an other paragraph" $ do
- "[label](url)\n\nfoobar" `shouldParseTo`
- DocParagraph (hyperlink "url" "label") <> DocParagraph "foobar"
-
- context "when paragraph contains additional text" $ do
- it "accepts more text after the link" $ do
- "[label](url) foo bar baz" `shouldParseTo`
- DocParagraph (hyperlink "url" "label" <> " foo bar baz")
-
- it "accepts a newline right after the markdown link" $ do
- "[label](url)\nfoo bar baz" `shouldParseTo`
- DocParagraph (hyperlink "url" "label" <> " foo bar baz")
+ context "when the paragraph starts with the markdown link" $ do
+ it "correctly parses it as a text paragraph (not a definition list)" $ do
+ "[label](url)" `shouldParseTo`
+ DocParagraph (hyperlink "url" "label")
it "can be followed by an other paragraph" $ do
- "[label](url)foo\n\nbar" `shouldParseTo`
- DocParagraph (hyperlink "url" "label" <> "foo") <> DocParagraph "bar"
+ "[label](url)\n\nfoobar" `shouldParseTo`
+ DocParagraph (hyperlink "url" "label") <> DocParagraph "foobar"
+
+ context "when paragraph contains additional text" $ do
+ it "accepts more text after the link" $ do
+ "[label](url) foo bar baz" `shouldParseTo`
+ DocParagraph (hyperlink "url" "label" <> " foo bar baz")
+
+ it "accepts a newline right after the markdown link" $ do
+ "[label](url)\nfoo bar baz" `shouldParseTo`
+ DocParagraph (hyperlink "url" "label" <> " foo bar baz")
+
+ it "can be followed by an other paragraph" $ do
+ "[label](url)foo\n\nbar" `shouldParseTo`
+ DocParagraph (hyperlink "url" "label" <> "foo") <> DocParagraph "bar"
+
+ context "when the link starts on a new line not at the beginning of the paragraph" $ do
+ it "correctly parses the link" $ do
+ "Bla\n[label](url)" `shouldParseTo`
+ DocParagraph ("Bla\n" <> hyperlink "url" "label")
context "when parsing birdtracks" $ do
it "parses them as a code block" $ do