diff options
-rw-r--r-- | src/Text/Pandoc/Writers/MediaWiki.hs | 20 | ||||
-rw-r--r-- | tests/writer.mediawiki | 44 |
2 files changed, 31 insertions, 33 deletions
diff --git a/src/Text/Pandoc/Writers/MediaWiki.hs b/src/Text/Pandoc/Writers/MediaWiki.hs index f81fda5d4..f1e985bb7 100644 --- a/src/Text/Pandoc/Writers/MediaWiki.hs +++ b/src/Text/Pandoc/Writers/MediaWiki.hs @@ -377,17 +377,15 @@ inlineToMediaWiki _ (LineBreak) = return "<br />\n" inlineToMediaWiki _ Space = return " " inlineToMediaWiki opts (Link txt (src, _)) = do - link <- inlineListToMediaWiki opts txt - let useAuto = txt == [Code src] - let src' = if isURI src - then src - else if take 1 src == "/" - then "http://{{SERVERNAME}}" ++ src - else "http://{{SERVERNAME}}/" ++ src - return $ if useAuto - then src' - else "[" ++ src' ++ " " ++ link ++ "]" - + label <- inlineListToMediaWiki opts txt + if txt == [Code src] -- autolink + then return src + else if isURI src + then return $ "[" ++ src ++ " " ++ label ++ "]" + else return $ "[[" ++ src' ++ "|" ++ label ++ "]]" + where src' = case src of + '/':xs -> xs -- with leading / it's a + _ -> src -- link to a help page inlineToMediaWiki opts (Image alt (source, tit)) = do alt' <- inlineListToMediaWiki opts alt let txt = if (null tit) diff --git a/tests/writer.mediawiki b/tests/writer.mediawiki index 942223c2d..5873ea831 100644 --- a/tests/writer.mediawiki +++ b/tests/writer.mediawiki @@ -5,7 +5,7 @@ This is a set of tests for pandoc. Most of them are adapted from John Gruber&rsq = Headers = -== Level 2 with an [http://{{SERVERNAME}}/url embedded link] == +== Level 2 with an [[url|embedded link]] == === Level 3 with ''emphasis'' === @@ -430,7 +430,7 @@ This is ''emphasized'', and so ''is this''. This is '''strong''', and so '''is this'''. -An ''[http://{{SERVERNAME}}/url emphasized link]''. +An ''[[url|emphasized link]]''. '''''This is strong and em.''''' @@ -558,48 +558,48 @@ Minus: - == Explicit == -Just a [http://{{SERVERNAME}}/url/ URL]. +Just a [[url/|URL]]. -[http://{{SERVERNAME}}/url/ URL and title]. +[[url/|URL and title]]. -[http://{{SERVERNAME}}/url/ URL and title]. +[[url/|URL and title]]. -[http://{{SERVERNAME}}/url/ URL and title]. +[[url/|URL and title]]. -[http://{{SERVERNAME}}/url/ URL and title] +[[url/|URL and title]] -[http://{{SERVERNAME}}/url/ URL and title] +[[url/|URL and title]] -[http://{{SERVERNAME}}/url/with_underscore with_underscore] +[[url/with_underscore|with_underscore]] [mailto:nobody@nowhere.net Email link] -[http://{{SERVERNAME}}/ Empty]. +[[|Empty]]. == Reference == -Foo [http://{{SERVERNAME}}/url/ bar]. +Foo [[url/|bar]]. -Foo [http://{{SERVERNAME}}/url/ bar]. +Foo [[url/|bar]]. -Foo [http://{{SERVERNAME}}/url/ bar]. +Foo [[url/|bar]]. -With [http://{{SERVERNAME}}/url/ embedded [brackets]]. +With [[url/|embedded [brackets]]]. -[http://{{SERVERNAME}}/url/ b] by itself should be a link. +[[url/|b]] by itself should be a link. -Indented [http://{{SERVERNAME}}/url once]. +Indented [[url|once]]. -Indented [http://{{SERVERNAME}}/url twice]. +Indented [[url|twice]]. -Indented [http://{{SERVERNAME}}/url thrice]. +Indented [[url|thrice]]. This should [not][] be a link. <pre>[not]: /url</pre> -Foo [http://{{SERVERNAME}}/url/ bar]. +Foo [[url/|bar]]. -Foo [http://{{SERVERNAME}}/url/ biz]. +Foo [[url/|biz]]. == With ampersands == @@ -607,9 +607,9 @@ Here’s a [http://example.com/?foo=1&bar=2 link with an ampersand in the UR Here’s a link with an amersand in the link text: [http://att.com/ AT&T]. -Here’s an [http://{{SERVERNAME}}/script?foo=1&bar=2 inline link]. +Here’s an [[script?foo=1&bar=2|inline link]]. -Here’s an [http://{{SERVERNAME}}/script?foo=1&bar=2 inline link in pointy braces]. +Here’s an [[script?foo=1&bar=2|inline link in pointy braces]]. == Autolinks == |