Jira writer: keep image caption as alt attribute

Fixes #6529
This commit is contained in:
Albert Krewinkel 2020-07-17 16:01:41 +02:00
parent 06d834caaa
commit 36fede2b02
No known key found for this signature in database
GPG key ID: 388DC0B21F631124
2 changed files with 14 additions and 12 deletions

View file

@ -194,7 +194,7 @@ toJiraInlines inlines = do
Jira.Monospaced (escapeSpecialChars cs) Jira.Monospaced (escapeSpecialChars cs)
Emph xs -> styled Jira.Emphasis xs Emph xs -> styled Jira.Emphasis xs
Underline xs -> styled Jira.Insert xs Underline xs -> styled Jira.Insert xs
Image attr _ tgt -> imageToJira attr (fst tgt) (snd tgt) Image attr cap tgt -> imageToJira attr cap (fst tgt) (snd tgt)
LineBreak -> pure . singleton $ Jira.Linebreak LineBreak -> pure . singleton $ Jira.Linebreak
Link attr xs tgt -> toJiraLink attr tgt xs Link attr xs tgt -> toJiraLink attr tgt xs
Math mtype cs -> mathToJira mtype cs Math mtype cs -> mathToJira mtype cs
@ -233,16 +233,18 @@ escapeSpecialChars t = case plainText t of
Left _ -> singleton $ Jira.Str t Left _ -> singleton $ Jira.Str t
imageToJira :: PandocMonad m imageToJira :: PandocMonad m
=> Attr -> Text -> Text => Attr -> [Inline] -> Text -> Text
-> JiraConverter m [Jira.Inline] -> JiraConverter m [Jira.Inline]
imageToJira (_, classes, kvs) src title = imageToJira (_, classes, kvs) caption src title =
let imgParams = if "thumbnail" `elem` classes let imageWithParams ps = Jira.Image ps (Jira.URL src)
then [Jira.Parameter "thumbnail" ""] alt = stringify caption
else map (uncurry Jira.Parameter) kvs in pure . singleton . imageWithParams $
imgParams' = if T.null title if "thumbnail" `elem` classes
then imgParams then [Jira.Parameter "thumbnail" ""]
else Jira.Parameter "title" title : imgParams else map (uncurry Jira.Parameter)
in pure . singleton $ Jira.Image imgParams' (Jira.URL src) . (if T.null title then id else (("title", title):))
. (if T.null alt then id else (("alt", alt):))
$ kvs
-- | Creates a Jira Link element. -- | Creates a Jira Link element.
toJiraLink :: PandocMonad m toJiraLink :: PandocMonad m

View file

@ -513,9 +513,9 @@ or here: <http://example.com/>
h1. {anchor:images}Images h1. {anchor:images}Images
From "Voyage dans la Lune" by Georges Melies \(1902): From "Voyage dans la Lune" by Georges Melies \(1902):
!lalune.jpg|title=fig:Voyage dans la Lune! !lalune.jpg|title=fig:Voyage dans la Lune, alt=lalune!
Here is a movie !movie.jpg! icon. Here is a movie !movie.jpg|alt=movie! icon.
---- ----
h1. {anchor:footnotes}Footnotes h1. {anchor:footnotes}Footnotes