    {-# LANGUAGE LambdaCase #-}
    {-# LANGUAGE OverloadedStrings #-}
    {- |
       Module      : Text.Pandoc.Writers.Jira
       Copyright   : © 2010-2020 Albert Krewinkel, John MacFarlane
       License     : GNU GPL, version 2 or above

       Maintainer  : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
       Stability   : alpha
       Portability : portable

    Conversion of 'Pandoc' documents to Jira markup.

    JIRA:
    <https://jira.atlassian.com/secure/WikiRendererHelpAction.jspa?section=all>
    -}
    module Text.Pandoc.Writers.Jira ( writeJira ) where
    import Control.Monad.Reader (ReaderT, ask, asks, runReaderT)
    import Control.Monad.State.Strict (StateT, evalStateT, gets, modify)
    import Data.Foldable (find)
    import Data.Text (Text)
    import Text.Jira.Parser (plainText)
    import Text.Jira.Printer (prettyBlocks, prettyInlines)
    import Text.Pandoc.Class.PandocMonad (PandocMonad)
    import Text.Pandoc.Definition
    import Text.Pandoc.Options (WriterOptions (writerTemplate, writerWrapText),
                                WrapOption (..))
    import Text.Pandoc.Shared (linesToPara)
    import Text.Pandoc.Templates (renderTemplate)
    import Text.Pandoc.Writers.Math (texMathToInlines)
    import Text.Pandoc.Writers.Shared (defField, metaToContext)
    import Text.DocLayout (literal, render)
    import qualified Data.Text as T
    import qualified Text.Jira.Markup as Jira

    -- | Convert Pandoc to Jira.
    writeJira :: PandocMonad m => WriterOptions -> Pandoc -> m Text
    writeJira :: WriterOptions -> Pandoc -> m Text
    writeJira opts :: WriterOptions
    opts = WrapOption -> (Pandoc -> JiraConverter m Text) -> Pandoc -> m Text
    forall (m :: * -> *) a.
    PandocMonad m =>
    WrapOption -> (a -> JiraConverter m Text) -> a -> m Text
    runDefaultConverter (WriterOptions -> WrapOption
    writerWrapText WriterOptions
    opts) (WriterOptions -> Pandoc -> JiraConverter m Text
    forall (m :: * -> *).
    PandocMonad m =>
    WriterOptions -> Pandoc -> JiraConverter m Text
    pandocToJira WriterOptions
    opts)

    -- | State to keep track of footnotes.
    newtype ConverterState = ConverterState { ConverterState -> [Text]
    stNotes :: [Text] }

    -- | Initial converter state.
    startState :: ConverterState
    startState :: ConverterState
    startState = ConverterState :: [Text] -> ConverterState
    ConverterState { stNotes :: [Text]
    stNotes = [] }

    -- | Converter monad
    type JiraConverter m = ReaderT WrapOption (StateT ConverterState m)

    -- | Run a converter using the default state
    runDefaultConverter :: PandocMonad m
                        => WrapOption
                        -> (a -> JiraConverter m Text)
                        -> a
                        -> m Text
    runDefaultConverter :: WrapOption -> (a -> JiraConverter m Text) -> a -> m Text
    runDefaultConverter wrap :: WrapOption
    wrap c :: a -> JiraConverter m Text
    c x :: a
    x = StateT ConverterState m Text -> ConverterState -> m Text
    forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
    evalStateT (JiraConverter m Text -> WrapOption -> StateT ConverterState m Text
    forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
    runReaderT (a -> JiraConverter m Text
    c a
    x) WrapOption
    wrap) ConverterState
    startState

    -- | Return Jira representation of document.
    pandocToJira :: PandocMonad m
                 => WriterOptions -> Pandoc -> JiraConverter m Text
    pandocToJira :: WriterOptions -> Pandoc -> JiraConverter m Text
    pandocToJira opts :: WriterOptions
    opts (Pandoc meta :: Meta
    meta blocks :: [Block]
    blocks) = do
      WrapOption
    wrap <- ReaderT WrapOption (StateT ConverterState m) WrapOption
    forall r (m :: * -> *). MonadReader r m => m r
    ask
      Context Text
    metadata <- WriterOptions
    -> ([Block]
        -> ReaderT WrapOption (StateT ConverterState m) (Doc Text))
    -> ([Inline]
        -> ReaderT WrapOption (StateT ConverterState m) (Doc Text))
    -> Meta
    -> ReaderT WrapOption (StateT ConverterState m) (Context Text)
    forall (m :: * -> *) a.
    (Monad m, TemplateTarget a) =>
    WriterOptions
    -> ([Block] -> m (Doc a))
    -> ([Inline] -> m (Doc a))
    -> Meta
    -> m (Context a)
    metaToContext WriterOptions
    opts
                     ((Text -> Doc Text)
    -> JiraConverter m Text
    -> ReaderT WrapOption (StateT ConverterState m) (Doc Text)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Text -> Doc Text
    forall a. HasChars a => a -> Doc a
    literal (JiraConverter m Text
     -> ReaderT WrapOption (StateT ConverterState m) (Doc Text))
    -> ([Block] -> JiraConverter m Text)
    -> [Block]
    -> ReaderT WrapOption (StateT ConverterState m) (Doc Text)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . WrapOption
    -> ([Block]
        -> JiraConverter
             (ReaderT WrapOption (StateT ConverterState m)) Text)
    -> [Block]
    -> JiraConverter m Text
    forall (m :: * -> *) a.
    PandocMonad m =>
    WrapOption -> (a -> JiraConverter m Text) -> a -> m Text
    runDefaultConverter WrapOption
    wrap [Block]
    -> JiraConverter
         (ReaderT WrapOption (StateT ConverterState m)) Text
    forall (m :: * -> *).
    PandocMonad m =>
    [Block] -> JiraConverter m Text
    blockListToJira)
                     ((Text -> Doc Text)
    -> JiraConverter m Text
    -> ReaderT WrapOption (StateT ConverterState m) (Doc Text)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Text -> Doc Text
    forall a. HasChars a => a -> Doc a
    literal (JiraConverter m Text
     -> ReaderT WrapOption (StateT ConverterState m) (Doc Text))
    -> ([Inline] -> JiraConverter m Text)
    -> [Inline]
    -> ReaderT WrapOption (StateT ConverterState m) (Doc Text)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . WrapOption
    -> ([Inline]
        -> JiraConverter
             (ReaderT WrapOption (StateT ConverterState m)) Text)
    -> [Inline]
    -> JiraConverter m Text
    forall (m :: * -> *) a.
    PandocMonad m =>
    WrapOption -> (a -> JiraConverter m Text) -> a -> m Text
    runDefaultConverter WrapOption
    wrap [Inline]
    -> JiraConverter
         (ReaderT WrapOption (StateT ConverterState m)) Text
    forall (m :: * -> *).
    PandocMonad m =>
    [Inline] -> JiraConverter m Text
    inlineListToJira) Meta
    meta
      Text
    body <- [Block] -> JiraConverter m Text
    forall (m :: * -> *).
    PandocMonad m =>
    [Block] -> JiraConverter m Text
    blockListToJira [Block]
    blocks
      Text
    notes <- (ConverterState -> Text) -> JiraConverter m Text
    forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
    gets ((ConverterState -> Text) -> JiraConverter m Text)
    -> (ConverterState -> Text) -> JiraConverter m Text
    forall a b. (a -> b) -> a -> b
    $ Text -> [Text] -> Text
    T.intercalate "\n" ([Text] -> Text)
    -> (ConverterState -> [Text]) -> ConverterState -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Text] -> [Text]
    forall a. [a] -> [a]
    reverse ([Text] -> [Text])
    -> (ConverterState -> [Text]) -> ConverterState -> [Text]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ConverterState -> [Text]
    stNotes
      let main :: Text
    main = Text
    body Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> if Text -> Bool
    T.null Text
    notes then Text
    forall a. Monoid a => a
    mempty else "\n\n" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    notes
      let context :: Context Text
    context = Text -> Text -> Context Text -> Context Text
    forall a b. ToContext a b => Text -> b -> Context a -> Context a
    defField "body" Text
    main Context Text
    metadata
      Text -> JiraConverter m Text
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> JiraConverter m Text) -> Text -> JiraConverter m Text
    forall a b. (a -> b) -> a -> b
    $
        case WriterOptions -> Maybe (Template Text)
    writerTemplate WriterOptions
    opts of
          Nothing  -> Text
    main
          Just tpl :: Template Text
    tpl -> Maybe Int -> Doc Text -> Text
    forall a. HasChars a => Maybe Int -> Doc a -> a
    render Maybe Int
    forall a. Maybe a
    Nothing (Doc Text -> Text) -> Doc Text -> Text
    forall a b. (a -> b) -> a -> b
    $ Template Text -> Context Text -> Doc Text
    forall a b.
    (TemplateTarget a, ToContext a b) =>
    Template a -> b -> Doc a
    renderTemplate Template Text
    tpl Context Text
    context

    blockListToJira :: PandocMonad m => [Block] -> JiraConverter m Text
    blockListToJira :: [Block] -> JiraConverter m Text
    blockListToJira = ([Block] -> Text)
    -> ReaderT WrapOption (StateT ConverterState m) [Block]
    -> JiraConverter m Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [Block] -> Text
    prettyBlocks (ReaderT WrapOption (StateT ConverterState m) [Block]
     -> JiraConverter m Text)
    -> ([Block]
        -> ReaderT WrapOption (StateT ConverterState m) [Block])
    -> [Block]
    -> JiraConverter m Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Block] -> ReaderT WrapOption (StateT ConverterState m) [Block]
    forall (m :: * -> *).
    PandocMonad m =>
    [Block] -> JiraConverter m [Block]
    toJiraBlocks

    inlineListToJira :: PandocMonad m => [Inline] -> JiraConverter m Text
    inlineListToJira :: [Inline] -> JiraConverter m Text
    inlineListToJira = ([Inline] -> Text)
    -> ReaderT WrapOption (StateT ConverterState m) [Inline]
    -> JiraConverter m Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [Inline] -> Text
    prettyInlines (ReaderT WrapOption (StateT ConverterState m) [Inline]
     -> JiraConverter m Text)
    -> ([Inline]
        -> ReaderT WrapOption (StateT ConverterState m) [Inline])
    -> [Inline]
    -> JiraConverter m Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Inline] -> ReaderT WrapOption (StateT ConverterState m) [Inline]
    forall (m :: * -> *).
    PandocMonad m =>
    [Inline] -> JiraConverter m [Inline]
    toJiraInlines

    toJiraBlocks :: PandocMonad m => [Block] -> JiraConverter m [Jira.Block]
    toJiraBlocks :: [Block] -> JiraConverter m [Block]
    toJiraBlocks blocks :: [Block]
    blocks = do
      let convert :: Block -> JiraConverter m [Block]
    convert = \case
            BlockQuote bs :: [Block]
    bs        -> Block -> [Block]
    forall a. a -> [a]
    singleton (Block -> [Block]) -> ([Block] -> Block) -> [Block] -> [Block]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Block] -> Block
    Jira.BlockQuote
                                    ([Block] -> [Block])
    -> JiraConverter m [Block] -> JiraConverter m [Block]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Block] -> JiraConverter m [Block]
    forall (m :: * -> *).
    PandocMonad m =>
    [Block] -> JiraConverter m [Block]
    toJiraBlocks [Block]
    bs
            BulletList items :: [[Block]]
    items     -> Block -> [Block]
    forall a. a -> [a]
    singleton (Block -> [Block]) -> ([[Block]] -> Block) -> [[Block]] -> [Block]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ListStyle -> [[Block]] -> Block
    Jira.List ListStyle
    Jira.CircleBullets
                                    ([[Block]] -> [Block])
    -> ReaderT WrapOption (StateT ConverterState m) [[Block]]
    -> JiraConverter m [Block]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [[Block]] -> ReaderT WrapOption (StateT ConverterState m) [[Block]]
    forall (m :: * -> *).
    PandocMonad m =>
    [[Block]] -> JiraConverter m [[Block]]
    toJiraItems [[Block]]
    items
            CodeBlock attr :: Attr
    attr cs :: Text
    cs    -> Attr -> Text -> JiraConverter m [Block]
    forall (m :: * -> *).
    PandocMonad m =>
    Attr -> Text -> JiraConverter m [Block]
    toJiraCode Attr
    attr Text
    cs
            DefinitionList items :: [([Inline], [[Block]])]
    items -> [([Inline], [[Block]])] -> JiraConverter m [Block]
    forall (m :: * -> *).
    PandocMonad m =>
    [([Inline], [[Block]])] -> JiraConverter m [Block]
    toJiraDefinitionList [([Inline], [[Block]])]
    items
            Div attr :: Attr
    attr bs :: [Block]
    bs          -> Attr -> [Block] -> JiraConverter m [Block]
    forall (m :: * -> *).
    PandocMonad m =>
    Attr -> [Block] -> JiraConverter m [Block]
    toJiraPanel Attr
    attr [Block]
    bs
            Header lvl :: Int
    lvl attr :: Attr
    attr xs :: [Inline]
    xs   -> Int -> Attr -> [Inline] -> JiraConverter m [Block]
    forall (m :: * -> *).
    PandocMonad m =>
    Int -> Attr -> [Inline] -> JiraConverter m [Block]
    toJiraHeader Int
    lvl Attr
    attr [Inline]
    xs
            HorizontalRule       -> [Block] -> JiraConverter m [Block]
    forall (m :: * -> *) a. Monad m => a -> m a
    return ([Block] -> JiraConverter m [Block])
    -> (Block -> [Block]) -> Block -> JiraConverter m [Block]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Block -> [Block]
    forall a. a -> [a]
    singleton (Block -> JiraConverter m [Block])
    -> Block -> JiraConverter m [Block]
    forall a b. (a -> b) -> a -> b
    $ Block
    Jira.HorizontalRule
            LineBlock xs :: [[Inline]]
    xs         -> [Block] -> JiraConverter m [Block]
    forall (m :: * -> *).
    PandocMonad m =>
    [Block] -> JiraConverter m [Block]
    toJiraBlocks [[[Inline]] -> Block
    linesToPara [[Inline]]
    xs]
            OrderedList _ items :: [[Block]]
    items  -> Block -> [Block]
    forall a. a -> [a]
    singleton (Block -> [Block]) -> ([[Block]] -> Block) -> [[Block]] -> [Block]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ListStyle -> [[Block]] -> Block
    Jira.List ListStyle
    Jira.Enumeration
                                    ([[Block]] -> [Block])
    -> ReaderT WrapOption (StateT ConverterState m) [[Block]]
    -> JiraConverter m [Block]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [[Block]] -> ReaderT WrapOption (StateT ConverterState m) [[Block]]
    forall (m :: * -> *).
    PandocMonad m =>
    [[Block]] -> JiraConverter m [[Block]]
    toJiraItems [[Block]]
    items
            Para xs :: [Inline]
    xs              -> Block -> [Block]
    forall a. a -> [a]
    singleton (Block -> [Block]) -> ([Inline] -> Block) -> [Inline] -> [Block]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Inline] -> Block
    Jira.Para ([Inline] -> [Block])
    -> ReaderT WrapOption (StateT ConverterState m) [Inline]
    -> JiraConverter m [Block]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Inline] -> ReaderT WrapOption (StateT ConverterState m) [Inline]
    forall (m :: * -> *).
    PandocMonad m =>
    [Inline] -> JiraConverter m [Inline]
    toJiraInlines [Inline]
    xs
            Plain xs :: [Inline]
    xs             -> Block -> [Block]
    forall a. a -> [a]
    singleton (Block -> [Block]) -> ([Inline] -> Block) -> [Inline] -> [Block]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Inline] -> Block
    Jira.Para ([Inline] -> [Block])
    -> ReaderT WrapOption (StateT ConverterState m) [Inline]
    -> JiraConverter m [Block]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Inline] -> ReaderT WrapOption (StateT ConverterState m) [Inline]
    forall (m :: * -> *).
    PandocMonad m =>
    [Inline] -> JiraConverter m [Inline]
    toJiraInlines [Inline]
    xs
            RawBlock fmt :: Format
    fmt cs :: Text
    cs      -> Format -> Text -> JiraConverter m [Block]
    forall (m :: * -> *).
    PandocMonad m =>
    Format -> Text -> JiraConverter m [Block]
    rawBlockToJira Format
    fmt Text
    cs
            Null                 -> [Block] -> JiraConverter m [Block]
    forall (m :: * -> *) a. Monad m => a -> m a
    return [Block]
    forall a. Monoid a => a
    mempty
            Table _ _ _ hd :: [[Block]]
    hd body :: [[[Block]]]
    body  -> Block -> [Block]
    forall a. a -> [a]
    singleton (Block -> [Block])
    -> ReaderT WrapOption (StateT ConverterState m) Block
    -> JiraConverter m [Block]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> do
              Maybe Row
    headerRow <- if ([Block] -> Bool) -> [[Block]] -> Bool
    forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
    all [Block] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null [[Block]]
    hd
                           then Maybe Row
    -> ReaderT WrapOption (StateT ConverterState m) (Maybe Row)
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure Maybe Row
    forall a. Maybe a
    Nothing
                           else Row -> Maybe Row
    forall a. a -> Maybe a
    Just (Row -> Maybe Row)
    -> ReaderT WrapOption (StateT ConverterState m) Row
    -> ReaderT WrapOption (StateT ConverterState m) (Maybe Row)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ([Block] -> Cell)
    -> [[Block]] -> ReaderT WrapOption (StateT ConverterState m) Row
    forall (m :: * -> *).
    PandocMonad m =>
    ([Block] -> Cell) -> [[Block]] -> JiraConverter m Row
    toRow [Block] -> Cell
    Jira.HeaderCell [[Block]]
    hd
              [Row]
    bodyRows <- ([[Block]] -> ReaderT WrapOption (StateT ConverterState m) Row)
    -> [[[Block]]]
    -> ReaderT WrapOption (StateT ConverterState m) [Row]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM (([Block] -> Cell)
    -> [[Block]] -> ReaderT WrapOption (StateT ConverterState m) Row
    forall (m :: * -> *).
    PandocMonad m =>
    ([Block] -> Cell) -> [[Block]] -> JiraConverter m Row
    toRow [Block] -> Cell
    Jira.BodyCell) [[[Block]]]
    body
              let rows :: [Row]
    rows = case Maybe Row
    headerRow of
                           Just header :: Row
    header -> Row
    header Row -> [Row] -> [Row]
    forall a. a -> [a] -> [a]
    : [Row]
    bodyRows
                           Nothing     -> [Row]
    bodyRows
              Block -> ReaderT WrapOption (StateT ConverterState m) Block
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Block -> ReaderT WrapOption (StateT ConverterState m) Block)
    -> Block -> ReaderT WrapOption (StateT ConverterState m) Block
    forall a b. (a -> b) -> a -> b
    $ [Row] -> Block
    Jira.Table [Row]
    rows
      [[Block]]
    jiraBlocks <- (Block -> JiraConverter m [Block])
    -> [Block]
    -> ReaderT WrapOption (StateT ConverterState m) [[Block]]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM Block -> JiraConverter m [Block]
    convert [Block]
    blocks
      [Block] -> JiraConverter m [Block]
    forall (m :: * -> *) a. Monad m => a -> m a
    return ([Block] -> JiraConverter m [Block])
    -> [Block] -> JiraConverter m [Block]
    forall a b. (a -> b) -> a -> b
    $ [[Block]] -> [Block]
    forall a. Monoid a => [a] -> a
    mconcat [[Block]]
    jiraBlocks

    toRow :: PandocMonad m
          => ([Jira.Block] -> Jira.Cell)
          -> [TableCell]
          -> JiraConverter m Jira.Row
    toRow :: ([Block] -> Cell) -> [[Block]] -> JiraConverter m Row
    toRow mkCell :: [Block] -> Cell
    mkCell cells :: [[Block]]
    cells = [Cell] -> Row
    Jira.Row ([Cell] -> Row)
    -> ReaderT WrapOption (StateT ConverterState m) [Cell]
    -> JiraConverter m Row
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
      ([Block] -> ReaderT WrapOption (StateT ConverterState m) Cell)
    -> [[Block]] -> ReaderT WrapOption (StateT ConverterState m) [Cell]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM (([Block] -> Cell)
    -> ReaderT WrapOption (StateT ConverterState m) [Block]
    -> ReaderT WrapOption (StateT ConverterState m) Cell
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [Block] -> Cell
    mkCell (ReaderT WrapOption (StateT ConverterState m) [Block]
     -> ReaderT WrapOption (StateT ConverterState m) Cell)
    -> ([Block]
        -> ReaderT WrapOption (StateT ConverterState m) [Block])
    -> [Block]
    -> ReaderT WrapOption (StateT ConverterState m) Cell
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Block] -> ReaderT WrapOption (StateT ConverterState m) [Block]
    forall (m :: * -> *).
    PandocMonad m =>
    [Block] -> JiraConverter m [Block]
    toJiraBlocks) [[Block]]
    cells

    toJiraItems :: PandocMonad m => [[Block]] -> JiraConverter m [[Jira.Block]]
    toJiraItems :: [[Block]] -> JiraConverter m [[Block]]
    toJiraItems = ([Block] -> ReaderT WrapOption (StateT ConverterState m) [Block])
    -> [[Block]] -> JiraConverter m [[Block]]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM [Block] -> ReaderT WrapOption (StateT ConverterState m) [Block]
    forall (m :: * -> *).
    PandocMonad m =>
    [Block] -> JiraConverter m [Block]
    toJiraBlocks

    toJiraCode :: PandocMonad m
               => Attr
               -> Text
               -> JiraConverter m [Jira.Block]
    toJiraCode :: Attr -> Text -> JiraConverter m [Block]
    toJiraCode (ident :: Text
    ident, classes :: [Text]
    classes, _attribs :: [(Text, Text)]
    _attribs) code :: Text
    code = do
      let lang :: Language
    lang = case (Text -> Bool) -> [Text] -> Maybe Text
    forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
    find (\c :: Text
    c -> Text -> Text
    T.toLower Text
    c Text -> [Text] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `elem` [Text]
    knownLanguages) [Text]
    classes of
                   Nothing -> Text -> Language
    Jira.Language "java"
                   Just l :: Text
    l  -> Text -> Language
    Jira.Language Text
    l
      let addAnchor :: [Block] -> [Block]
    addAnchor b :: [Block]
    b = if Text -> Bool
    T.null Text
    ident
                        then [Block]
    b
                        else [[Inline] -> Block
    Jira.Para (Inline -> [Inline]
    forall a. a -> [a]
    singleton (Text -> Inline
    Jira.Anchor Text
    ident))] [Block] -> [Block] -> [Block]
    forall a. Semigroup a => a -> a -> a
    <> [Block]
    b
      [Block] -> JiraConverter m [Block]
    forall (m :: * -> *) a. Monad m => a -> m a
    return ([Block] -> JiraConverter m [Block])
    -> (Block -> [Block]) -> Block -> JiraConverter m [Block]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Block] -> [Block]
    addAnchor ([Block] -> [Block]) -> (Block -> [Block]) -> Block -> [Block]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Block -> [Block]
    forall a. a -> [a]
    singleton (Block -> JiraConverter m [Block])
    -> Block -> JiraConverter m [Block]
    forall a b. (a -> b) -> a -> b
    $ Language -> [Parameter] -> Text -> Block
    Jira.Code Language
    lang [Parameter]
    forall a. Monoid a => a
    mempty Text
    code

    -- | Creates a Jira definition list
    toJiraDefinitionList :: PandocMonad m
                         => [([Inline], [[Block]])]
                         -> JiraConverter m [Jira.Block]
    toJiraDefinitionList :: [([Inline], [[Block]])] -> JiraConverter m [Block]
    toJiraDefinitionList defItems :: [([Inline], [[Block]])]
    defItems = do
      let convertDefItem :: ([Inline], [[Block]])
    -> ReaderT WrapOption (StateT ConverterState m) [Block]
    convertDefItem (term :: [Inline]
    term, defs :: [[Block]]
    defs) = do
            Block
    jiraTerm <- [Inline] -> Block
    Jira.Para ([Inline] -> Block)
    -> ReaderT WrapOption (StateT ConverterState m) [Inline]
    -> ReaderT WrapOption (StateT ConverterState m) Block
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> InlineStyle
    -> [Inline]
    -> ReaderT WrapOption (StateT ConverterState m) [Inline]
    forall (m :: * -> *).
    PandocMonad m =>
    InlineStyle -> [Inline] -> JiraConverter m [Inline]
    styled InlineStyle
    Jira.Strong [Inline]
    term
            [Block]
    jiraDefs <- [[Block]] -> [Block]
    forall a. Monoid a => [a] -> a
    mconcat ([[Block]] -> [Block])
    -> ReaderT WrapOption (StateT ConverterState m) [[Block]]
    -> ReaderT WrapOption (StateT ConverterState m) [Block]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ([Block] -> ReaderT WrapOption (StateT ConverterState m) [Block])
    -> [[Block]]
    -> ReaderT WrapOption (StateT ConverterState m) [[Block]]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM [Block] -> ReaderT WrapOption (StateT ConverterState m) [Block]
    forall (m :: * -> *).
    PandocMonad m =>
    [Block] -> JiraConverter m [Block]
    toJiraBlocks [[Block]]
    defs
            [Block] -> ReaderT WrapOption (StateT ConverterState m) [Block]
    forall (m :: * -> *) a. Monad m => a -> m a
    return ([Block] -> ReaderT WrapOption (StateT ConverterState m) [Block])
    -> [Block] -> ReaderT WrapOption (StateT ConverterState m) [Block]
    forall a b. (a -> b) -> a -> b
    $ Block
    jiraTerm Block -> [Block] -> [Block]
    forall a. a -> [a] -> [a]
    : [Block]
    jiraDefs
      Block -> [Block]
    forall a. a -> [a]
    singleton (Block -> [Block]) -> ([[Block]] -> Block) -> [[Block]] -> [Block]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ListStyle -> [[Block]] -> Block
    Jira.List ListStyle
    Jira.CircleBullets ([[Block]] -> [Block])
    -> ReaderT WrapOption (StateT ConverterState m) [[Block]]
    -> JiraConverter m [Block]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (([Inline], [[Block]]) -> JiraConverter m [Block])
    -> [([Inline], [[Block]])]
    -> ReaderT WrapOption (StateT ConverterState m) [[Block]]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM ([Inline], [[Block]]) -> JiraConverter m [Block]
    forall (m :: * -> *).
    PandocMonad m =>
    ([Inline], [[Block]])
    -> ReaderT WrapOption (StateT ConverterState m) [Block]
    convertDefItem [([Inline], [[Block]])]
    defItems

    -- | Creates a Jira panel
    toJiraPanel :: PandocMonad m
                => Attr -> [Block]
                -> JiraConverter m [Jira.Block]
    toJiraPanel :: Attr -> [Block] -> JiraConverter m [Block]
    toJiraPanel attr :: Attr
    attr blocks :: [Block]
    blocks = do
      [Block]
    jiraBlocks <- [Block] -> JiraConverter m [Block]
    forall (m :: * -> *).
    PandocMonad m =>
    [Block] -> JiraConverter m [Block]
    toJiraBlocks [Block]
    blocks
      [Block] -> JiraConverter m [Block]
    forall (m :: * -> *) a. Monad m => a -> m a
    return ([Block] -> JiraConverter m [Block])
    -> [Block] -> JiraConverter m [Block]
    forall a b. (a -> b) -> a -> b
    $ if Attr
    attr Attr -> Attr -> Bool
    forall a. Eq a => a -> a -> Bool
    == Attr
    nullAttr
               then [Block]
    jiraBlocks
               else Block -> [Block]
    forall a. a -> [a]
    singleton ([Parameter] -> [Block] -> Block
    Jira.Panel [] [Block]
    jiraBlocks)

    -- | Creates a Jira header
    toJiraHeader :: PandocMonad m
                 => Int -> Attr -> [Inline]
                 -> JiraConverter m [Jira.Block]
    toJiraHeader :: Int -> Attr -> [Inline] -> JiraConverter m [Block]
    toJiraHeader lvl :: Int
    lvl (ident :: Text
    ident, _, _) inlines :: [Inline]
    inlines =
      let anchor :: Inline
    anchor = Text -> Inline
    Jira.Anchor Text
    ident
      in Block -> [Block]
    forall a. a -> [a]
    singleton (Block -> [Block]) -> ([Inline] -> Block) -> [Inline] -> [Block]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Int -> [Inline] -> Block
    Jira.Header Int
    lvl ([Inline] -> Block) -> ([Inline] -> [Inline]) -> [Inline] -> Block
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Inline
    anchor Inline -> [Inline] -> [Inline]
    forall a. a -> [a] -> [a]
    :) ([Inline] -> [Block])
    -> ReaderT WrapOption (StateT ConverterState m) [Inline]
    -> JiraConverter m [Block]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Inline] -> ReaderT WrapOption (StateT ConverterState m) [Inline]
    forall (m :: * -> *).
    PandocMonad m =>
    [Inline] -> JiraConverter m [Inline]
    toJiraInlines [Inline]
    inlines

    -- | Handles raw block. Jira is included verbatim, everything else is
    -- discarded.
    rawBlockToJira :: PandocMonad m
                   => Format -> Text
                   -> JiraConverter m [Jira.Block]
    rawBlockToJira :: Format -> Text -> JiraConverter m [Block]
    rawBlockToJira fmt :: Format
    fmt cs :: Text
    cs = do
      [Inline]
    rawInlines <- Format -> Text -> JiraConverter m [Inline]
    forall (m :: * -> *).
    PandocMonad m =>
    Format -> Text -> JiraConverter m [Inline]
    toJiraRaw Format
    fmt Text
    cs
      [Block] -> JiraConverter m [Block]
    forall (m :: * -> *) a. Monad m => a -> m a
    return ([Block] -> JiraConverter m [Block])
    -> [Block] -> JiraConverter m [Block]
    forall a b. (a -> b) -> a -> b
    $
        if [Inline] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null [Inline]
    rawInlines
        then [Block]
    forall a. Monoid a => a
    mempty
        else Block -> [Block]
    forall a. a -> [a]
    singleton ([Inline] -> Block
    Jira.Para [Inline]
    rawInlines)

    toJiraRaw :: PandocMonad m
              => Format -> Text -> JiraConverter m [Jira.Inline]
    toJiraRaw :: Format -> Text -> JiraConverter m [Inline]
    toJiraRaw fmt :: Format
    fmt cs :: Text
    cs = case Format
    fmt of
      Format "jira" -> [Inline] -> JiraConverter m [Inline]
    forall (m :: * -> *) a. Monad m => a -> m a
    return ([Inline] -> JiraConverter m [Inline])
    -> (Inline -> [Inline]) -> Inline -> JiraConverter m [Inline]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Inline -> [Inline]
    forall a. a -> [a]
    singleton (Inline -> JiraConverter m [Inline])
    -> Inline -> JiraConverter m [Inline]
    forall a b. (a -> b) -> a -> b
    $ Text -> Inline
    Jira.Str Text
    cs
      _             -> [Inline] -> JiraConverter m [Inline]
    forall (m :: * -> *) a. Monad m => a -> m a
    return [Inline]
    forall a. Monoid a => a
    mempty

    --
    -- Inlines
    --

    toJiraInlines :: PandocMonad m => [Inline] -> JiraConverter m [Jira.Inline]
    toJiraInlines :: [Inline] -> JiraConverter m [Inline]
    toJiraInlines inlines :: [Inline]
    inlines = do
      let convert :: Inline -> JiraConverter m [Inline]
    convert = \case
            Cite _ xs :: [Inline]
    xs          -> [Inline] -> JiraConverter m [Inline]
    forall (m :: * -> *).
    PandocMonad m =>
    [Inline] -> JiraConverter m [Inline]
    toJiraInlines [Inline]
    xs
            Code _ cs :: Text
    cs          -> [Inline] -> JiraConverter m [Inline]
    forall (m :: * -> *) a. Monad m => a -> m a
    return ([Inline] -> JiraConverter m [Inline])
    -> (Inline -> [Inline]) -> Inline -> JiraConverter m [Inline]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Inline -> [Inline]
    forall a. a -> [a]
    singleton (Inline -> JiraConverter m [Inline])
    -> Inline -> JiraConverter m [Inline]
    forall a b. (a -> b) -> a -> b
    $
                                  [Inline] -> Inline
    Jira.Monospaced (Text -> [Inline]
    escapeSpecialChars Text
    cs)
            Emph xs :: [Inline]
    xs            -> InlineStyle -> [Inline] -> JiraConverter m [Inline]
    forall (m :: * -> *).
    PandocMonad m =>
    InlineStyle -> [Inline] -> JiraConverter m [Inline]
    styled InlineStyle
    Jira.Emphasis [Inline]
    xs
            Image _ _ (src :: Text
    src, _) -> [Inline] -> JiraConverter m [Inline]
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure ([Inline] -> JiraConverter m [Inline])
    -> (Inline -> [Inline]) -> Inline -> JiraConverter m [Inline]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Inline -> [Inline]
    forall a. a -> [a]
    singleton (Inline -> JiraConverter m [Inline])
    -> Inline -> JiraConverter m [Inline]
    forall a b. (a -> b) -> a -> b
    $ [Parameter] -> URL -> Inline
    Jira.Image [] (Text -> URL
    Jira.URL Text
    src)
            LineBreak          -> [Inline] -> JiraConverter m [Inline]
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure ([Inline] -> JiraConverter m [Inline])
    -> (Inline -> [Inline]) -> Inline -> JiraConverter m [Inline]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Inline -> [Inline]
    forall a. a -> [a]
    singleton (Inline -> JiraConverter m [Inline])
    -> Inline -> JiraConverter m [Inline]
    forall a b. (a -> b) -> a -> b
    $ Inline
    Jira.Linebreak
            Link _ xs :: [Inline]
    xs (tgt :: Text
    tgt, _) -> Inline -> [Inline]
    forall a. a -> [a]
    singleton (Inline -> [Inline])
    -> ([Inline] -> Inline) -> [Inline] -> [Inline]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ([Inline] -> URL -> Inline) -> URL -> [Inline] -> Inline
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip [Inline] -> URL -> Inline
    Jira.Link (Text -> URL
    Jira.URL Text
    tgt)
                                  ([Inline] -> [Inline])
    -> JiraConverter m [Inline] -> JiraConverter m [Inline]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Inline] -> JiraConverter m [Inline]
    forall (m :: * -> *).
    PandocMonad m =>
    [Inline] -> JiraConverter m [Inline]
    toJiraInlines [Inline]
    xs
            Math mtype :: MathType
    mtype cs :: Text
    cs      -> MathType -> Text -> JiraConverter m [Inline]
    forall (m :: * -> *).
    PandocMonad m =>
    MathType -> Text -> JiraConverter m [Inline]
    mathToJira MathType
    mtype Text
    cs
            Note bs :: [Block]
    bs            -> [Block] -> JiraConverter m [Inline]
    forall (m :: * -> *).
    PandocMonad m =>
    [Block] -> JiraConverter m [Inline]
    registerNotes [Block]
    bs
            Quoted qt :: QuoteType
    qt xs :: [Inline]
    xs       -> QuoteType -> [Inline] -> JiraConverter m [Inline]
    forall (m :: * -> *).
    PandocMonad m =>
    QuoteType -> [Inline] -> JiraConverter m [Inline]
    quotedToJira QuoteType
    qt [Inline]
    xs
            RawInline fmt :: Format
    fmt cs :: Text
    cs   -> Format -> Text -> JiraConverter m [Inline]
    forall (m :: * -> *).
    PandocMonad m =>
    Format -> Text -> JiraConverter m [Inline]
    toJiraRaw Format
    fmt Text
    cs
            SmallCaps xs :: [Inline]
    xs       -> InlineStyle -> [Inline] -> JiraConverter m [Inline]
    forall (m :: * -> *).
    PandocMonad m =>
    InlineStyle -> [Inline] -> JiraConverter m [Inline]
    styled InlineStyle
    Jira.Strong [Inline]
    xs
            SoftBreak          -> do
                                    Bool
    preserveBreak <- (WrapOption -> Bool)
    -> ReaderT WrapOption (StateT ConverterState m) Bool
    forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
    asks (WrapOption -> WrapOption -> Bool
    forall a. Eq a => a -> a -> Bool
    == WrapOption
    WrapPreserve)
                                    [Inline] -> JiraConverter m [Inline]
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure ([Inline] -> JiraConverter m [Inline])
    -> (Inline -> [Inline]) -> Inline -> JiraConverter m [Inline]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Inline -> [Inline]
    forall a. a -> [a]
    singleton (Inline -> JiraConverter m [Inline])
    -> Inline -> JiraConverter m [Inline]
    forall a b. (a -> b) -> a -> b
    $ if Bool
    preserveBreak
                                      then Inline
    Jira.Linebreak
                                      else Inline
    Jira.Space
            Space              -> [Inline] -> JiraConverter m [Inline]
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure ([Inline] -> JiraConverter m [Inline])
    -> (Inline -> [Inline]) -> Inline -> JiraConverter m [Inline]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Inline -> [Inline]
    forall a. a -> [a]
    singleton (Inline -> JiraConverter m [Inline])
    -> Inline -> JiraConverter m [Inline]
    forall a b. (a -> b) -> a -> b
    $ Inline
    Jira.Space
            Span _attr :: Attr
    _attr xs :: [Inline]
    xs      -> [Inline] -> JiraConverter m [Inline]
    forall (m :: * -> *).
    PandocMonad m =>
    [Inline] -> JiraConverter m [Inline]
    toJiraInlines [Inline]
    xs
            Str s :: Text
    s              -> [Inline] -> JiraConverter m [Inline]
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure ([Inline] -> JiraConverter m [Inline])
    -> [Inline] -> JiraConverter m [Inline]
    forall a b. (a -> b) -> a -> b
    $ Text -> [Inline]
    escapeSpecialChars Text
    s
            Strikeout xs :: [Inline]
    xs       -> InlineStyle -> [Inline] -> JiraConverter m [Inline]
    forall (m :: * -> *).
    PandocMonad m =>
    InlineStyle -> [Inline] -> JiraConverter m [Inline]
    styled InlineStyle
    Jira.Strikeout [Inline]
    xs
            Strong xs :: [Inline]
    xs          -> InlineStyle -> [Inline] -> JiraConverter m [Inline]
    forall (m :: * -> *).
    PandocMonad m =>
    InlineStyle -> [Inline] -> JiraConverter m [Inline]
    styled InlineStyle
    Jira.Strong [Inline]
    xs
            Subscript xs :: [Inline]
    xs       -> InlineStyle -> [Inline] -> JiraConverter m [Inline]
    forall (m :: * -> *).
    PandocMonad m =>
    InlineStyle -> [Inline] -> JiraConverter m [Inline]
    styled InlineStyle
    Jira.Subscript [Inline]
    xs
            Superscript xs :: [Inline]
    xs     -> InlineStyle -> [Inline] -> JiraConverter m [Inline]
    forall (m :: * -> *).
    PandocMonad m =>
    InlineStyle -> [Inline] -> JiraConverter m [Inline]
    styled InlineStyle
    Jira.Superscript [Inline]
    xs
      [[Inline]]
    jiraInlines <- (Inline -> JiraConverter m [Inline])
    -> [Inline]
    -> ReaderT WrapOption (StateT ConverterState m) [[Inline]]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM Inline -> JiraConverter m [Inline]
    convert [Inline]
    inlines
      [Inline] -> JiraConverter m [Inline]
    forall (m :: * -> *) a. Monad m => a -> m a
    return ([Inline] -> JiraConverter m [Inline])
    -> [Inline] -> JiraConverter m [Inline]
    forall a b. (a -> b) -> a -> b
    $ [[Inline]] -> [Inline]
    forall a. Monoid a => [a] -> a
    mconcat [[Inline]]
    jiraInlines

    singleton :: a -> [a]
    singleton :: a -> [a]
    singleton = (a -> [a] -> [a]
    forall a. a -> [a] -> [a]
    :[])

    styled :: PandocMonad m
           => Jira.InlineStyle -> [Inline]
           -> JiraConverter m [Jira.Inline]
    styled :: InlineStyle -> [Inline] -> JiraConverter m [Inline]
    styled s :: InlineStyle
    s = ([Inline] -> [Inline])
    -> JiraConverter m [Inline] -> JiraConverter m [Inline]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap (Inline -> [Inline]
    forall a. a -> [a]
    singleton (Inline -> [Inline])
    -> ([Inline] -> Inline) -> [Inline] -> [Inline]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . InlineStyle -> [Inline] -> Inline
    Jira.Styled InlineStyle
    s) (JiraConverter m [Inline] -> JiraConverter m [Inline])
    -> ([Inline] -> JiraConverter m [Inline])
    -> [Inline]
    -> JiraConverter m [Inline]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Inline] -> JiraConverter m [Inline]
    forall (m :: * -> *).
    PandocMonad m =>
    [Inline] -> JiraConverter m [Inline]
    toJiraInlines

    -- | Converts a plain text value to Jira inlines, ensuring that all
    -- special characters will be handled appropriately.
    escapeSpecialChars :: Text -> [Jira.Inline]
    escapeSpecialChars :: Text -> [Inline]
    escapeSpecialChars t :: Text
    t = case Text -> Either ParseError [Inline]
    plainText Text
    t of
      Right xs :: [Inline]
    xs -> [Inline]
    xs
      Left _  -> Inline -> [Inline]
    forall a. a -> [a]
    singleton (Inline -> [Inline]) -> Inline -> [Inline]
    forall a b. (a -> b) -> a -> b
    $ Text -> Inline
    Jira.Str Text
    t

    mathToJira :: PandocMonad m
               => MathType
               -> Text
               -> JiraConverter m [Jira.Inline]
    mathToJira :: MathType -> Text -> JiraConverter m [Inline]
    mathToJira mtype :: MathType
    mtype cs :: Text
    cs = do
      [Inline]
    mathInlines <- [Inline] -> JiraConverter m [Inline]
    forall (m :: * -> *).
    PandocMonad m =>
    [Inline] -> JiraConverter m [Inline]
    toJiraInlines ([Inline] -> JiraConverter m [Inline])
    -> ReaderT WrapOption (StateT ConverterState m) [Inline]
    -> JiraConverter m [Inline]
    forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
    =<< MathType
    -> Text -> ReaderT WrapOption (StateT ConverterState m) [Inline]
    forall (m :: * -> *).
    PandocMonad m =>
    MathType -> Text -> m [Inline]
    texMathToInlines MathType
    mtype Text
    cs
      [Inline] -> JiraConverter m [Inline]
    forall (m :: * -> *) a. Monad m => a -> m a
    return ([Inline] -> JiraConverter m [Inline])
    -> [Inline] -> JiraConverter m [Inline]
    forall a b. (a -> b) -> a -> b
    $ case MathType
    mtype of
        InlineMath  -> [Inline]
    mathInlines
        DisplayMath -> Inline
    Jira.Linebreak Inline -> [Inline] -> [Inline]
    forall a. a -> [a] -> [a]
    : [Inline]
    mathInlines [Inline] -> [Inline] -> [Inline]
    forall a. [a] -> [a] -> [a]
    ++ [Inline
    Jira.Linebreak]

    quotedToJira :: PandocMonad m
                 => QuoteType
                 -> [Inline]
                 -> JiraConverter m [Jira.Inline]
    quotedToJira :: QuoteType -> [Inline] -> JiraConverter m [Inline]
    quotedToJira qtype :: QuoteType
    qtype xs :: [Inline]
    xs = do
      let quoteChar :: Text
    quoteChar = case QuoteType
    qtype of
                        DoubleQuote -> "\""
                        SingleQuote -> "'"
      let surroundWithQuotes :: [Inline] -> [Inline]
    surroundWithQuotes = (Text -> Inline
    Jira.Str Text
    quoteChar Inline -> [Inline] -> [Inline]
    forall a. a -> [a] -> [a]
    :) ([Inline] -> [Inline])
    -> ([Inline] -> [Inline]) -> [Inline] -> [Inline]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ([Inline] -> [Inline] -> [Inline]
    forall a. [a] -> [a] -> [a]
    ++ [Text -> Inline
    Jira.Str Text
    quoteChar])
      [Inline] -> [Inline]
    surroundWithQuotes ([Inline] -> [Inline])
    -> JiraConverter m [Inline] -> JiraConverter m [Inline]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Inline] -> JiraConverter m [Inline]
    forall (m :: * -> *).
    PandocMonad m =>
    [Inline] -> JiraConverter m [Inline]
    toJiraInlines [Inline]
    xs

    registerNotes :: PandocMonad m => [Block] -> JiraConverter m [Jira.Inline]
    registerNotes :: [Block] -> JiraConverter m [Inline]
    registerNotes contents :: [Block]
    contents = do
      [Text]
    curNotes <- (ConverterState -> [Text])
    -> ReaderT WrapOption (StateT ConverterState m) [Text]
    forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
    gets ConverterState -> [Text]
    stNotes
      let newnum :: Int
    newnum = [Text] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length [Text]
    curNotes Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + 1
      Text
    contents' <- [Block] -> JiraConverter m Text
    forall (m :: * -> *).
    PandocMonad m =>
    [Block] -> JiraConverter m Text
    blockListToJira [Block]
    contents
      let thisnote :: Text
    thisnote = "\\[" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> String -> Text
    T.pack (Int -> String
    forall a. Show a => a -> String
    show Int
    newnum) Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> "] " Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    contents' Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> "\n"
      (ConverterState -> ConverterState)
    -> ReaderT WrapOption (StateT ConverterState m) ()
    forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
    modify ((ConverterState -> ConverterState)
     -> ReaderT WrapOption (StateT ConverterState m) ())
    -> (ConverterState -> ConverterState)
    -> ReaderT WrapOption (StateT ConverterState m) ()
    forall a b. (a -> b) -> a -> b
    $ \s :: ConverterState
    s -> ConverterState
    s { stNotes :: [Text]
    stNotes = Text
    thisnote Text -> [Text] -> [Text]
    forall a. a -> [a] -> [a]
    : [Text]
    curNotes }
      [Inline] -> JiraConverter m [Inline]
    forall (m :: * -> *) a. Monad m => a -> m a
    return ([Inline] -> JiraConverter m [Inline])
    -> (Text -> [Inline]) -> Text -> JiraConverter m [Inline]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Inline -> [Inline]
    forall a. a -> [a]
    singleton (Inline -> [Inline]) -> (Text -> Inline) -> Text -> [Inline]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> Inline
    Jira.Str (Text -> JiraConverter m [Inline])
    -> Text -> JiraConverter m [Inline]
    forall a b. (a -> b) -> a -> b
    $
        "[" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> String -> Text
    T.pack (Int -> String
    forall a. Show a => a -> String
    show Int
    newnum) Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> "]"

    -- | Language codes recognized by jira
    knownLanguages :: [Text]
    knownLanguages :: [Text]
    knownLanguages =
      [ "actionscript", "ada", "applescript", "bash", "c", "c#", "c++"
      , "css", "erlang", "go", "groovy", "haskell", "html", "javascript"
      , "json", "lua", "nyan", "objc", "perl", "php", "python", "r", "ruby"
      , "scala", "sql", "swift", "visualbasic", "xml", "yaml"
      ]