[commit: haddock] master: Create simple method for indentation parsing. (39a7a1b)
git at git.haskell.org
git at git.haskell.org
Wed Jul 8 08:38:45 UTC 2015
Repository : ssh://git@git.haskell.org/haddock
On branch : master
Link : http://git.haskell.org/haddock.git/commitdiff/39a7a1b9e344bfa3258a6414e75f19c1eabc30de
>---------------------------------------------------------------
commit 39a7a1b9e344bfa3258a6414e75f19c1eabc30de
Author: Łukasz Hanuszczak <lukasz.hanuszczak at gmail.com>
Date: Wed May 27 11:51:31 2015 +0200
Create simple method for indentation parsing.
>---------------------------------------------------------------
39a7a1b9e344bfa3258a6414e75f19c1eabc30de
haddock-library/src/Documentation/Haddock/Parser.hs | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/haddock-library/src/Documentation/Haddock/Parser.hs b/haddock-library/src/Documentation/Haddock/Parser.hs
index 5c607a1..6bb8803 100644
--- a/haddock-library/src/Documentation/Haddock/Parser.hs
+++ b/haddock-library/src/Documentation/Haddock/Parser.hs
@@ -382,6 +382,15 @@ takeNonEmptyLine :: Parser String
takeNonEmptyLine = do
(++ "\n") . decodeUtf8 <$> (takeWhile1 (/= '\n') >>= nonSpace) <* "\n"
+-- | Takes indentation of first non-empty line.
+--
+-- More precisely: skips all whitespace-only lines and returns indentation
+-- (horizontal space, might be empty) of that non-empty line.
+takeIndent :: Parser BS.ByteString
+takeIndent = do
+ indent <- takeHorizontalSpace
+ "\n" *> takeIndent <|> return indent
+
-- | Blocks of text of the form:
--
-- >> foo
More information about the ghc-commits
mailing list