git.iko.soy/typeable/pandoc
on master help sign in
Jira writer: convert spans with class `underline` to inserted text

Spans with class `underline` as converted into Jira text marked as `+inserted+`, i.e. surrounded by plus-signs.

commitff9be6b38429b502b1582f2395b824305eb8c99c authorAlbert Krewinkel <albert@zeitkraut.de> dateTue 31 Mar 2020, 09:57 (7 years ago) parent9a42bec
4 files changed+39−1
pandoc.cabal+1 src/Text/Pandoc/Writers/Jira.hs+9−1 test/Tests/Writers/Jira.hs+27 test/test-pandoc.hs+2
pandoc.cabal+1
@@ -789,6 +789,7 @@ test-suite test-pandoc
789789 Tests.Writers.Docbook
790790 Tests.Writers.HTML
791791 Tests.Writers.JATS
792+ Tests.Writers.Jira
792793 Tests.Writers.Markdown
793794 Tests.Writers.Org
794795 Tests.Writers.Plain
src/Text/Pandoc/Writers/Jira.hs+9−1
@@ -206,7 +206,7 @@ toJiraInlines inlines = do
206206 then Jira.Linebreak
207207 else Jira.Space
208208 Space -> pure . singleton $ Jira.Space
209− Span _attr xs -> toJiraInlines xs
209+ Span attr xs -> spanToJira attr xs
210210 Str s -> pure $ escapeSpecialChars s
211211 Strikeout xs -> styled Jira.Strikeout xs
212212 Strong xs -> styled Jira.Strong xs
@@ -263,6 +263,14 @@ quotedToJira qtype xs = do
263263 let surroundWithQuotes = (Jira.Str quoteChar :) . (++ [Jira.Str quoteChar])
264264 surroundWithQuotes <$> toJiraInlines xs
265265
266+spanToJira :: PandocMonad m
267+ => Attr -> [Inline]
268+ -> JiraConverter m [Jira.Inline]
269+spanToJira (_, classes, _) =
270+ if "underline" `elem` classes
271+ then styled Jira.Insert
272+ else toJiraInlines
273+
266274registerNotes :: PandocMonad m => [Block] -> JiraConverter m [Jira.Inline]
267275registerNotes contents = do
268276 curNotes <- gets stNotes
test/Tests/Writers/Jira.hsnew file+27
@@ -0,0 +1,27 @@
1+{-# LANGUAGE OverloadedStrings #-}
2+module Tests.Writers.Jira (tests) where
3+
4+import Data.Text (unpack)
5+import Test.Tasty
6+import Tests.Helpers
7+import Text.Pandoc
8+import Text.Pandoc.Arbitrary ()
9+import Text.Pandoc.Builder
10+
11+jira :: (ToPandoc a) => a -> String
12+jira = unpack . purely (writeJira def) . toPandoc
13+
14+infix 4 =:
15+(=:) :: (ToString a, ToPandoc a)
16+ => String -> (a, String) -> TestTree
17+(=:) = test jira
18+
19+tests :: [TestTree]
20+tests =
21+ [ testGroup "inlines"
22+ [ "underlined text" =:
23+ spanWith ("ignored", ["ignored", "underline"], [("foo", "bar")])
24+ "underlined text" =?>
25+ "+underlined text+"
26+ ]
27+ ]
test/test-pandoc.hs+2
@@ -34,6 +34,7 @@ import qualified Tests.Writers.Docx
3434import qualified Tests.Writers.FB2
3535import qualified Tests.Writers.HTML
3636import qualified Tests.Writers.JATS
37+import qualified Tests.Writers.Jira
3738import qualified Tests.Writers.LaTeX
3839import qualified Tests.Writers.Markdown
3940import qualified Tests.Writers.Muse
@@ -57,6 +58,7 @@ tests pandocPath = testGroup "pandoc tests"
5758 , testGroup "LaTeX" Tests.Writers.LaTeX.tests
5859 , testGroup "HTML" Tests.Writers.HTML.tests
5960 , testGroup "JATS" Tests.Writers.JATS.tests
61+ , testGroup "Jira" Tests.Writers.Jira.tests
6062 , testGroup "Docbook" Tests.Writers.Docbook.tests
6163 , testGroup "Markdown" Tests.Writers.Markdown.tests
6264 , testGroup "Org" Tests.Writers.Org.tests