git.iko.soy/typeable/pandoc
on master help sign in
Markdown reader: Allow linebreaks in URLs (treat as spaces).

Also, a string of consecutive spaces or tabs is now parsed as a single space. If you have multiple spaces in your URL, use %20%20.

commit17d48cf4afdbac5da3c0a241dd66dfec93a89b8e authorJohn MacFarlane <jgm@berkeley.edu> dateFri 10 Dec 2010, 12:14 (16 years ago) parentee0a095
3 files changed+24−8
src/Text/Pandoc/Readers/Markdown.hs+21−6 tests/markdown-reader-more.native+1−1 tests/markdown-reader-more.txt+2−1
src/Text/Pandoc/Readers/Markdown.hs+21−6
@@ -202,9 +202,17 @@ referenceKey = try $ do
202202 lab <- reference
203203 char ':'
204204 skipSpaces >> optional newline >> skipSpaces >> notFollowedBy (char '[')
205− let sourceURL excludes = many $
206− optional (char '\\') >> (noneOf (' ':excludes) <|> (notFollowedBy' referenceTitle >> char ' '))
207− src <- try (char '<' >> sourceURL ">\t\n" >>~ char '>') <|> sourceURL "\t\n"
205+ let nl = char '\n' >> notFollowedBy blankline >> return ' '
206+ let sourceURL = liftM unwords $ many $ try $ do
207+ notFollowedBy' referenceTitle
208+ skipMany (oneOf " \t")
209+ optional nl
210+ notFollowedBy' reference
211+ skipMany (oneOf " \t")
212+ many1 (noneOf " \t\n")
213+ let betweenAngles = try $ char '<' >>
214+ manyTill (noneOf ">\n" <|> nl) (char '>')
215+ src <- try betweenAngles <|> sourceURL
208216 tit <- option "" referenceTitle
209217 blanklines
210218 endPos <- getPosition
@@ -1116,9 +1124,16 @@ source =
11161124source' :: GenParser Char st (String, [Char])
11171125source' = do
11181126 skipSpaces
1119− let sourceURL excludes = many $
1120− optional (char '\\') >> (noneOf (' ':excludes) <|> (notFollowedBy' linkTitle >> char ' '))
1121− src <- try (char '<' >> sourceURL ">\t\n" >>~ char '>') <|> sourceURL "\t\n"
1127+ let nl = char '\n' >>~ notFollowedBy blankline
1128+ let sourceURL = liftM unwords $ many $ try $ do
1129+ notFollowedBy' linkTitle
1130+ skipMany (oneOf " \t")
1131+ optional nl
1132+ skipMany (oneOf " \t")
1133+ many1 (noneOf " \t\n")
1134+ let betweenAngles = try $ char '<' >>
1135+ manyTill (noneOf ">\n" <|> nl) (char '>')
1136+ src <- try betweenAngles <|> sourceURL
11221137 tit <- option "" linkTitle
11231138 skipSpaces
11241139 eof
tests/markdown-reader-more.native+1−1
@@ -6,7 +6,7 @@ Pandoc (Meta {docTitle = [Str "Title",Space,Str "spanning",Space,Str "multiple",
66, Para [TeX "\\placeformula",Space,TeX "\\startformula\n L_{1} = L_{2}\n \\stopformula"]
77, Para [TeX "\\start[a2]\n\\start[a2]\n\\stop[a2]\n\\stop[a2]"]
88, Header 2 [Str "URLs",Space,Str "with",Space,Str "spaces"]
9−, Para [Link [Str "foo"] ("/bar%20and%20baz",""),Space,Link [Str "foo"] ("/bar%20and%20baz",""),Space,Link [Str "foo"] ("/bar%20%20and%20%20baz",""),Space,Link [Str "foo"] ("bar%20baz","title")]
9+, Para [Link [Str "foo"] ("/bar%20and%20baz",""),Space,Link [Str "foo"] ("/bar%20and%20baz",""),Space,Link [Str "foo"] ("/bar%20and%20baz",""),Space,Link [Str "foo"] ("bar%20baz","title")]
1010, Para [Link [Str "baz"] ("/foo%20foo",""),Space,Link [Str "bam"] ("/foo%20fee",""),Space,Link [Str "bork"] ("/foo/zee%20zob","title")]
1111, Header 2 [Str "Horizontal",Space,Str "rules",Space,Str "with",Space,Str "spaces",Space,Str "at",Space,Str "end"]
1212, HorizontalRule
tests/markdown-reader-more.txt+2−1
@@ -31,7 +31,8 @@
3131## URLs with spaces
3232
3333[foo](/bar and baz)
34−[foo](/bar and baz )
34+[foo](/bar
35+ and baz )
3536[foo]( /bar and baz )
3637[foo](bar baz "title" )
3738