Jira writer: keep image caption as alt attribute

Fixes #6529
This commit is contained in:
Albert Krewinkel
2020-07-17 16:02:40 +02:00
parent 06d834caaa
commit 36fede2b02
2 changed files with 14 additions and 12 deletions
+12 -10
View File
@@ -194,7 +194,7 @@ toJiraInlines inlines = do
Jira.Monospaced (escapeSpecialChars cs)
Emph xs -> styled Jira.Emphasis 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
Link attr xs tgt -> toJiraLink attr tgt xs
Math mtype cs -> mathToJira mtype cs
@@ -233,16 +233,18 @@ escapeSpecialChars t = case plainText t of
Left _ -> singleton $ Jira.Str t
imageToJira :: PandocMonad m
=> Attr -> Text -> Text
=> Attr -> [Inline] -> 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)
imageToJira (_, classes, kvs) caption src title =
let imageWithParams ps = Jira.Image ps (Jira.URL src)
alt = stringify caption
in pure . singleton . imageWithParams $
if "thumbnail" `elem` classes
then [Jira.Parameter "thumbnail" ""]
else map (uncurry Jira.Parameter)
. (if T.null title then id else (("title", title):))
. (if T.null alt then id else (("alt", alt):))
$ kvs
-- | Creates a Jira Link element.
toJiraLink :: PandocMonad m
+2 -2
View File
@@ -513,9 +513,9 @@ or here: <http://example.com/>
h1. {anchor:images}Images
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