aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2010-02-27 04:59:34 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2010-02-27 04:59:34 +0000
commitddcde4d543f865fa95d2a6bb4ca2dfdfc4435c13 (patch)
treeec025662bce03a43c07b7065594ef12049d40aeb /src/Text/Pandoc/Readers
parentf2552cf382a12c9465eac9b5ce1a28b519c61a1a (diff)
downloadpandoc-ddcde4d543f865fa95d2a6bb4ca2dfdfc4435c13.tar.gz
Markdown reader: Use simpler approach for URLs - just escape spaces.
Markdown.pl doesn't URI-escape anything, so we won't do that either, except for spaces, which can cause problems if not escaped. Resolves Issue #220 and partially reverts r1847. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1851 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 7131af2b7..e0cc39ecc 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -45,7 +45,6 @@ import Text.Pandoc.Readers.HTML ( rawHtmlBlock, anyHtmlBlockTag,
import Text.Pandoc.CharacterReferences ( decodeCharacterReferences )
import Text.ParserCombinators.Parsec
import Control.Monad (when, liftM, unless)
-import Network.URI ( unEscapeString, escapeURIString, isUnescapedInURI )
-- | Read markdown from an input string and return a Pandoc document.
readMarkdown :: ParserState -- ^ Parser state, including options for parser
@@ -74,12 +73,9 @@ specialChars = "\\[]*_~`<>$!^-.&'\"\8216\8217\8220\8221;"
-- auxiliary functions
--
--- | Escape a URI in a markdown-appropriate way. First,
--- we unescape the string, since we don't want to screw things
--- up if they've entered a properly encoded URI. Then, we
--- escape the result.
-escapeURI :: String -> String
-escapeURI = escapeURIString isUnescapedInURI . unEscapeString
+-- | Replace spaces with %20
+uriEscapeSpaces :: String -> String
+uriEscapeSpaces = substitute " " "%20"
indentSpaces :: GenParser Char ParserState [Char]
indentSpaces = try $ do
@@ -202,7 +198,7 @@ referenceKey = try $ do
tit <- option "" referenceTitle
blanklines
endPos <- getPosition
- let newkey = (lab, (escapeURI $ removeTrailingSpace src, tit))
+ let newkey = (lab, (uriEscapeSpaces $ removeTrailingSpace src, tit))
st <- getState
let oldkeys = stateKeys st
updateState $ \s -> s { stateKeys = newkey : oldkeys }
@@ -1181,7 +1177,7 @@ source' = do
tit <- option "" linkTitle
skipSpaces
eof
- return (escapeURI $ removeTrailingSpace src, tit)
+ return (uriEscapeSpaces $ removeTrailingSpace src, tit)
linkTitle :: GenParser Char st String
linkTitle = try $ do