From e8e6c82aae5ca00b608f81b13a2c78c6eb7aeadc Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Mon, 30 Mar 2020 22:21:29 +0200 Subject: Jira writer: add image attributes Image attributes are added to the output as image parameters. If the image has a class "thumbnail", then a thumbnail image is generated; all other attributes are discarded in this case. Closes: #6234 --- src/Text/Pandoc/Writers/Jira.hs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Text/Pandoc/Writers/Jira.hs b/src/Text/Pandoc/Writers/Jira.hs index 573e13248..57de04cf5 100644 --- a/src/Text/Pandoc/Writers/Jira.hs +++ b/src/Text/Pandoc/Writers/Jira.hs @@ -191,7 +191,7 @@ toJiraInlines inlines = do Code _ cs -> return . singleton $ Jira.Monospaced (escapeSpecialChars cs) Emph xs -> styled Jira.Emphasis xs - Image _ _ (src, _) -> pure . singleton $ Jira.Image [] (Jira.URL src) + Image attr _ tgt -> imageToJira attr (fst tgt) (snd tgt) LineBreak -> pure . singleton $ Jira.Linebreak Link _ xs (tgt, _) -> singleton . flip Jira.Link (Jira.URL tgt) <$> toJiraInlines xs @@ -230,6 +230,18 @@ escapeSpecialChars t = case plainText t of Right xs -> xs Left _ -> singleton $ Jira.Str t +imageToJira :: PandocMonad m + => Attr -> Text -> Text + -> JiraConverter m [Jira.Inline] +imageToJira (_, classes, kvs) src title = + let imgParams = if "thumbnail" `elem` classes + then [Jira.Parameter "thumbnail" ""] + else map (uncurry Jira.Parameter) kvs + imgParams' = if T.null title + then imgParams + else Jira.Parameter "title" title : imgParams + in pure . singleton $ Jira.Image imgParams' (Jira.URL src) + mathToJira :: PandocMonad m => MathType -> Text -- cgit v1.2.3