aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Readers/Jira.hs14
-rw-r--r--test/Tests/Readers/Jira.hs9
2 files changed, 22 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/Jira.hs b/src/Text/Pandoc/Readers/Jira.hs
index 117239d40..cfe8ba81c 100644
--- a/src/Text/Pandoc/Readers/Jira.hs
+++ b/src/Text/Pandoc/Readers/Jira.hs
@@ -123,7 +123,8 @@ jiraToPandocInlines = \case
fromInlines ils
Jira.Emoji icon -> str . iconUnicode $ icon
Jira.Entity entity -> str . fromEntity $ entity
- Jira.Image _ url -> image (Jira.fromURL url) "" mempty
+ Jira.Image params url -> let (title, attr) = imgParams params
+ in imageWith attr (Jira.fromURL url) title mempty
Jira.Link alias url -> link (Jira.fromURL url) "" (fromInlines alias)
Jira.Linebreak -> linebreak
Jira.Monospaced inlns -> code . stringify . toList . fromInlines $ inlns
@@ -145,6 +146,17 @@ jiraToPandocInlines = \case
Jira.Subscript -> subscript
Jira.Superscript -> superscript
+ imgParams :: [Jira.Parameter] -> (Text, Attr)
+ imgParams = foldr addImgParam ("", ("", [], []))
+
+ addImgParam :: Jira.Parameter -> (Text, Attr) -> (Text, Attr)
+ addImgParam p (title, attr@(ident, classes, kvs)) =
+ case Jira.parameterKey p of
+ "title" -> (Jira.parameterValue p, attr)
+ "thumbnail" -> (title, (ident, "thumbnail":classes, kvs))
+ _ -> let kv = (Jira.parameterKey p, Jira.parameterValue p)
+ in (title, (ident, classes, kv:kvs))
+
-- | Get unicode representation of a Jira icon.
iconUnicode :: Jira.Icon -> Text
iconUnicode = \case
diff --git a/test/Tests/Readers/Jira.hs b/test/Tests/Readers/Jira.hs
index 299db7bed..1ae3244ab 100644
--- a/test/Tests/Readers/Jira.hs
+++ b/test/Tests/Readers/Jira.hs
@@ -117,6 +117,15 @@ tests =
"!https://example.com/image.jpg!" =?>
para (image "https://example.com/image.jpg" "" mempty)
+ , "thumbnail image" =:
+ "!image.jpg|thumbnail!" =?>
+ para (imageWith ("", ["thumbnail"], []) "image.jpg" "" mempty)
+
+ , "image with attributes" =:
+ "!image.gif|align=right, vspace=4, title=Hello!" =?>
+ let attr = ("", [], [("align", "right"), ("vspace", "4")])
+ in para $ imageWith attr "image.gif" "Hello" mempty
+
, "HTML entity" =:
"me & you" =?> para "me & you"