diff options
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 |
commit | 39a7a1b9e344bfa3258a6414e75f19c1eabc30de (patch) | |
tree | 5fe826363dbbd0a1ff8960d14aa500957b2ae9f2 /haddock-library/src | |
parent | 3fee88b2891683eeb56db3d7b79e890070530c8f (diff) |
Create simple method for indentation parsing.
Diffstat (limited to 'haddock-library/src')
-rw-r--r-- | haddock-library/src/Documentation/Haddock/Parser.hs | 9 |
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 |