summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorech0 <mail@ech0.de>2023-06-22 20:00:47 +0200
committerGitHub <noreply@github.com>2023-06-22 11:00:47 -0700
commit7b8b8f802da77ce0d8e473124801e27e2e87362f (patch)
tree5654460875c22fd175ca6d8a3de3186bccdeed83
parent83b69ead8123a3483ec79a9df5be85612c3b564e (diff)
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.
-rw-r--r--src/Text/Pandoc/Readers/DokuWiki.hs6
-rw-r--r--test/Tests/Readers/DokuWiki.hs4
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"))