diff options
author | Albert Krewinkel <albert@zeitkraut.de> | 2020-07-17 16:01:41 +0200 |
---|---|---|
committer | Albert Krewinkel <albert@zeitkraut.de> | 2020-07-17 16:02:40 +0200 |
commit | 36fede2b024d46f64d1a5bbc1a82b22d681fe7c3 (patch) | |
tree | 25bb127fbaede39cc80613b09462f51d59012983 /src | |
parent | 06d834caaa91bee53537e49251a1b30cfb9a8d00 (diff) | |
download | pandoc-36fede2b024d46f64d1a5bbc1a82b22d681fe7c3.tar.gz |
Jira writer: keep image caption as alt attribute
Fixes #6529
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Writers/Jira.hs | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/Text/Pandoc/Writers/Jira.hs b/src/Text/Pandoc/Writers/Jira.hs index 12348f62b..4f12667d4 100644 --- a/src/Text/Pandoc/Writers/Jira.hs +++ b/src/Text/Pandoc/Writers/Jira.hs @@ -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 |