diff --git a/src/Text/Pandoc/Writers/MediaWiki.hs b/src/Text/Pandoc/Writers/MediaWiki.hs index a04975ae3..f4bdf239c 100644 --- a/src/Text/Pandoc/Writers/MediaWiki.hs +++ b/src/Text/Pandoc/Writers/MediaWiki.hs @@ -449,10 +449,13 @@ inlineToMediaWiki (Link _ txt (src, _)) = do case txt of [Str s] | isURI src && escapeURI s == src -> return src _ -> return $ if isURI src - then "[" <> src <> " " <> label <> "]" - else "[[" <> src' <> "|" <> label <> "]]" - -- with leading / it's a link to a help page - where src' = fromMaybe src $ T.stripPrefix "/" src + then "[" <> src <> " " <> label <> "]" + else + if src == label + then "[[" <> src' <> "]]" + else "[[" <> src' <> "|" <> label <> "]]" + -- with leading / it's a link to a help page + where src' = fromMaybe src $ T.stripPrefix "/" src inlineToMediaWiki (Image attr alt (source, tit)) = do img <- imageToMediaWiki attr diff --git a/test/command/7808.md b/test/command/7808.md new file mode 100644 index 000000000..9c7d3032f --- /dev/null +++ b/test/command/7808.md @@ -0,0 +1,8 @@ +Wiki links should have no display text, if their display text matches +their target. +``` +% pandoc -f mediawiki -t mediawiki +[[Help]] [[Butter|Butter]] [[Bubbles|Everyone loves bubbles]] +^D +[[Help]] [[Butter]] [[Bubbles|Everyone loves bubbles]] +```