From 7c8dcc3db6afdc5c1d71fc63ca7b094040139e06 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Sat, 28 Jul 2007 15:33:58 +0000 Subject: Cleaned up and fixed autolinks in RST. All that's needed is a bare email address or URL. This is now handled with a separate matching clause in the definition of inlineToRST, rather than with conditionals. git-svn-id: https://pandoc.googlecode.com/svn/trunk@821 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Writers/RST.hs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs index 3f226ee98..5c486480c 100644 --- a/src/Text/Pandoc/Writers/RST.hs +++ b/src/Text/Pandoc/Writers/RST.hs @@ -291,21 +291,21 @@ inlineToRST opts (TeX str) = return $ text str inlineToRST opts (HtmlInline str) = return empty inlineToRST opts (LineBreak) = return $ char ' ' -- RST doesn't have linebreaks inlineToRST opts Space = return $ char ' ' +inlineToRST opts (Link [Code str] (src, tit)) | src == str || + src == "mailto:" ++ str = do + let srcSuffix = if isPrefixOf "mailto:" src then drop 7 src else src + return $ text srcSuffix inlineToRST opts (Link txt (src, tit)) = do let useReferenceLinks = writerReferenceLinks opts - let srcSuffix = if isPrefixOf "mailto:" src then drop 7 src else src - let useAuto = null tit && txt == [Str srcSuffix] - (notes, refs, pics) <- get linktext <- inlineListToRST opts $ normalizeSpaces txt - link <- if useReferenceLinks - then do let refs' = if (txt, (src, tit)) `elem` refs - then refs - else (txt, (src, tit)):refs - put (notes, refs', pics) - return $ char '`' <> linktext <> text "`_" - else return $ char '`' <> linktext <> text " <" <> - text src <> text ">`_" - return link + if useReferenceLinks + then do (notes, refs, pics) <- get + let refs' = if (txt, (src, tit)) `elem` refs + then refs + else (txt, (src, tit)):refs + put (notes, refs', pics) + return $ char '`' <> linktext <> text "`_" + else return $ char '`' <> linktext <> text " <" <> text src <> text ">`_" inlineToRST opts (Image alternate (source, tit)) = do (notes, refs, pics) <- get let labelsUsed = map fst pics -- cgit v1.2.3