diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Haddock/Parser.hs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Haddock/Parser.hs b/src/Haddock/Parser.hs index e9bed2a5..a6ad817c 100644 --- a/src/Haddock/Parser.hs +++ b/src/Haddock/Parser.hs @@ -302,10 +302,19 @@ takeNonEmptyLine = do (++ "\n") . decodeUtf8 <$> (takeWhile1 (/= '\n') >>= nonSpace) <* "\n" birdtracks :: Parser (Doc a) -birdtracks = DocCodeBlock . DocString . intercalate "\n" <$> many1 line +birdtracks = DocCodeBlock . DocString . intercalate "\n" . stripSpace <$> many1 line where line = skipHorizontalSpace *> ">" *> takeLine +-- | Strip leading spaces, but ignore blank lines. If any of the lines don't +-- start with a ' ', however, we don't touch the block. +stripSpace :: [String] -> [String] +stripSpace = fromMaybe <*> mapM strip + where + strip (' ':xs) = Just xs + strip "" = Just "" + strip _ = Nothing + -- | Parses examples. Examples are a paragraph level entitity (separated by an empty line). -- Consecutive examples are accepted. examples :: Parser (Doc a) |