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.
This commit is contained in:
ech0
2023-06-22 11:00:47 -07:00
committed by GitHub
parent 83b69ead81
commit 7b8b8f802d
2 changed files with 7 additions and 3 deletions
+5 -1
View File
@@ -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
+2 -2
View File
@@ -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"))