diff options
author | Albert Krewinkel <albert@zeitkraut.de> | 2020-03-30 22:21:29 +0200 |
---|---|---|
committer | Albert Krewinkel <albert@zeitkraut.de> | 2020-03-30 22:21:29 +0200 |
commit | e8e6c82aae5ca00b608f81b13a2c78c6eb7aeadc (patch) | |
tree | dcdb4c91e15ba61a6f3b4db9c1018343f6051898 | |
parent | 69a3fa57087f54df6fe24c447cfbad8563befd36 (diff) | |
download | pandoc-e8e6c82aae5ca00b608f81b13a2c78c6eb7aeadc.tar.gz |
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
-rw-r--r-- | src/Text/Pandoc/Writers/Jira.hs | 14 |
1 files changed, 13 insertions, 1 deletions
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 |