From 8e0ad5a006bf0402f37c7d884bb48c39689c6246 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Sat, 27 Jan 2007 22:45:14 +0000 Subject: Cleaned up handling of embedded quotes in link titles. Now these are stored as a '"' character, not as '"'. The function escapeLinkTitle in the Markdown writer is unnecessary and was removed. Tests modified accordingly. git-svn-id: https://pandoc.googlecode.com/svn/trunk@517 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Readers/Markdown.hs | 3 +-- src/Text/Pandoc/Writers/Markdown.hs | 10 +++------- 2 files changed, 4 insertions(+), 9 deletions(-) (limited to 'src/Text') 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)) -- cgit v1.2.3