[commit: haddock] ghc-7.8: Fix @ code blocks (485b632)
git at git.haskell.org
git at git.haskell.org
Thu Jan 30 18:52:39 UTC 2014
Repository : ssh://git@git.haskell.org/haddock
On branch : ghc-7.8
Link : http://git.haskell.org/haddock.git/commitdiff/485b6324a2d49493e73218f8161a1a1614c8ed21
>---------------------------------------------------------------
commit 485b6324a2d49493e73218f8161a1a1614c8ed21
Author: Mateusz Kowalczyk <fuuzetsu at fuuzetsu.co.uk>
Date: Wed Jan 29 20:37:10 2014 +0000
Fix @ code blocks
In cases where we had some horizontal space before the closing ‘@’, the
parser would not accept the block as a code block and we'd get ugly
output.
(cherry picked from commit 7d2106e18f26a680d157ef943da2602e7199afa1)
Signed-off-by: Herbert Valerio Riedel <hvr at gnu.org>
>---------------------------------------------------------------
485b6324a2d49493e73218f8161a1a1614c8ed21
src/Haddock/Parser.hs | 1 +
test/Haddock/ParserSpec.hs | 8 ++++++++
2 files changed, 9 insertions(+)
diff --git a/src/Haddock/Parser.hs b/src/Haddock/Parser.hs
index 6370eec..e9bed2a 100644
--- a/src/Haddock/Parser.hs
+++ b/src/Haddock/Parser.hs
@@ -365,6 +365,7 @@ codeblock d =
where
p isNewline c
| isNewline && c == '@' = Nothing
+ | isNewline && isSpace c = Just isNewline
| otherwise = Just $ c == '\n'
hyperlink :: Parser (Doc a)
diff --git a/test/Haddock/ParserSpec.hs b/test/Haddock/ParserSpec.hs
index 9bca745..455a67f 100644
--- a/test/Haddock/ParserSpec.hs
+++ b/test/Haddock/ParserSpec.hs
@@ -410,6 +410,14 @@ spec = before initStaticOpts $ do
, "@"
] `shouldParseTo` DocCodeBlock "foo\n@\nbar\n"
+ it "accepts horizontal space before the @" $ do
+ unlines [ " @"
+ , " foo"
+ , ""
+ , " bar"
+ , " @"
+ ] `shouldParseTo` DocCodeBlock " foo\n\n bar\n "
+
it "accepts unicode" $ do
"@foo 灼眼のシャナ bar@" `shouldParseTo` DocCodeBlock "foo 灼眼のシャナ bar"
More information about the ghc-commits
mailing list