    {-# LANGUAGE LambdaCase #-}
    {-|
    Module      : Text.Jira.Markup
    Copyright   : © 2019–2023 Albert Krewinkel
    License     : MIT

    Maintainer  : Albert Krewinkel <tarleb@zeitkraut.de>
    Stability   : alpha
    Portability : portable

    Jira markup types.
    -}
    module Text.Jira.Markup
      ( Doc (..)
      , Block (..)
      , Inline (..)
      , InlineStyle (..)
      , LinkType (..)
      , ListStyle (..)
      , URL (..)
      , ColorName (..)
      , Icon (..)
      , Row (..)
      , Cell (..)
      , Language (..)
      , Parameter (..)
      , normalizeInlines
      , iconText
      ) where

    import Data.Text (Text, append)

    -- | Jira document
    newtype Doc = Doc { Doc -> [Block]
    fromDoc :: [Block] }
      deriving (Doc -> Doc -> Bool
    (Doc -> Doc -> Bool) -> (Doc -> Doc -> Bool) -> Eq Doc
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Doc -> Doc -> Bool
    == :: Doc -> Doc -> Bool
    $c/= :: Doc -> Doc -> Bool
    /= :: Doc -> Doc -> Bool
    Eq, Eq Doc
    Eq Doc =>
    (Doc -> Doc -> Ordering)
    -> (Doc -> Doc -> Bool)
    -> (Doc -> Doc -> Bool)
    -> (Doc -> Doc -> Bool)
    -> (Doc -> Doc -> Bool)
    -> (Doc -> Doc -> Doc)
    -> (Doc -> Doc -> Doc)
    -> Ord Doc
    Doc -> Doc -> Bool
    Doc -> Doc -> Ordering
    Doc -> Doc -> Doc
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: Doc -> Doc -> Ordering
    compare :: Doc -> Doc -> Ordering
    $c< :: Doc -> Doc -> Bool
    < :: Doc -> Doc -> Bool
    $c<= :: Doc -> Doc -> Bool
    <= :: Doc -> Doc -> Bool
    $c> :: Doc -> Doc -> Bool
    > :: Doc -> Doc -> Bool
    $c>= :: Doc -> Doc -> Bool
    >= :: Doc -> Doc -> Bool
    $cmax :: Doc -> Doc -> Doc
    max :: Doc -> Doc -> Doc
    $cmin :: Doc -> Doc -> Doc
    min :: Doc -> Doc -> Doc
    Ord, Int -> Doc -> ShowS
    [Doc] -> ShowS
    Doc -> String
    (Int -> Doc -> ShowS)
    -> (Doc -> String) -> ([Doc] -> ShowS) -> Show Doc
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Doc -> ShowS
    showsPrec :: Int -> Doc -> ShowS
    $cshow :: Doc -> String
    show :: Doc -> String
    $cshowList :: [Doc] -> ShowS
    showList :: [Doc] -> ShowS
    Show)

    -- | Inline Jira markup elements.
    data Inline
      = Anchor Text                         -- ^ anchor for internal links
      | AutoLink URL                        -- ^ URL which is also a link
      | Citation [Inline]                   -- ^ source of a citation
      | ColorInline ColorName [Inline]      -- ^ colored inline text
      | Emoji Icon                          -- ^ emoticon
      | Entity Text                         -- ^ named or numeric HTML entity
      | Image [Parameter] URL               -- ^ an image
      | Linebreak                           -- ^ hard linebreak
      | Link LinkType [Inline] URL          -- ^ hyperlink with alias
      | Monospaced [Inline]                 -- ^ text rendered with monospaced font
      | Space                               -- ^ space between words
      | SpecialChar Char                    -- ^ single char with special meaning
      | Str Text                            -- ^ simple, markup-less string
      | Styled InlineStyle [Inline]         -- ^ styled text
      deriving (Inline -> Inline -> Bool
    (Inline -> Inline -> Bool)
    -> (Inline -> Inline -> Bool) -> Eq Inline
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Inline -> Inline -> Bool
    == :: Inline -> Inline -> Bool
    $c/= :: Inline -> Inline -> Bool
    /= :: Inline -> Inline -> Bool
    Eq, Eq Inline
    Eq Inline =>
    (Inline -> Inline -> Ordering)
    -> (Inline -> Inline -> Bool)
    -> (Inline -> Inline -> Bool)
    -> (Inline -> Inline -> Bool)
    -> (Inline -> Inline -> Bool)
    -> (Inline -> Inline -> Inline)
    -> (Inline -> Inline -> Inline)
    -> Ord Inline
    Inline -> Inline -> Bool
    Inline -> Inline -> Ordering
    Inline -> Inline -> Inline
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: Inline -> Inline -> Ordering
    compare :: Inline -> Inline -> Ordering
    $c< :: Inline -> Inline -> Bool
    < :: Inline -> Inline -> Bool
    $c<= :: Inline -> Inline -> Bool
    <= :: Inline -> Inline -> Bool
    $c> :: Inline -> Inline -> Bool
    > :: Inline -> Inline -> Bool
    $c>= :: Inline -> Inline -> Bool
    >= :: Inline -> Inline -> Bool
    $cmax :: Inline -> Inline -> Inline
    max :: Inline -> Inline -> Inline
    $cmin :: Inline -> Inline -> Inline
    min :: Inline -> Inline -> Inline
    Ord, Int -> Inline -> ShowS
    [Inline] -> ShowS
    Inline -> String
    (Int -> Inline -> ShowS)
    -> (Inline -> String) -> ([Inline] -> ShowS) -> Show Inline
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Inline -> ShowS
    showsPrec :: Int -> Inline -> ShowS
    $cshow :: Inline -> String
    show :: Inline -> String
    $cshowList :: [Inline] -> ShowS
    showList :: [Inline] -> ShowS
    Show)

    -- | Supported inline text effect styles.
    data InlineStyle
      = Emphasis                            -- ^ emphasized text
      | Insert                              -- ^ text marked as having been inserted
      | Strikeout                           -- ^ deleted (struk-out) text
      | Strong                              -- ^ strongly emphasized text
      | Subscript                           -- ^ subscript text
      | Superscript                         -- ^ superscript text
      deriving (InlineStyle -> InlineStyle -> Bool
    (InlineStyle -> InlineStyle -> Bool)
    -> (InlineStyle -> InlineStyle -> Bool) -> Eq InlineStyle
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: InlineStyle -> InlineStyle -> Bool
    == :: InlineStyle -> InlineStyle -> Bool
    $c/= :: InlineStyle -> InlineStyle -> Bool
    /= :: InlineStyle -> InlineStyle -> Bool
    Eq, Eq InlineStyle
    Eq InlineStyle =>
    (InlineStyle -> InlineStyle -> Ordering)
    -> (InlineStyle -> InlineStyle -> Bool)
    -> (InlineStyle -> InlineStyle -> Bool)
    -> (InlineStyle -> InlineStyle -> Bool)
    -> (InlineStyle -> InlineStyle -> Bool)
    -> (InlineStyle -> InlineStyle -> InlineStyle)
    -> (InlineStyle -> InlineStyle -> InlineStyle)
    -> Ord InlineStyle
    InlineStyle -> InlineStyle -> Bool
    InlineStyle -> InlineStyle -> Ordering
    InlineStyle -> InlineStyle -> InlineStyle
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: InlineStyle -> InlineStyle -> Ordering
    compare :: InlineStyle -> InlineStyle -> Ordering
    $c< :: InlineStyle -> InlineStyle -> Bool
    < :: InlineStyle -> InlineStyle -> Bool
    $c<= :: InlineStyle -> InlineStyle -> Bool
    <= :: InlineStyle -> InlineStyle -> Bool
    $c> :: InlineStyle -> InlineStyle -> Bool
    > :: InlineStyle -> InlineStyle -> Bool
    $c>= :: InlineStyle -> InlineStyle -> Bool
    >= :: InlineStyle -> InlineStyle -> Bool
    $cmax :: InlineStyle -> InlineStyle -> InlineStyle
    max :: InlineStyle -> InlineStyle -> InlineStyle
    $cmin :: InlineStyle -> InlineStyle -> InlineStyle
    min :: InlineStyle -> InlineStyle -> InlineStyle
    Ord, Int -> InlineStyle -> ShowS
    [InlineStyle] -> ShowS
    InlineStyle -> String
    (Int -> InlineStyle -> ShowS)
    -> (InlineStyle -> String)
    -> ([InlineStyle] -> ShowS)
    -> Show InlineStyle
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> InlineStyle -> ShowS
    showsPrec :: Int -> InlineStyle -> ShowS
    $cshow :: InlineStyle -> String
    show :: InlineStyle -> String
    $cshowList :: [InlineStyle] -> ShowS
    showList :: [InlineStyle] -> ShowS
    Show)

    -- | Type of a link.
    data LinkType
      = Attachment                          -- ^ link to an attachment
      | Email                               -- ^ link to an email address
      | External                            -- ^ external resource, like a website
      | SmartCard                           -- ^ smart-card link (external)
      | SmartLink                           -- ^ "smart" link with icon, short-name
      | User                                -- ^ link to a user
      deriving (LinkType -> LinkType -> Bool
    (LinkType -> LinkType -> Bool)
    -> (LinkType -> LinkType -> Bool) -> Eq LinkType
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: LinkType -> LinkType -> Bool
    == :: LinkType -> LinkType -> Bool
    $c/= :: LinkType -> LinkType -> Bool
    /= :: LinkType -> LinkType -> Bool
    Eq, Eq LinkType
    Eq LinkType =>
    (LinkType -> LinkType -> Ordering)
    -> (LinkType -> LinkType -> Bool)
    -> (LinkType -> LinkType -> Bool)
    -> (LinkType -> LinkType -> Bool)
    -> (LinkType -> LinkType -> Bool)
    -> (LinkType -> LinkType -> LinkType)
    -> (LinkType -> LinkType -> LinkType)
    -> Ord LinkType
    LinkType -> LinkType -> Bool
    LinkType -> LinkType -> Ordering
    LinkType -> LinkType -> LinkType
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: LinkType -> LinkType -> Ordering
    compare :: LinkType -> LinkType -> Ordering
    $c< :: LinkType -> LinkType -> Bool
    < :: LinkType -> LinkType -> Bool
    $c<= :: LinkType -> LinkType -> Bool
    <= :: LinkType -> LinkType -> Bool
    $c> :: LinkType -> LinkType -> Bool
    > :: LinkType -> LinkType -> Bool
    $c>= :: LinkType -> LinkType -> Bool
    >= :: LinkType -> LinkType -> Bool
    $cmax :: LinkType -> LinkType -> LinkType
    max :: LinkType -> LinkType -> LinkType
    $cmin :: LinkType -> LinkType -> LinkType
    min :: LinkType -> LinkType -> LinkType
    Ord, Int -> LinkType -> ShowS
    [LinkType] -> ShowS
    LinkType -> String
    (Int -> LinkType -> ShowS)
    -> (LinkType -> String) -> ([LinkType] -> ShowS) -> Show LinkType
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> LinkType -> ShowS
    showsPrec :: Int -> LinkType -> ShowS
    $cshow :: LinkType -> String
    show :: LinkType -> String
    $cshowList :: [LinkType] -> ShowS
    showList :: [LinkType] -> ShowS
    Show)

    -- | Blocks of text.
    data Block
      = Code Language [Parameter] Text      -- ^ Code block with panel parameters
      | Color ColorName [Block]             -- ^ text displayed in a specific color
      | BlockQuote [Block]                  -- ^ Block of quoted content
      | Header Int [Inline]                 -- ^ Header with level and text
      | HorizontalRule                      -- ^ horizontal ruler
      | List ListStyle [[Block]]            -- ^ List
      | NoFormat [Parameter] Text           -- ^ Unformatted text
      | Panel [Parameter] [Block]           -- ^ Formatted panel
      | Para [Inline]                       -- ^ Paragraph of text
      | Table [Row]                         -- ^ Table
      deriving (Block -> Block -> Bool
    (Block -> Block -> Bool) -> (Block -> Block -> Bool) -> Eq Block
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Block -> Block -> Bool
    == :: Block -> Block -> Bool
    $c/= :: Block -> Block -> Bool
    /= :: Block -> Block -> Bool
    Eq, Eq Block
    Eq Block =>
    (Block -> Block -> Ordering)
    -> (Block -> Block -> Bool)
    -> (Block -> Block -> Bool)
    -> (Block -> Block -> Bool)
    -> (Block -> Block -> Bool)
    -> (Block -> Block -> Block)
    -> (Block -> Block -> Block)
    -> Ord Block
    Block -> Block -> Bool
    Block -> Block -> Ordering
    Block -> Block -> Block
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: Block -> Block -> Ordering
    compare :: Block -> Block -> Ordering
    $c< :: Block -> Block -> Bool
    < :: Block -> Block -> Bool
    $c<= :: Block -> Block -> Bool
    <= :: Block -> Block -> Bool
    $c> :: Block -> Block -> Bool
    > :: Block -> Block -> Bool
    $c>= :: Block -> Block -> Bool
    >= :: Block -> Block -> Bool
    $cmax :: Block -> Block -> Block
    max :: Block -> Block -> Block
    $cmin :: Block -> Block -> Block
    min :: Block -> Block -> Block
    Ord, Int -> Block -> ShowS
    [Block] -> ShowS
    Block -> String
    (Int -> Block -> ShowS)
    -> (Block -> String) -> ([Block] -> ShowS) -> Show Block
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Block -> ShowS
    showsPrec :: Int -> Block -> ShowS
    $cshow :: Block -> String
    show :: Block -> String
    $cshowList :: [Block] -> ShowS
    showList :: [Block] -> ShowS
    Show)

    -- | Style used for list items.
    data ListStyle
      = CircleBullets                       -- ^ List with round bullets
      | SquareBullets                       -- ^ List with square bullets
      | Enumeration                         -- ^ Enumeration, i.e., numbered items
      deriving (ListStyle -> ListStyle -> Bool
    (ListStyle -> ListStyle -> Bool)
    -> (ListStyle -> ListStyle -> Bool) -> Eq ListStyle
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ListStyle -> ListStyle -> Bool
    == :: ListStyle -> ListStyle -> Bool
    $c/= :: ListStyle -> ListStyle -> Bool
    /= :: ListStyle -> ListStyle -> Bool
    Eq, Eq ListStyle
    Eq ListStyle =>
    (ListStyle -> ListStyle -> Ordering)
    -> (ListStyle -> ListStyle -> Bool)
    -> (ListStyle -> ListStyle -> Bool)
    -> (ListStyle -> ListStyle -> Bool)
    -> (ListStyle -> ListStyle -> Bool)
    -> (ListStyle -> ListStyle -> ListStyle)
    -> (ListStyle -> ListStyle -> ListStyle)
    -> Ord ListStyle
    ListStyle -> ListStyle -> Bool
    ListStyle -> ListStyle -> Ordering
    ListStyle -> ListStyle -> ListStyle
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: ListStyle -> ListStyle -> Ordering
    compare :: ListStyle -> ListStyle -> Ordering
    $c< :: ListStyle -> ListStyle -> Bool
    < :: ListStyle -> ListStyle -> Bool
    $c<= :: ListStyle -> ListStyle -> Bool
    <= :: ListStyle -> ListStyle -> Bool
    $c> :: ListStyle -> ListStyle -> Bool
    > :: ListStyle -> ListStyle -> Bool
    $c>= :: ListStyle -> ListStyle -> Bool
    >= :: ListStyle -> ListStyle -> Bool
    $cmax :: ListStyle -> ListStyle -> ListStyle
    max :: ListStyle -> ListStyle -> ListStyle
    $cmin :: ListStyle -> ListStyle -> ListStyle
    min :: ListStyle -> ListStyle -> ListStyle
    Ord, Int -> ListStyle -> ShowS
    [ListStyle] -> ShowS
    ListStyle -> String
    (Int -> ListStyle -> ShowS)
    -> (ListStyle -> String)
    -> ([ListStyle] -> ShowS)
    -> Show ListStyle
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> ListStyle -> ShowS
    showsPrec :: Int -> ListStyle -> ShowS
    $cshow :: ListStyle -> String
    show :: ListStyle -> String
    $cshowList :: [ListStyle] -> ShowS
    showList :: [ListStyle] -> ShowS
    Show)

    -- | Text color
    newtype ColorName = ColorName Text
      deriving (ColorName -> ColorName -> Bool
    (ColorName -> ColorName -> Bool)
    -> (ColorName -> ColorName -> Bool) -> Eq ColorName
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ColorName -> ColorName -> Bool
    == :: ColorName -> ColorName -> Bool
    $c/= :: ColorName -> ColorName -> Bool
    /= :: ColorName -> ColorName -> Bool
    Eq, Eq ColorName
    Eq ColorName =>
    (ColorName -> ColorName -> Ordering)
    -> (ColorName -> ColorName -> Bool)
    -> (ColorName -> ColorName -> Bool)
    -> (ColorName -> ColorName -> Bool)
    -> (ColorName -> ColorName -> Bool)
    -> (ColorName -> ColorName -> ColorName)
    -> (ColorName -> ColorName -> ColorName)
    -> Ord ColorName
    ColorName -> ColorName -> Bool
    ColorName -> ColorName -> Ordering
    ColorName -> ColorName -> ColorName
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: ColorName -> ColorName -> Ordering
    compare :: ColorName -> ColorName -> Ordering
    $c< :: ColorName -> ColorName -> Bool
    < :: ColorName -> ColorName -> Bool
    $c<= :: ColorName -> ColorName -> Bool
    <= :: ColorName -> ColorName -> Bool
    $c> :: ColorName -> ColorName -> Bool
    > :: ColorName -> ColorName -> Bool
    $c>= :: ColorName -> ColorName -> Bool
    >= :: ColorName -> ColorName -> Bool
    $cmax :: ColorName -> ColorName -> ColorName
    max :: ColorName -> ColorName -> ColorName
    $cmin :: ColorName -> ColorName -> ColorName
    min :: ColorName -> ColorName -> ColorName
    Ord, Int -> ColorName -> ShowS
    [ColorName] -> ShowS
    ColorName -> String
    (Int -> ColorName -> ShowS)
    -> (ColorName -> String)
    -> ([ColorName] -> ShowS)
    -> Show ColorName
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> ColorName -> ShowS
    showsPrec :: Int -> ColorName -> ShowS
    $cshow :: ColorName -> String
    show :: ColorName -> String
    $cshowList :: [ColorName] -> ShowS
    showList :: [ColorName] -> ShowS
    Show)

    -- | Unified resource location
    newtype URL = URL { URL -> Text
    fromURL :: Text }
      deriving (URL -> URL -> Bool
    (URL -> URL -> Bool) -> (URL -> URL -> Bool) -> Eq URL
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: URL -> URL -> Bool
    == :: URL -> URL -> Bool
    $c/= :: URL -> URL -> Bool
    /= :: URL -> URL -> Bool
    Eq, Eq URL
    Eq URL =>
    (URL -> URL -> Ordering)
    -> (URL -> URL -> Bool)
    -> (URL -> URL -> Bool)
    -> (URL -> URL -> Bool)
    -> (URL -> URL -> Bool)
    -> (URL -> URL -> URL)
    -> (URL -> URL -> URL)
    -> Ord URL
    URL -> URL -> Bool
    URL -> URL -> Ordering
    URL -> URL -> URL
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: URL -> URL -> Ordering
    compare :: URL -> URL -> Ordering
    $c< :: URL -> URL -> Bool
    < :: URL -> URL -> Bool
    $c<= :: URL -> URL -> Bool
    <= :: URL -> URL -> Bool
    $c> :: URL -> URL -> Bool
    > :: URL -> URL -> Bool
    $c>= :: URL -> URL -> Bool
    >= :: URL -> URL -> Bool
    $cmax :: URL -> URL -> URL
    max :: URL -> URL -> URL
    $cmin :: URL -> URL -> URL
    min :: URL -> URL -> URL
    Ord, Int -> URL -> ShowS
    [URL] -> ShowS
    URL -> String
    (Int -> URL -> ShowS)
    -> (URL -> String) -> ([URL] -> ShowS) -> Show URL
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> URL -> ShowS
    showsPrec :: Int -> URL -> ShowS
    $cshow :: URL -> String
    show :: URL -> String
    $cshowList :: [URL] -> ShowS
    showList :: [URL] -> ShowS
    Show)

    -- | Table row, containing an arbitrary number of cells.
    newtype Row = Row { Row -> [Cell]
    fromRow :: [Cell] }
      deriving (Row -> Row -> Bool
    (Row -> Row -> Bool) -> (Row -> Row -> Bool) -> Eq Row
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Row -> Row -> Bool
    == :: Row -> Row -> Bool
    $c/= :: Row -> Row -> Bool
    /= :: Row -> Row -> Bool
    Eq, Eq Row
    Eq Row =>
    (Row -> Row -> Ordering)
    -> (Row -> Row -> Bool)
    -> (Row -> Row -> Bool)
    -> (Row -> Row -> Bool)
    -> (Row -> Row -> Bool)
    -> (Row -> Row -> Row)
    -> (Row -> Row -> Row)
    -> Ord Row
    Row -> Row -> Bool
    Row -> Row -> Ordering
    Row -> Row -> Row
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: Row -> Row -> Ordering
    compare :: Row -> Row -> Ordering
    $c< :: Row -> Row -> Bool
    < :: Row -> Row -> Bool
    $c<= :: Row -> Row -> Bool
    <= :: Row -> Row -> Bool
    $c> :: Row -> Row -> Bool
    > :: Row -> Row -> Bool
    $c>= :: Row -> Row -> Bool
    >= :: Row -> Row -> Bool
    $cmax :: Row -> Row -> Row
    max :: Row -> Row -> Row
    $cmin :: Row -> Row -> Row
    min :: Row -> Row -> Row
    Ord, Int -> Row -> ShowS
    [Row] -> ShowS
    Row -> String
    (Int -> Row -> ShowS)
    -> (Row -> String) -> ([Row] -> ShowS) -> Show Row
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Row -> ShowS
    showsPrec :: Int -> Row -> ShowS
    $cshow :: Row -> String
    show :: Row -> String
    $cshowList :: [Row] -> ShowS
    showList :: [Row] -> ShowS
    Show)

    -- | Table cell with block content
    data Cell
      = BodyCell [Block]
      | HeaderCell [Block]
      deriving (Cell -> Cell -> Bool
    (Cell -> Cell -> Bool) -> (Cell -> Cell -> Bool) -> Eq Cell
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Cell -> Cell -> Bool
    == :: Cell -> Cell -> Bool
    $c/= :: Cell -> Cell -> Bool
    /= :: Cell -> Cell -> Bool
    Eq, Eq Cell
    Eq Cell =>
    (Cell -> Cell -> Ordering)
    -> (Cell -> Cell -> Bool)
    -> (Cell -> Cell -> Bool)
    -> (Cell -> Cell -> Bool)
    -> (Cell -> Cell -> Bool)
    -> (Cell -> Cell -> Cell)
    -> (Cell -> Cell -> Cell)
    -> Ord Cell
    Cell -> Cell -> Bool
    Cell -> Cell -> Ordering
    Cell -> Cell -> Cell
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: Cell -> Cell -> Ordering
    compare :: Cell -> Cell -> Ordering
    $c< :: Cell -> Cell -> Bool
    < :: Cell -> Cell -> Bool
    $c<= :: Cell -> Cell -> Bool
    <= :: Cell -> Cell -> Bool
    $c> :: Cell -> Cell -> Bool
    > :: Cell -> Cell -> Bool
    $c>= :: Cell -> Cell -> Bool
    >= :: Cell -> Cell -> Bool
    $cmax :: Cell -> Cell -> Cell
    max :: Cell -> Cell -> Cell
    $cmin :: Cell -> Cell -> Cell
    min :: Cell -> Cell -> Cell
    Ord, Int -> Cell -> ShowS
    [Cell] -> ShowS
    Cell -> String
    (Int -> Cell -> ShowS)
    -> (Cell -> String) -> ([Cell] -> ShowS) -> Show Cell
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Cell -> ShowS
    showsPrec :: Int -> Cell -> ShowS
    $cshow :: Cell -> String
    show :: Cell -> String
    $cshowList :: [Cell] -> ShowS
    showList :: [Cell] -> ShowS
    Show)

    -- | Programming language used for syntax highlighting.
    newtype Language = Language Text
      deriving (Language -> Language -> Bool
    (Language -> Language -> Bool)
    -> (Language -> Language -> Bool) -> Eq Language
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Language -> Language -> Bool
    == :: Language -> Language -> Bool
    $c/= :: Language -> Language -> Bool
    /= :: Language -> Language -> Bool
    Eq, Eq Language
    Eq Language =>
    (Language -> Language -> Ordering)
    -> (Language -> Language -> Bool)
    -> (Language -> Language -> Bool)
    -> (Language -> Language -> Bool)
    -> (Language -> Language -> Bool)
    -> (Language -> Language -> Language)
    -> (Language -> Language -> Language)
    -> Ord Language
    Language -> Language -> Bool
    Language -> Language -> Ordering
    Language -> Language -> Language
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: Language -> Language -> Ordering
    compare :: Language -> Language -> Ordering
    $c< :: Language -> Language -> Bool
    < :: Language -> Language -> Bool
    $c<= :: Language -> Language -> Bool
    <= :: Language -> Language -> Bool
    $c> :: Language -> Language -> Bool
    > :: Language -> Language -> Bool
    $c>= :: Language -> Language -> Bool
    >= :: Language -> Language -> Bool
    $cmax :: Language -> Language -> Language
    max :: Language -> Language -> Language
    $cmin :: Language -> Language -> Language
    min :: Language -> Language -> Language
    Ord, Int -> Language -> ShowS
    [Language] -> ShowS
    Language -> String
    (Int -> Language -> ShowS)
    -> (Language -> String) -> ([Language] -> ShowS) -> Show Language
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Language -> ShowS
    showsPrec :: Int -> Language -> ShowS
    $cshow :: Language -> String
    show :: Language -> String
    $cshowList :: [Language] -> ShowS
    showList :: [Language] -> ShowS
    Show)

    -- | Panel parameter
    data Parameter = Parameter
      { Parameter -> Text
    parameterKey :: Text
      , Parameter -> Text
    parameterValue :: Text
      } deriving (Parameter -> Parameter -> Bool
    (Parameter -> Parameter -> Bool)
    -> (Parameter -> Parameter -> Bool) -> Eq Parameter
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Parameter -> Parameter -> Bool
    == :: Parameter -> Parameter -> Bool
    $c/= :: Parameter -> Parameter -> Bool
    /= :: Parameter -> Parameter -> Bool
    Eq, Eq Parameter
    Eq Parameter =>
    (Parameter -> Parameter -> Ordering)
    -> (Parameter -> Parameter -> Bool)
    -> (Parameter -> Parameter -> Bool)
    -> (Parameter -> Parameter -> Bool)
    -> (Parameter -> Parameter -> Bool)
    -> (Parameter -> Parameter -> Parameter)
    -> (Parameter -> Parameter -> Parameter)
    -> Ord Parameter
    Parameter -> Parameter -> Bool
    Parameter -> Parameter -> Ordering
    Parameter -> Parameter -> Parameter
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: Parameter -> Parameter -> Ordering
    compare :: Parameter -> Parameter -> Ordering
    $c< :: Parameter -> Parameter -> Bool
    < :: Parameter -> Parameter -> Bool
    $c<= :: Parameter -> Parameter -> Bool
    <= :: Parameter -> Parameter -> Bool
    $c> :: Parameter -> Parameter -> Bool
    > :: Parameter -> Parameter -> Bool
    $c>= :: Parameter -> Parameter -> Bool
    >= :: Parameter -> Parameter -> Bool
    $cmax :: Parameter -> Parameter -> Parameter
    max :: Parameter -> Parameter -> Parameter
    $cmin :: Parameter -> Parameter -> Parameter
    min :: Parameter -> Parameter -> Parameter
    Ord, Int -> Parameter -> ShowS
    [Parameter] -> ShowS
    Parameter -> String
    (Int -> Parameter -> ShowS)
    -> (Parameter -> String)
    -> ([Parameter] -> ShowS)
    -> Show Parameter
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Parameter -> ShowS
    showsPrec :: Int -> Parameter -> ShowS
    $cshow :: Parameter -> String
    show :: Parameter -> String
    $cshowList :: [Parameter] -> ShowS
    showList :: [Parameter] -> ShowS
    Show)

    -- | Graphical emoticons
    data Icon
      = IconSlightlySmiling
      | IconFrowning
      | IconTongue
      | IconSmiling
      | IconWinking
      | IconThumbsUp
      | IconThumbsDown
      | IconInfo
      | IconCheckmark
      | IconX
      | IconAttention
      | IconPlus
      | IconMinus
      | IconQuestionmark
      | IconOn
      | IconOff
      | IconStar
      | IconStarRed
      | IconStarGreen
      | IconStarBlue
      | IconStarYellow
      | IconFlag
      | IconFlagOff
      deriving (Int -> Icon
    Icon -> Int
    Icon -> [Icon]
    Icon -> Icon
    Icon -> Icon -> [Icon]
    Icon -> Icon -> Icon -> [Icon]
    (Icon -> Icon)
    -> (Icon -> Icon)
    -> (Int -> Icon)
    -> (Icon -> Int)
    -> (Icon -> [Icon])
    -> (Icon -> Icon -> [Icon])
    -> (Icon -> Icon -> [Icon])
    -> (Icon -> Icon -> Icon -> [Icon])
    -> Enum Icon
    forall a.
    (a -> a)
    -> (a -> a)
    -> (Int -> a)
    -> (a -> Int)
    -> (a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> a -> [a])
    -> Enum a
    $csucc :: Icon -> Icon
    succ :: Icon -> Icon
    $cpred :: Icon -> Icon
    pred :: Icon -> Icon
    $ctoEnum :: Int -> Icon
    toEnum :: Int -> Icon
    $cfromEnum :: Icon -> Int
    fromEnum :: Icon -> Int
    $cenumFrom :: Icon -> [Icon]
    enumFrom :: Icon -> [Icon]
    $cenumFromThen :: Icon -> Icon -> [Icon]
    enumFromThen :: Icon -> Icon -> [Icon]
    $cenumFromTo :: Icon -> Icon -> [Icon]
    enumFromTo :: Icon -> Icon -> [Icon]
    $cenumFromThenTo :: Icon -> Icon -> Icon -> [Icon]
    enumFromThenTo :: Icon -> Icon -> Icon -> [Icon]
    Enum, Icon -> Icon -> Bool
    (Icon -> Icon -> Bool) -> (Icon -> Icon -> Bool) -> Eq Icon
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Icon -> Icon -> Bool
    == :: Icon -> Icon -> Bool
    $c/= :: Icon -> Icon -> Bool
    /= :: Icon -> Icon -> Bool
    Eq, Eq Icon
    Eq Icon =>
    (Icon -> Icon -> Ordering)
    -> (Icon -> Icon -> Bool)
    -> (Icon -> Icon -> Bool)
    -> (Icon -> Icon -> Bool)
    -> (Icon -> Icon -> Bool)
    -> (Icon -> Icon -> Icon)
    -> (Icon -> Icon -> Icon)
    -> Ord Icon
    Icon -> Icon -> Bool
    Icon -> Icon -> Ordering
    Icon -> Icon -> Icon
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: Icon -> Icon -> Ordering
    compare :: Icon -> Icon -> Ordering
    $c< :: Icon -> Icon -> Bool
    < :: Icon -> Icon -> Bool
    $c<= :: Icon -> Icon -> Bool
    <= :: Icon -> Icon -> Bool
    $c> :: Icon -> Icon -> Bool
    > :: Icon -> Icon -> Bool
    $c>= :: Icon -> Icon -> Bool
    >= :: Icon -> Icon -> Bool
    $cmax :: Icon -> Icon -> Icon
    max :: Icon -> Icon -> Icon
    $cmin :: Icon -> Icon -> Icon
    min :: Icon -> Icon -> Icon
    Ord, Int -> Icon -> ShowS
    [Icon] -> ShowS
    Icon -> String
    (Int -> Icon -> ShowS)
    -> (Icon -> String) -> ([Icon] -> ShowS) -> Show Icon
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Icon -> ShowS
    showsPrec :: Int -> Icon -> ShowS
    $cshow :: Icon -> String
    show :: Icon -> String
    $cshowList :: [Icon] -> ShowS
    showList :: [Icon] -> ShowS
    Show)

    -- | Normalize a list of inlines, merging elements where possible.
    normalizeInlines :: [Inline] -> [Inline]
    normalizeInlines :: [Inline] -> [Inline]
    normalizeInlines = \case
      []                     -> []
      [Inline
    Space]                -> []
      [Inline
    Linebreak]            -> []
      Inline
    Space : Inline
    Space : [Inline]
    xs     -> Inline
    Space Inline -> [Inline] -> [Inline]
    forall a. a -> [a] -> [a]
    : [Inline] -> [Inline]
    normalizeInlines [Inline]
    xs
      Inline
    Space : Inline
    Linebreak : [Inline]
    xs -> Inline
    Linebreak Inline -> [Inline] -> [Inline]
    forall a. a -> [a] -> [a]
    : [Inline] -> [Inline]
    normalizeInlines [Inline]
    xs
      Inline
    Linebreak : Inline
    Space : [Inline]
    xs -> Inline
    Linebreak Inline -> [Inline] -> [Inline]
    forall a. a -> [a] -> [a]
    : [Inline] -> [Inline]
    normalizeInlines [Inline]
    xs
      Str Text
    s1 : Str Text
    s2 : [Inline]
    xs   -> Text -> Inline
    Str (Text
    s1 Text -> Text -> Text
    `append` Text
    s2) Inline -> [Inline] -> [Inline]
    forall a. a -> [a] -> [a]
    : [Inline] -> [Inline]
    normalizeInlines [Inline]
    xs
      Inline
    x : [Inline]
    xs                 -> Inline
    x Inline -> [Inline] -> [Inline]
    forall a. a -> [a] -> [a]
    : [Inline] -> [Inline]
    normalizeInlines [Inline]
    xs

    -- | Gets the characters used to represent an emoji.
    iconText :: Icon -> Text
    iconText :: Icon -> Text
    iconText = \case
      Icon
    IconSlightlySmiling -> Text
    ":)"
      Icon
    IconFrowning        -> Text
    ":("
      Icon
    IconTongue          -> Text
    ":P"
      Icon
    IconSmiling         -> Text
    ":D"
      Icon
    IconWinking         -> Text
    ";)"
      Icon
    IconThumbsUp        -> Text
    "(y)"
      Icon
    IconThumbsDown      -> Text
    "(n)"
      Icon
    IconInfo            -> Text
    "(i)"
      Icon
    IconCheckmark       -> Text
    "(/)"
      Icon
    IconX               -> Text
    "(x)"
      Icon
    IconAttention       -> Text
    "(!)"
      Icon
    IconPlus            -> Text
    "(+)"
      Icon
    IconMinus           -> Text
    "(-)"
      Icon
    IconQuestionmark    -> Text
    "(?)"
      Icon
    IconOn              -> Text
    "(on)"
      Icon
    IconOff             -> Text
    "(off)"
      Icon
    IconStar            -> Text
    "(*)"
      Icon
    IconStarRed         -> Text
    "(*r)"
      Icon
    IconStarGreen       -> Text
    "(*g)"
      Icon
    IconStarBlue        -> Text
    "(*b)"
      Icon
    IconStarYellow      -> Text
    "(*y)"
      Icon
    IconFlag            -> Text
    "(flag)"
      Icon
    IconFlagOff         -> Text
    "(flagoff)"