From dd50fef01f5effb415e0c62a5345a0ab4eb14769 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 7 Mar 2023 17:04:58 -0800 Subject: ICML writer: fix images with data. The Contents element should be inside Properties. Closes #8675. --- src/Text/Pandoc/Writers/ICML.hs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Writers/ICML.hs b/src/Text/Pandoc/Writers/ICML.hs index a35699b46..8ee45f6c6 100644 --- a/src/Text/Pandoc/Writers/ICML.hs +++ b/src/Text/Pandoc/Writers/ICML.hs @@ -628,13 +628,19 @@ imageICML opts style attr (src, _) = do , selfClosingTag "PathPointType" [("Anchor", hw<>" -"<>hh), ("LeftDirection", hw<>" -"<>hh), ("RightDirection", hw<>" -"<>hh)] ] - img = if "data:" `Text.isPrefixOf` src' && "base64," `Text.isInfixOf` src' + + isdata = "data:" `Text.isPrefixOf` src' && "base64," `Text.isInfixOf` src' + contents = + if isdata then -- see #8398 inTags True "Contents" [] $ - literal (" - Text.drop 1 (Text.dropWhile (/=',') src') <> "]]>") - else selfClosingTag "Link" [("Self", "ueb"), ("LinkResourceURI", src')] - + literal (" Text.replace "%20" "" + (Text.drop 1 (Text.dropWhile (/=',') src')) <> "]]>") + else mempty + link = if isdata + then mempty + else selfClosingTag "Link" [("Self", "ueb"), + ("LinkResourceURI", src')] image = inTags True "Image" [("Self","ue6"), ("ItemTransform", scale<>" -"<>hw<>" -"<>hh)] $ vcat [ @@ -643,8 +649,9 @@ imageICML opts style attr (src, _) = do , selfClosingTag "GraphicBounds" [("Left","0"), ("Top","0") , ("Right", showFl $ ow*ow / imgWidth) , ("Bottom", showFl $ oh*oh / imgHeight)] + , contents ] - , img + , link ] doc = inTags True "CharacterStyleRange" attrs $ inTags True "Rectangle" [("Self","uec"), ("StrokeWeight", "0"), -- cgit v1.2.3