diff options
author | John MacFarlane <jgm@berkeley.edu> | 2020-02-05 10:08:18 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2020-02-05 10:08:18 -0800 |
commit | 0a4f49d3703bfb7016800148059206482278eeb6 (patch) | |
tree | bef9970b57f97b26c35bd93f671c173000ed912a /src/Text | |
parent | 9c4dc8b49b3894d51aa37fbcff1c228776ffb98f (diff) | |
download | pandoc-0a4f49d3703bfb7016800148059206482278eeb6.tar.gz |
MediaWiki writer: prevent triple `[[[`.
This confuses mediawiki's parser. So we insert a `<nowiki/>`
no-op between a literal `[` and a link. Closes #6119.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Writers/MediaWiki.hs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/MediaWiki.hs b/src/Text/Pandoc/Writers/MediaWiki.hs index ad292200c..d63c9de2e 100644 --- a/src/Text/Pandoc/Writers/MediaWiki.hs +++ b/src/Text/Pandoc/Writers/MediaWiki.hs @@ -347,7 +347,17 @@ blockListToMediaWiki blocks = -- | Convert list of Pandoc inline elements to MediaWiki. inlineListToMediaWiki :: PandocMonad m => [Inline] -> MediaWikiWriter m Text inlineListToMediaWiki lst = - fmap T.concat $ mapM inlineToMediaWiki lst + fmap T.concat $ mapM inlineToMediaWiki $ fixup lst + where + fixup [] = [] + fixup (Str t : x : xs) + | not (T.null t) && T.last t == '[' + , isLinkOrImage x = + Str t : RawInline (Format "mediawiki") "<nowiki/>" : x : fixup xs + fixup (x:xs) = x : fixup xs + isLinkOrImage (Link{}) = True + isLinkOrImage (Image{}) = True + isLinkOrImage _ = False -- | Convert Pandoc inline element to MediaWiki. inlineToMediaWiki :: PandocMonad m => Inline -> MediaWikiWriter m Text |