aboutsummaryrefslogtreecommitdiff
path: root/haddock-library/test/Documentation/Haddock
diff options
context:
space:
mode:
authorSimon Hengel <sol@typeful.net>2014-11-02 12:07:24 +0800
committerSimon Hengel <sol@typeful.net>2014-11-03 09:34:19 +0800
commit58a5683d1ce759f80ca7eb3b35663b717ae2abd5 (patch)
treeb78a8dfa6df0d1bce5ea7d3a30edf28ba37ba6b6 /haddock-library/test/Documentation/Haddock
parent77ed6a63df3d2653401f1869f116c8854021a71e (diff)
Allow markdown links at the beginning of a paragraph
Diffstat (limited to 'haddock-library/test/Documentation/Haddock')
-rw-r--r--haddock-library/test/Documentation/Haddock/ParserSpec.hs28
1 files changed, 25 insertions, 3 deletions
diff --git a/haddock-library/test/Documentation/Haddock/ParserSpec.hs b/haddock-library/test/Documentation/Haddock/ParserSpec.hs
index cb417cf6..6d152ee2 100644
--- a/haddock-library/test/Documentation/Haddock/ParserSpec.hs
+++ b/haddock-library/test/Documentation/Haddock/ParserSpec.hs
@@ -28,6 +28,9 @@ parseParas = Parse.toRegular . Parse.parseParas
parseString :: String -> Doc String
parseString = Parse.toRegular . Parse.parseString
+hyperlink :: String -> Maybe String -> Doc String
+hyperlink url = DocHyperlink . Hyperlink url
+
main :: IO ()
main = hspec spec
@@ -83,9 +86,6 @@ spec = do
"don't use apostrophe's in the wrong place's"
context "when parsing URLs" $ do
- let hyperlink :: String -> Maybe String -> Doc String
- hyperlink url = DocHyperlink . Hyperlink url
-
it "parses a URL" $ do
"<http://example.com/>" `shouldParseTo` hyperlink "http://example.com/" Nothing
@@ -387,6 +387,28 @@ 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")
+
+ 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")
+
+ it "can be followed by an other paragraph" $ do
+ "[label](url)foo\n\nbar" `shouldParseTo`
+ DocParagraph (hyperlink "url" "label" <> "foo") <> DocParagraph "bar"
+
context "when parsing birdtracks" $ do
it "parses them as a code block" $ do
unlines [