From 4ea1b2bdc0a86f135bae4ae95cfc3d45a9416604 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Sat, 30 Dec 2006 22:51:49 +0000 Subject: Merged 'strict' branch from r324. This adds a '--strict' option to pandoc, which forces it to stay as close as possible to official Markdown syntax. git-svn-id: https://pandoc.googlecode.com/svn/trunk@347 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Writers/Markdown.hs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/Text/Pandoc/Writers/Markdown.hs') diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 0e0563ab3..bfebc71fe 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -168,11 +168,12 @@ inlineToMarkdown (Link txt (Src src tit)) = (if tit /= "" then text (" \"" ++ (escapeLinkTitle tit) ++ "\"") else empty) <> char ')' -inlineToMarkdown (Link txt (Ref [])) = - char '[' <> inlineListToMarkdown txt <> text "][]" inlineToMarkdown (Link txt (Ref ref)) = - char '[' <> inlineListToMarkdown txt <> char ']' <> char '[' <> - inlineListToMarkdown ref <> char ']' + let first = char '[' <> inlineListToMarkdown txt <> char ']' + second = if (txt == ref) + then empty + else char '[' <> inlineListToMarkdown ref <> char ']' in + first <> second inlineToMarkdown (Image alternate (Src source tit)) = let alt = if (null alternate) || (alternate == [Str ""]) then text "image" @@ -181,10 +182,7 @@ inlineToMarkdown (Image alternate (Src source tit)) = (if tit /= "" then text (" \"" ++ (escapeLinkTitle tit) ++ "\"") else empty) <> char ')' -inlineToMarkdown (Image alternate (Ref [])) = - char '!' <> char '[' <> inlineListToMarkdown alternate <> char ']' inlineToMarkdown (Image alternate (Ref ref)) = - char '!' <> char '[' <> inlineListToMarkdown alternate <> char ']' <> - char '[' <> inlineListToMarkdown ref <> char ']' + char '!' <> inlineToMarkdown (Link alternate (Ref ref)) inlineToMarkdown (NoteRef ref) = text "[^" <> text (escapeString ref) <> char ']' -- cgit v1.2.3