From 7b8b8f802da77ce0d8e473124801e27e2e87362f Mon Sep 17 00:00:00 2001 From: ech0 Date: Thu, 22 Jun 2023 20:00:47 +0200 Subject: Retain image query parameters in dokuwiki reader (#8887) While converting dokuwiki syntax to gfm, the query parameters of images were stripped from the output. In general this makes sense, as the parameters' semantics are specific to dokuwiki. But it makes it impossible to access the query in a filter. This change retains the query parameters of image urls in the dokuwiki reader, by adding it as an extra query attribute. --- src/Text/Pandoc/Readers/DokuWiki.hs | 6 +++++- test/Tests/Readers/DokuWiki.hs | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Text/Pandoc/Readers/DokuWiki.hs b/src/Text/Pandoc/Readers/DokuWiki.hs index 1ca4cf696..77213a111 100644 --- a/src/Text/Pandoc/Readers/DokuWiki.hs +++ b/src/Text/Pandoc/Readers/DokuWiki.hs @@ -389,7 +389,11 @@ image = try $ parseLink fromRaw "{{" "}}" parameterList = T.splitOn "&" $ T.drop 1 parameters linkOnly = "linkonly" `elem` parameterList (width, height) = maybe (Nothing, Nothing) parseWidthHeight (F.find isWidthHeightParameter parameterList) - attributes = catMaybes [fmap ("width",) width, fmap ("height",) height] + attributes = catMaybes [ + fmap ("width",) width, + fmap ("height",) height, + fmap ("query",) (if T.null parameters then Nothing else Just parameters) + ] defaultDescription = B.str $ urlToText path' -- * Block parsers diff --git a/test/Tests/Readers/DokuWiki.hs b/test/Tests/Readers/DokuWiki.hs index 56275d3d2..c0363db31 100644 --- a/test/Tests/Readers/DokuWiki.hs +++ b/test/Tests/Readers/DokuWiki.hs @@ -167,10 +167,10 @@ tests = [ testGroup "inlines" para (imageWith ("", ["align-center"], []) "/wiki/dokuwiki-128.png" "" (str "dokuwiki-128.png")) , "Image with width" =: "{{wiki:dokuwiki-128.png?50}}" =?> - para (imageWith ("", [], [("width", "50")]) "/wiki/dokuwiki-128.png" "" (str "dokuwiki-128.png")) + para (imageWith ("", [], [("width", "50"), ("query", "?50")]) "/wiki/dokuwiki-128.png" "" (str "dokuwiki-128.png")) , "Image with width and height" =: "{{wiki:dokuwiki-128.png?nocache&50x100}}" =?> - para (imageWith ("", [], [("width", "50"), ("height", "100")]) "/wiki/dokuwiki-128.png" "" (str "dokuwiki-128.png")) + para (imageWith ("", [], [("width", "50"), ("height", "100"), ("query", "?nocache&50x100")]) "/wiki/dokuwiki-128.png" "" (str "dokuwiki-128.png")) , "Linkonly" =: "{{wiki:dokuwiki-128.png?linkonly}}" =?> para (link "/wiki/dokuwiki-128.png" "" (str "dokuwiki-128.png")) -- cgit v1.2.3