aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs3
-rw-r--r--src/Text/Pandoc/Writers/Markdown.hs10
-rw-r--r--tests/testsuite.native6
-rw-r--r--tests/writer.markdown6
-rw-r--r--tests/writer.native6
5 files changed, 13 insertions, 18 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 9b3f047e9..0f1ef348d 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -894,8 +894,7 @@ titleWith startChar endChar = try (do
char endChar
skipSpaces
notFollowedBy (noneOf ")\n")))
- let tit' = substitute "\"" """ tit
- return tit')
+ return tit)
title = choice [ titleWith '(' ')',
titleWith '"' '"',
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs
index 46c47bf74..4d3f844b5 100644
--- a/src/Text/Pandoc/Writers/Markdown.hs
+++ b/src/Text/Pandoc/Writers/Markdown.hs
@@ -52,10 +52,6 @@ writeMarkdown options (Pandoc meta blocks) =
escapeString :: String -> String
escapeString = backslashEscape "`<\\*_^"
--- | Escape embedded \" in link title.
-escapeLinkTitle :: String -> String
-escapeLinkTitle = substitute "\"" "\\\""
-
-- | Take list of inline elements and return wrapped doc.
wrappedMarkdown :: [Inline] -> Doc
wrappedMarkdown lst =
@@ -119,7 +115,7 @@ blockToMarkdown tabStop (Note ref lst) =
blockToMarkdown tabStop (Key txt (Src src tit)) =
text " " <> char '[' <> inlineListToMarkdown txt <> char ']' <>
text ": " <> text src <>
- if tit /= "" then text (" \"" ++ (escapeLinkTitle tit) ++ "\"") else empty
+ if tit /= "" then text (" \"" ++ tit ++ "\"") else empty
blockToMarkdown tabStop (CodeBlock str) =
(nest tabStop $ vcat $ map text (lines str)) <> text "\n"
blockToMarkdown tabStop (RawHtml str) = text str
@@ -185,7 +181,7 @@ inlineToMarkdown (Link txt (Src src tit)) =
else inlineListToMarkdown txt
linktitle = if null tit
then empty
- else text (" \"" ++ (escapeLinkTitle tit) ++ "\"")
+ else text (" \"" ++ tit ++ "\"")
srcSuffix = if isPrefixOf "mailto:" src then drop 7 src else src in
if (null tit) && (txt == [Str srcSuffix])
then char '<' <> text srcSuffix <> char '>'
@@ -203,7 +199,7 @@ inlineToMarkdown (Image alternate (Src source tit)) =
else inlineListToMarkdown alternate in
char '!' <> char '[' <> alt <> char ']' <> char '(' <> text source <>
(if tit /= ""
- then text (" \"" ++ (escapeLinkTitle tit) ++ "\"")
+ then text (" \"" ++ tit ++ "\"")
else empty) <> char ')'
inlineToMarkdown (Image alternate (Ref ref)) =
char '!' <> inlineToMarkdown (Link alternate (Ref ref))
diff --git a/tests/testsuite.native b/tests/testsuite.native
index 683b2c550..bc4970e12 100644
--- a/tests/testsuite.native
+++ b/tests/testsuite.native
@@ -268,7 +268,7 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] (Src "/url/" "title"),Str "."]
, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] (Src "/url/" "title preceded by two spaces"),Str "."]
, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] (Src "/url/" "title preceded by a tab"),Str "."]
-, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] (Src "/url/" "title with &quot;quotes&quot; in it")]
+, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] (Src "/url/" "title with \"quotes\" in it")]
, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] (Src "/url/" "title with single quotes")]
, Para [Link [Str "with",Str "_",Str "underscore"] (Src "/url/with_underscore" "")]
, Para [Link [Str "Email",Space,Str "link"] (Src "mailto:nobody@nowhere.net" "")]
@@ -290,8 +290,8 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
, CodeBlock "[not]: /url"
, Key [Str "b"] (Src "/url/" "")
, Para [Str "Foo",Space,Link [Str "bar"] (Ref [Str "bar"]),Str "."]
-, Para [Str "Foo",Space,Link [Str "biz"] (Src "/url/" "Title with &quot;quote&quot; inside"),Str "."]
-, Key [Str "bar"] (Src "/url/" "Title with &quot;quotes&quot; inside")
+, Para [Str "Foo",Space,Link [Str "biz"] (Src "/url/" "Title with \"quote\" inside"),Str "."]
+, Key [Str "bar"] (Src "/url/" "Title with \"quotes\" inside")
, Header 2 [Str "With",Space,Str "ampersands"]
, Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Link [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] (Ref [Str "1"]),Str "."]
, Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "amersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text:",Space,Link [Str "AT",Str "&",Str "T"] (Ref [Str "2"]),Str "."]
diff --git a/tests/writer.markdown b/tests/writer.markdown
index dbbed7adb..bae2008dd 100644
--- a/tests/writer.markdown
+++ b/tests/writer.markdown
@@ -510,7 +510,7 @@ Just a [URL](/url/).
[URL and title](/url/ "title preceded by a tab").
-[URL and title](/url/ "title with &quot;quotes&quot; in it")
+[URL and title](/url/ "title with "quotes" in it")
[URL and title](/url/ "title with single quotes")
@@ -554,10 +554,10 @@ This should [not][] be a link.
Foo [bar][].
-Foo [biz](/url/ "Title with &quot;quote&quot; inside").
+Foo [biz](/url/ "Title with "quote" inside").
- [bar]: /url/ "Title with &quot;quotes&quot; inside"
+ [bar]: /url/ "Title with "quotes" inside"
## With ampersands
diff --git a/tests/writer.native b/tests/writer.native
index 683b2c550..bc4970e12 100644
--- a/tests/writer.native
+++ b/tests/writer.native
@@ -268,7 +268,7 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] (Src "/url/" "title"),Str "."]
, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] (Src "/url/" "title preceded by two spaces"),Str "."]
, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] (Src "/url/" "title preceded by a tab"),Str "."]
-, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] (Src "/url/" "title with &quot;quotes&quot; in it")]
+, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] (Src "/url/" "title with \"quotes\" in it")]
, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] (Src "/url/" "title with single quotes")]
, Para [Link [Str "with",Str "_",Str "underscore"] (Src "/url/with_underscore" "")]
, Para [Link [Str "Email",Space,Str "link"] (Src "mailto:nobody@nowhere.net" "")]
@@ -290,8 +290,8 @@ Pandoc (Meta [Str "Pandoc",Space,Str "Test",Space,Str "Suite"] ["John MacFarlane
, CodeBlock "[not]: /url"
, Key [Str "b"] (Src "/url/" "")
, Para [Str "Foo",Space,Link [Str "bar"] (Ref [Str "bar"]),Str "."]
-, Para [Str "Foo",Space,Link [Str "biz"] (Src "/url/" "Title with &quot;quote&quot; inside"),Str "."]
-, Key [Str "bar"] (Src "/url/" "Title with &quot;quotes&quot; inside")
+, Para [Str "Foo",Space,Link [Str "biz"] (Src "/url/" "Title with \"quote\" inside"),Str "."]
+, Key [Str "bar"] (Src "/url/" "Title with \"quotes\" inside")
, Header 2 [Str "With",Space,Str "ampersands"]
, Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Link [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] (Ref [Str "1"]),Str "."]
, Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "amersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text:",Space,Link [Str "AT",Str "&",Str "T"] (Ref [Str "2"]),Str "."]