aboutsummaryrefslogtreecommitdiff
path: root/haddock-library/src/Documentation/Haddock
diff options
context:
space:
mode:
authorŁukasz Hanuszczak <lukasz.hanuszczak@gmail.com>2015-05-27 11:51:31 +0200
committerŁukasz Hanuszczak <lukasz.hanuszczak@gmail.com>2015-05-27 11:51:31 +0200
commit39a7a1b9e344bfa3258a6414e75f19c1eabc30de (patch)
tree5fe826363dbbd0a1ff8960d14aa500957b2ae9f2 /haddock-library/src/Documentation/Haddock
parent3fee88b2891683eeb56db3d7b79e890070530c8f (diff)
Create simple method for indentation parsing.
Diffstat (limited to 'haddock-library/src/Documentation/Haddock')
-rw-r--r--haddock-library/src/Documentation/Haddock/Parser.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/haddock-library/src/Documentation/Haddock/Parser.hs b/haddock-library/src/Documentation/Haddock/Parser.hs
index 5c607a1a..6bb88035 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