aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-07-28 15:33:58 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-07-28 15:33:58 +0000
commit7c8dcc3db6afdc5c1d71fc63ca7b094040139e06 (patch)
tree4baa0a2553f934cb803ff3ccd9f37f4034e0fb13 /src/Text
parentdb0757d65be3fc91417dea63107c06dfea509606 (diff)
downloadpandoc-7c8dcc3db6afdc5c1d71fc63ca7b094040139e06.tar.gz
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
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Writers/RST.hs24
1 files changed, 12 insertions, 12 deletions
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