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.
This commit is contained in:
Albert Krewinkel 2020-03-31 09:57:59 +02:00
parent 9a42bec7fc
commit ff9be6b384
No known key found for this signature in database
GPG key ID: 388DC0B21F631124
4 changed files with 39 additions and 1 deletions

View file

@ -789,6 +789,7 @@ test-suite test-pandoc
Tests.Writers.Docbook
Tests.Writers.HTML
Tests.Writers.JATS
Tests.Writers.Jira
Tests.Writers.Markdown
Tests.Writers.Org
Tests.Writers.Plain

View file

@ -206,7 +206,7 @@ toJiraInlines inlines = do
then Jira.Linebreak
else Jira.Space
Space -> pure . singleton $ Jira.Space
Span _attr xs -> toJiraInlines xs
Span attr xs -> spanToJira attr xs
Str s -> pure $ escapeSpecialChars s
Strikeout xs -> styled Jira.Strikeout xs
Strong xs -> styled Jira.Strong xs
@ -263,6 +263,14 @@ quotedToJira qtype xs = do
let surroundWithQuotes = (Jira.Str quoteChar :) . (++ [Jira.Str quoteChar])
surroundWithQuotes <$> toJiraInlines xs
spanToJira :: PandocMonad m
=> Attr -> [Inline]
-> JiraConverter m [Jira.Inline]
spanToJira (_, classes, _) =
if "underline" `elem` classes
then styled Jira.Insert
else toJiraInlines
registerNotes :: PandocMonad m => [Block] -> JiraConverter m [Jira.Inline]
registerNotes contents = do
curNotes <- gets stNotes

View file

@ -0,0 +1,27 @@
{-# LANGUAGE OverloadedStrings #-}
module Tests.Writers.Jira (tests) where
import Data.Text (unpack)
import Test.Tasty
import Tests.Helpers
import Text.Pandoc
import Text.Pandoc.Arbitrary ()
import Text.Pandoc.Builder
jira :: (ToPandoc a) => a -> String
jira = unpack . purely (writeJira def) . toPandoc
infix 4 =:
(=:) :: (ToString a, ToPandoc a)
=> String -> (a, String) -> TestTree
(=:) = test jira
tests :: [TestTree]
tests =
[ testGroup "inlines"
[ "underlined text" =:
spanWith ("ignored", ["ignored", "underline"], [("foo", "bar")])
"underlined text" =?>
"+underlined text+"
]
]

View file

@ -34,6 +34,7 @@ import qualified Tests.Writers.Docx
import qualified Tests.Writers.FB2
import qualified Tests.Writers.HTML
import qualified Tests.Writers.JATS
import qualified Tests.Writers.Jira
import qualified Tests.Writers.LaTeX
import qualified Tests.Writers.Markdown
import qualified Tests.Writers.Muse
@ -57,6 +58,7 @@ tests pandocPath = testGroup "pandoc tests"
, testGroup "LaTeX" Tests.Writers.LaTeX.tests
, testGroup "HTML" Tests.Writers.HTML.tests
, testGroup "JATS" Tests.Writers.JATS.tests
, testGroup "Jira" Tests.Writers.Jira.tests
, testGroup "Docbook" Tests.Writers.Docbook.tests
, testGroup "Markdown" Tests.Writers.Markdown.tests
, testGroup "Org" Tests.Writers.Org.tests