git.iko.soy/typeable/pandoc
on master help sign in
Simplified HTML writer's treatment of autolinks.

There are now a few different cases for Link, and less conditional logic needed. git-svn-id: https://pandoc.googlecode.com/svn/trunk@813 788f1e2b-df1e-0410-8736-df70ead52e1b

commit465c0849ff6be236f5613ef091550399552cd505 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSat 28 Jul 2007, 02:43 (19 years ago) parent0928f65
1 file changed+8−8
src/Text/Pandoc/Writers/HTML.hs+8−8
src/Text/Pandoc/Writers/HTML.hs+8−8
@@ -142,7 +142,7 @@ obfuscateLink opts text src =
142142 at' = obfuscateChar '@'
143143 (linkText, altText) =
144144 if "mailto:" `isPrefixOf` src' &&
145− text' == ("<code>" ++ drop 7 src' ++ "</code>")
145+ text' == drop 7 src'
146146 then ("e", name ++ " at " ++ domain')
147147 else ("'" ++ text' ++ "'",
148148 text' ++ " (" ++ name ++ " at " ++
@@ -369,15 +369,15 @@ inlineToHtml opts inline =
369369 else return ()
370370 return $ stringToHtml str
371371 (HtmlInline str) -> return $ primHtml str
372+ (Link [Code str] (src,tit)) | src == "mailto:" ++ str ->
373+ return $ obfuscateLink opts (stringToHtml str) src
374+ (Link txt (src,tit)) | "mailto:" `isPrefixOf` src ->
375+ do linkText <- inlineListToHtml opts txt
376+ return $ obfuscateLink opts linkText src
372377 (Link txt (src,tit)) ->
373378 do linkText <- inlineListToHtml opts txt
374− return $ if (isPrefixOf "mailto:" src)
375− then obfuscateLink opts linkText src
376− else anchor ! ([href src] ++
377− if null tit
378− then []
379− else [title tit]) $
380− linkText
379+ return $ anchor ! ([href src] ++
380+ if null tit then [] else [title tit]) $ linkText
381381 (Image txt (source,tit)) ->
382382 do alternate <- inlineListToHtml opts txt
383383 let alternate' = renderHtmlFragment alternate