diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2008-10-31 22:34:38 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2008-10-31 22:34:38 +0000 |
commit | ddf2dc68965a281b03949d56576e1585325eed24 (patch) | |
tree | 8435a93a36daa841a7346ad666ddb0798c4f9b62 | |
parent | 1aeef232c812b7c57b4dba95f34dce6eaad1ced4 (diff) | |
download | pandoc-ddf2dc68965a281b03949d56576e1585325eed24.tar.gz |
Markdown reader: allow URLs containing spaces.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@1475 788f1e2b-df1e-0410-8736-df70ead52e1b
-rw-r--r-- | Text/Pandoc/Readers/Markdown.hs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/Text/Pandoc/Readers/Markdown.hs b/Text/Pandoc/Readers/Markdown.hs index 0326bac95..08e78d525 100644 --- a/Text/Pandoc/Readers/Markdown.hs +++ b/Text/Pandoc/Readers/Markdown.hs @@ -32,6 +32,7 @@ module Text.Pandoc.Readers.Markdown ( readMarkdown ) where +import Control.Applicative ( (<$>) ) import Data.List ( transpose, isPrefixOf, isSuffixOf, lookup, sortBy, findIndex, intercalate ) import Data.Ord ( comparing ) import Data.Char ( isAlphaNum, isAlpha, isLower, isDigit, isUpper ) @@ -188,8 +189,11 @@ referenceKey = try $ do lab <- reference char ':' skipSpaces >> optional newline >> skipSpaces >> notFollowedBy (char '[') - src <- (char '<' >> many (noneOf "> \n\t") >>~ char '>') - <|> many (noneOf " \n\t") + let sourceURL excludes = concat <$> + (many $ do optional (char '\\') + count 1 (noneOf $ ' ':excludes) + <|> (notFollowedBy' referenceTitle >> char ' ' >> return "%20")) + src <- try (char '<' >> sourceURL ">\t\n" >>~ char '>') <|> sourceURL "\t\n" tit <- option "" referenceTitle blanklines endPos <- getPosition @@ -1062,10 +1066,11 @@ source = source' :: GenParser Char st (String, [Char]) source' = do skipSpaces - src <- try (char '<' >> - many (optional (char '\\') >> noneOf "> \t\n") >>~ - char '>') - <|> many (optional (char '\\') >> noneOf " \t\n") + let sourceURL excludes = concat <$> + (many $ do optional (char '\\') + count 1 (noneOf $ ' ':excludes) + <|> (notFollowedBy' linkTitle >> char ' ' >> return "%20")) + src <- try (char '<' >> sourceURL ">\t\n" >>~ char '>') <|> sourceURL "\t\n" tit <- option "" linkTitle skipSpaces eof |