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
This commit is contained in:
Albert Krewinkel 2020-03-30 22:21:29 +02:00
parent 69a3fa5708
commit e8e6c82aae
No known key found for this signature in database
GPG key ID: 388DC0B21F631124

View file

@ -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