git.iko.soy/typeable/pandoc
on master help sign in
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

commit7c8dcc3db6afdc5c1d71fc63ca7b094040139e06 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSat 28 Jul 2007, 15:33 (19 years ago) parentdb0757d
1 file changed+12−12
src/Text/Pandoc/Writers/RST.hs+12−12
src/Text/Pandoc/Writers/RST.hs+12−12
@@ -291,21 +291,21 @@ inlineToRST opts (TeX str) = return $ text str
291291inlineToRST opts (HtmlInline str) = return empty
292292inlineToRST opts (LineBreak) = return $ char ' ' -- RST doesn't have linebreaks
293293inlineToRST opts Space = return $ char ' '
294+inlineToRST opts (Link [Code str] (src, tit)) | src == str ||
295+ src == "mailto:" ++ str = do
296+ let srcSuffix = if isPrefixOf "mailto:" src then drop 7 src else src
297+ return $ text srcSuffix
294298inlineToRST opts (Link txt (src, tit)) = do
295299 let useReferenceLinks = writerReferenceLinks opts
296− let srcSuffix = if isPrefixOf "mailto:" src then drop 7 src else src
297− let useAuto = null tit && txt == [Str srcSuffix]
298− (notes, refs, pics) <- get
299300 linktext <- inlineListToRST opts $ normalizeSpaces txt
300− link <- if useReferenceLinks
301− then do let refs' = if (txt, (src, tit)) `elem` refs
302− then refs
303− else (txt, (src, tit)):refs
304− put (notes, refs', pics)
305− return $ char '`' <> linktext <> text "`_"
306− else return $ char '`' <> linktext <> text " <" <>
307− text src <> text ">`_"
308− return link
301+ if useReferenceLinks
302+ then do (notes, refs, pics) <- get
303+ let refs' = if (txt, (src, tit)) `elem` refs
304+ then refs
305+ else (txt, (src, tit)):refs
306+ put (notes, refs', pics)
307+ return $ char '`' <> linktext <> text "`_"
308+ else return $ char '`' <> linktext <> text " <" <> text src <> text ">`_"
309309inlineToRST opts (Image alternate (source, tit)) = do
310310 (notes, refs, pics) <- get
311311 let labelsUsed = map fst pics