@@ -32,7 +32,6 @@ module Text.Pandoc.Readers.Markdown (
3232 readMarkdown
3333 ) where
3434
35−import Control.Applicative ( (<$>) )
3635import Data.List ( transpose, isPrefixOf, isSuffixOf, lookup, sortBy, findIndex, intercalate )
3736import Data.Ord ( comparing )
3837import Data.Char ( isAlphaNum, isAlpha, isLower, isDigit, isUpper )
@@ -189,15 +188,13 @@ referenceKey = try $ do
189188 lab <- reference
190189 char ':'
191190 skipSpaces >> optional newline >> skipSpaces >> notFollowedBy (char '[')
192− let sourceURL excludes = concat <$>
193− (many $ do optional (char '\\')
194− count 1 (noneOf $ ' ':excludes)
195− <|> (notFollowedBy' referenceTitle >> char ' ' >> return "%20"))
191+ let sourceURL excludes = many $
192+ optional (char '\\') >> (noneOf (' ':excludes) <|> (notFollowedBy' referenceTitle >> char ' '))
196193 src <- try (char '<' >> sourceURL ">\t\n" >>~ char '>') <|> sourceURL "\t\n"
197194 tit <- option "" referenceTitle
198195 blanklines
199196 endPos <- getPosition
200− let newkey = (lab, (removeTrailingSpace src, tit))
197+ let newkey = (lab, (intercalate "%20" $ words $ removeTrailingSpace src, tit))
201198 st <- getState
202199 let oldkeys = stateKeys st
203200 updateState $ \s -> s { stateKeys = newkey : oldkeys }
@@ -1066,15 +1063,13 @@ source =
10661063source' :: GenParser Char st (String, [Char])
10671064source' = do
10681065 skipSpaces
1069− let sourceURL excludes = concat <$>
1070− (many $ do optional (char '\\')
1071− count 1 (noneOf $ ' ':excludes)
1072− <|> (notFollowedBy' linkTitle >> char ' ' >> return "%20"))
1066+ let sourceURL excludes = many $
1067+ optional (char '\\') >> (noneOf (' ':excludes) <|> (notFollowedBy' linkTitle >> char ' '))
10731068 src <- try (char '<' >> sourceURL ">\t\n" >>~ char '>') <|> sourceURL "\t\n"
10741069 tit <- option "" linkTitle
10751070 skipSpaces
10761071 eof
1077− return (removeTrailingSpace src, tit)
1072+ return (intercalate "%20" $ words $ removeTrailingSpace src, tit)
10781073
10791074linkTitle :: GenParser Char st String
10801075linkTitle = try $ do