aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Hengel <simon.hengel@wiktory.org>2011-04-08 17:09:28 +0000
committerSimon Hengel <simon.hengel@wiktory.org>2011-04-08 17:09:28 +0000
commit6889ef69d6ffad53a292555615df2c2b336f93db (patch)
tree5a5bed955ecc1261aee6f88e8200f05b88627793 /src
parent3a048f0e823f21133ee7d24d066ddf6bd053379d (diff)
Add support for blank lines in the result of examples
Result lines that only contain the string "<BLANKLINE>" are treated as a blank line.
Diffstat (limited to 'src')
-rw-r--r--src/Haddock/Parse.y15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/Haddock/Parse.y b/src/Haddock/Parse.y
index 4a0f8f99..e36e8416 100644
--- a/src/Haddock/Parse.y
+++ b/src/Haddock/Parse.y
@@ -129,14 +129,21 @@ makeExample prompt expression result =
-- whitespace in expressions, so drop them
result'
where
- -- drop trailing whitespace from the prompt, remember the prefix
+ -- 1. drop trailing whitespace from the prompt, remember the prefix
(prefix, _) = span isSpace prompt
- -- drop, if possible, the exact same sequence of whitespace characters
- -- from each result line
- result' = map (tryStripPrefix prefix) result
+
+ -- 2. drop, if possible, the exact same sequence of whitespace
+ -- characters from each result line
+ --
+ -- 3. interpret lines that only contain the string "<BLANKLINE>" as an
+ -- empty line
+ result' = map (substituteBlankLine . tryStripPrefix prefix) result
where
tryStripPrefix xs ys = fromMaybe ys $ stripPrefix xs ys
+ substituteBlankLine "<BLANKLINE>" = ""
+ substituteBlankLine line = line
+
-- | Remove all leading and trailing whitespace
strip :: String -> String
strip = dropWhile isSpace . reverse . dropWhile isSpace . reverse