diff options
| author | wgevaert <[email protected]> | 2023-04-05 17:03:46 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-04-05 08:03:46 -0700 |
| commit | fd0f7332ede4329d53f60fa5adae029b1b52b5a2 (patch) | |
| tree | 099b4846167e0ffbd770af864bc9de756d5de3ca /src | |
| parent | 6da429f82999cdb3f06b9369501088639a3fe126 (diff) | |
Remove links from inside links in mediawiki writer (#8739)
Co-authored-by: Wout Gevaert <[email protected]>
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc/Writers/MediaWiki.hs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/MediaWiki.hs b/src/Text/Pandoc/Writers/MediaWiki.hs index baf35406c..ecc9fd413 100644 --- a/src/Text/Pandoc/Writers/MediaWiki.hs +++ b/src/Text/Pandoc/Writers/MediaWiki.hs @@ -26,6 +26,7 @@ import Text.Pandoc.Definition import Text.Pandoc.ImageSize import Text.Pandoc.Logging import Text.Pandoc.Options +import Text.Pandoc.Walk import Text.DocLayout (render, literal) import Text.Pandoc.Shared import Text.Pandoc.URI @@ -470,7 +471,7 @@ inlineToMediaWiki SoftBreak = do inlineToMediaWiki Space = return " " inlineToMediaWiki (Link _ txt (src, _)) = do - label <- inlineListToMediaWiki txt + label <- inlineListToMediaWiki (removeLinks txt) case txt of [Str s] | isURI src && escapeURI s == src -> return src _ -> return $ if isURI src @@ -504,6 +505,14 @@ inlineToMediaWiki (Note contents) = do return $ "<ref>" <> stripTrailingNewlines contents' <> "</ref>" -- note - does not work for notes with multiple blocks +-- We need to remove links from link text, because an <a> element is +-- not allowed inside another <a> element. +removeLinks :: [Inline] -> [Inline] +removeLinks = walk go + where + go (Link _ ils _) = SmallCaps ils + go x = x + highlightingLangs :: Set.Set Text highlightingLangs = Set.fromList [ "abap", |
