Jira writer: use Span identifiers as anchors

Closes: tarleb/jira-wiki-markup#3.
This commit is contained in:
Albert Krewinkel 2021-03-01 14:14:58 +01:00
parent 3793ed8beb
commit e1454fe0d0
No known key found for this signature in database
GPG key ID: 388DC0B21F631124
2 changed files with 11 additions and 2 deletions

View file

@ -292,7 +292,9 @@ quotedToJira qtype xs = do
spanToJira :: PandocMonad m
=> Attr -> [Inline]
-> JiraConverter m [Jira.Inline]
spanToJira (_, _classes, _) = toJiraInlines
spanToJira (ident, _classes, _attribs) inls = case ident of
"" -> toJiraInlines inls
_ -> (Jira.Anchor ident :) <$> toJiraInlines inls
registerNotes :: PandocMonad m => [Block] -> JiraConverter m [Jira.Inline]
registerNotes contents = do

View file

@ -3,6 +3,7 @@ module Tests.Writers.Jira (tests) where
import Data.Text (unpack)
import Test.Tasty
import Test.Tasty.HUnit (HasCallStack)
import Tests.Helpers
import Text.Pandoc
import Text.Pandoc.Arbitrary ()
@ -12,7 +13,7 @@ jira :: (ToPandoc a) => a -> String
jira = unpack . purely (writeJira def) . toPandoc
infix 4 =:
(=:) :: (ToString a, ToPandoc a)
(=:) :: (ToString a, ToPandoc a, HasCallStack)
=> String -> (a, String) -> TestTree
(=:) = test jira
@ -61,5 +62,11 @@ tests =
linkWith ("", ["user-account"], []) "~johndoe" "" "~johndoe" =?>
"[~johndoe]"
]
, testGroup "spans"
[ "id is used as anchor" =:
spanWith ("unicorn", [], []) (str "Unicorn") =?>
"{anchor:unicorn}Unicorn"
]
]
]