git.iko.soy/typeable/pandoc
on master help sign in
Jira writer: use Span identifiers as anchors

Closes: tarleb/jira-wiki-markup#3.

commite1454fe0d0e2f1cb4e9c5753f095a1f0a8580ffe authorAlbert Krewinkel <albert@zeitkraut.de> dateMon 1 Mar 2021, 14:14 (6 years ago) parent3793ed8
2 files changed+11−2
src/Text/Pandoc/Writers/Jira.hs+3−1 test/Tests/Writers/Jira.hs+8−1
src/Text/Pandoc/Writers/Jira.hs+3−1
@@ -292,7 +292,9 @@ quotedToJira qtype xs = do
292292spanToJira :: PandocMonad m
293293 => Attr -> [Inline]
294294 -> JiraConverter m [Jira.Inline]
295−spanToJira (_, _classes, _) = toJiraInlines
295+spanToJira (ident, _classes, _attribs) inls = case ident of
296+ "" -> toJiraInlines inls
297+ _ -> (Jira.Anchor ident :) <$> toJiraInlines inls
296298
297299registerNotes :: PandocMonad m => [Block] -> JiraConverter m [Jira.Inline]
298300registerNotes contents = do
test/Tests/Writers/Jira.hs+8−1
@@ -3,6 +3,7 @@ module Tests.Writers.Jira (tests) where
33
44import Data.Text (unpack)
55import Test.Tasty
6+import Test.Tasty.HUnit (HasCallStack)
67import Tests.Helpers
78import Text.Pandoc
89import Text.Pandoc.Arbitrary ()
@@ -12,7 +13,7 @@ jira :: (ToPandoc a) => a -> String
1213jira = unpack . purely (writeJira def) . toPandoc
1314
1415infix 4 =:
15−(=:) :: (ToString a, ToPandoc a)
16+(=:) :: (ToString a, ToPandoc a, HasCallStack)
1617 => String -> (a, String) -> TestTree
1718(=:) = test jira
1819
@@ -61,5 +62,11 @@ tests =
6162 linkWith ("", ["user-account"], []) "~johndoe" "" "~johndoe" =?>
6263 "[~johndoe]"
6364 ]
65+
66+ , testGroup "spans"
67+ [ "id is used as anchor" =:
68+ spanWith ("unicorn", [], []) (str "Unicorn") =?>
69+ "{anchor:unicorn}Unicorn"
70+ ]
6471 ]
6572 ]