aboutsummaryrefslogtreecommitdiff
path: root/src/Haddock/Parser/Util.hs
diff options
context:
space:
mode:
authorMateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk>2013-09-16 03:01:29 +0100
committerAustin Seipp <austin@well-typed.com>2014-01-12 14:48:36 -0600
commitdeb106d8250b7582e01f78e88c88ca7465fc0bc1 (patch)
treefef76ea6a8c491359becf8ee5d620b34558ffb85 /src/Haddock/Parser/Util.hs
parenta03c93524ba2ca4143c10770a2fa0dd134b57a83 (diff)
Allow escaping in URLs and pictures.
Some tests were moved under parseString as they weren't about paragraph level markup. Conflicts: src/Haddock/Parser.hs test/Haddock/ParserSpec.hs
Diffstat (limited to 'src/Haddock/Parser/Util.hs')
-rw-r--r--src/Haddock/Parser/Util.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Haddock/Parser/Util.hs b/src/Haddock/Parser/Util.hs
index ea682601..92fa7448 100644
--- a/src/Haddock/Parser/Util.hs
+++ b/src/Haddock/Parser/Util.hs
@@ -7,7 +7,7 @@ import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as BS
takeUntil :: ByteString -> Parser ByteString
-takeUntil end_ = dropEnd <$> requireEnd (scan (False, end) p)
+takeUntil end_ = dropEnd <$> requireEnd (scan (False, end) p) >>= gotSome
where
end = BS.unpack end_
@@ -20,3 +20,7 @@ takeUntil end_ = dropEnd <$> requireEnd (scan (False, end) p)
dropEnd = BS.reverse . BS.drop (length end) . BS.reverse
requireEnd = mfilter (BS.isSuffixOf end_)
+
+ gotSome xs
+ | BS.null xs = fail "didn't get any content"
+ | otherwise = return xs