Jira writer: use {color} when span has a color attribute

Closes: tarleb/jira-wiki-markup#10
This commit is contained in:
Albert Krewinkel 2021-05-24 09:56:02 +02:00
parent c5f9446646
commit 58fbf56548
No known key found for this signature in database
GPG key ID: 388DC0B21F631124
2 changed files with 11 additions and 3 deletions

View file

@ -309,9 +309,13 @@ quotedToJira qtype xs = do
spanToJira :: PandocMonad m
=> Attr -> [Inline]
-> JiraConverter m [Jira.Inline]
spanToJira (ident, _classes, _attribs) inls = case ident of
"" -> toJiraInlines inls
_ -> (Jira.Anchor ident :) <$> toJiraInlines inls
spanToJira (ident, _classes, attribs) inls =
let wrap = case lookup "color" attribs of
Nothing -> id
Just color -> singleton . Jira.ColorInline (Jira.ColorName color)
in wrap <$> case ident of
"" -> toJiraInlines inls
_ -> (Jira.Anchor ident :) <$> toJiraInlines inls
registerNotes :: PandocMonad m => [Block] -> JiraConverter m [Jira.Inline]
registerNotes contents = do

View file

@ -67,6 +67,10 @@ tests =
[ "id is used as anchor" =:
spanWith ("unicorn", [], []) (str "Unicorn") =?>
"{anchor:unicorn}Unicorn"
, "use `color` attribute" =:
spanWith ("",[],[("color","red")]) "ruby" =?>
"{color:red}ruby{color}"
]
, testGroup "code"