diff options
| author | Jesse Hathaway <[email protected]> | 2022-01-06 10:10:10 -0600 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2022-01-06 15:05:39 -0800 |
| commit | 4dcb2b6fb6d634c226adc173cb4c77f45360f836 (patch) | |
| tree | 228b3364e1df7037ca5f0872fe1312bf7fb8d86c /src | |
| parent | 6fffa1ac7884896406b9b5626aab35660a8826f3 (diff) | |
MediaWiki writer: Remove redundant display text for wiki links
Prior to this commit the MediaWiki writer always added the display
text for a wiki link:
* [[Help|Help]]
* [[Bubbles|Everyone loves bubbles]]
However the display text in the first example is redundant since
MediaWiki uses the target as the default display text. The result being:
* [[Help]]
* [[Bubbles|Everyone loves bubbles]]
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc/Writers/MediaWiki.hs | 11 |
1 files changed, 7 insertions, 4 deletions
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 |
