module Nbparts.Types.Sources.Markdown where

import Commonmark
  ( Format,
    HasAttributes,
    IsBlock
      ( blockQuote,
        codeBlock,
        heading,
        list,
        paragraph,
        plain,
        rawBlock,
        referenceLinkDefinition,
        thematicBreak
      ),
    IsInline
      ( code,
        emph,
        entity,
        escapedChar,
        image,
        lineBreak,
        link,
        rawInline,
        softBreak,
        str,
        strong
      ),
    ListSpacing,
    ListType,
    Rangeable (ranged),
    SourceRange,
  )
import Commonmark.Types (HasAttributes (addAttributes))
import Data.Data (Data, Typeable)
import Data.Map (Map)
import Data.Map qualified as Map
import Data.Sequence (Seq)
import Data.Sequence qualified as Seq
import Data.Text (Text)

newtype Inlines = Inlines (Seq Inline)
  deriving (Int -> Inlines -> ShowS
[Inlines] -> ShowS
Inlines -> String
(Int -> Inlines -> ShowS)
-> (Inlines -> String) -> ([Inlines] -> ShowS) -> Show Inlines
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Inlines -> ShowS
showsPrec :: Int -> Inlines -> ShowS
$cshow :: Inlines -> String
show :: Inlines -> String
$cshowList :: [Inlines] -> ShowS
showList :: [Inlines] -> ShowS
Show, NonEmpty Inlines -> Inlines
Inlines -> Inlines -> Inlines
(Inlines -> Inlines -> Inlines)
-> (NonEmpty Inlines -> Inlines)
-> (forall b. Integral b => b -> Inlines -> Inlines)
-> Semigroup Inlines
forall b. Integral b => b -> Inlines -> Inlines
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
$c<> :: Inlines -> Inlines -> Inlines
<> :: Inlines -> Inlines -> Inlines
$csconcat :: NonEmpty Inlines -> Inlines
sconcat :: NonEmpty Inlines -> Inlines
$cstimes :: forall b. Integral b => b -> Inlines -> Inlines
stimes :: forall b. Integral b => b -> Inlines -> Inlines
Semigroup, Semigroup Inlines
Inlines
Semigroup Inlines =>
Inlines
-> (Inlines -> Inlines -> Inlines)
-> ([Inlines] -> Inlines)
-> Monoid Inlines
[Inlines] -> Inlines
Inlines -> Inlines -> Inlines
forall a.
Semigroup a =>
a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
$cmempty :: Inlines
mempty :: Inlines
$cmappend :: Inlines -> Inlines -> Inlines
mappend :: Inlines -> Inlines -> Inlines
$cmconcat :: [Inlines] -> Inlines
mconcat :: [Inlines] -> Inlines
Monoid, Typeable Inlines
Typeable Inlines =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Inlines -> c Inlines)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Inlines)
-> (Inlines -> Constr)
-> (Inlines -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Inlines))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Inlines))
-> ((forall b. Data b => b -> b) -> Inlines -> Inlines)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Inlines -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Inlines -> r)
-> (forall u. (forall d. Data d => d -> u) -> Inlines -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Inlines -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Inlines -> m Inlines)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Inlines -> m Inlines)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Inlines -> m Inlines)
-> Data Inlines
Inlines -> Constr
Inlines -> DataType
(forall b. Data b => b -> b) -> Inlines -> Inlines
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Inlines -> u
forall u. (forall d. Data d => d -> u) -> Inlines -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Inlines -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Inlines -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Inlines -> m Inlines
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Inlines -> m Inlines
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Inlines
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Inlines -> c Inlines
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Inlines)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Inlines)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Inlines -> c Inlines
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Inlines -> c Inlines
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Inlines
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Inlines
$ctoConstr :: Inlines -> Constr
toConstr :: Inlines -> Constr
$cdataTypeOf :: Inlines -> DataType
dataTypeOf :: Inlines -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Inlines)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Inlines)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Inlines)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Inlines)
$cgmapT :: (forall b. Data b => b -> b) -> Inlines -> Inlines
gmapT :: (forall b. Data b => b -> b) -> Inlines -> Inlines
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Inlines -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Inlines -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Inlines -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Inlines -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Inlines -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Inlines -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Inlines -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Inlines -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Inlines -> m Inlines
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Inlines -> m Inlines
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Inlines -> m Inlines
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Inlines -> m Inlines
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Inlines -> m Inlines
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Inlines -> m Inlines
Data, Typeable)

data Inline
  = Inline
  { Inline -> InlineType
inlineType :: InlineType,
    Inline -> SourceRange
sourceRange :: SourceRange,
    Inline -> Map Text Text
attributes :: Map Text Text
  }
  deriving (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, Typeable Inline
Typeable Inline =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Inline -> c Inline)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Inline)
-> (Inline -> Constr)
-> (Inline -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Inline))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Inline))
-> ((forall b. Data b => b -> b) -> Inline -> Inline)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Inline -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Inline -> r)
-> (forall u. (forall d. Data d => d -> u) -> Inline -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Inline -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Inline -> m Inline)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Inline -> m Inline)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Inline -> m Inline)
-> Data Inline
Inline -> Constr
Inline -> DataType
(forall b. Data b => b -> b) -> Inline -> Inline
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Inline -> u
forall u. (forall d. Data d => d -> u) -> Inline -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Inline -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Inline -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Inline -> m Inline
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Inline -> m Inline
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Inline
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Inline -> c Inline
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Inline)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Inline)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Inline -> c Inline
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Inline -> c Inline
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Inline
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Inline
$ctoConstr :: Inline -> Constr
toConstr :: Inline -> Constr
$cdataTypeOf :: Inline -> DataType
dataTypeOf :: Inline -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Inline)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Inline)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Inline)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Inline)
$cgmapT :: (forall b. Data b => b -> b) -> Inline -> Inline
gmapT :: (forall b. Data b => b -> b) -> Inline -> Inline
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Inline -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Inline -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Inline -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Inline -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Inline -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Inline -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Inline -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Inline -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Inline -> m Inline
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Inline -> m Inline
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Inline -> m Inline
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Inline -> m Inline
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Inline -> m Inline
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Inline -> m Inline
Data, Typeable)

data InlineType
  = Code Text
  | Emph Inlines
  | Entity Text
  | EscapedChar Char
  | Image Text Text Inlines
  | LineBreak
  | Link Text Text Inlines
  | RawInline Format Text
  | SoftBreak
  | Str Text
  | Strong Inlines
  deriving (Int -> InlineType -> ShowS
[InlineType] -> ShowS
InlineType -> String
(Int -> InlineType -> ShowS)
-> (InlineType -> String)
-> ([InlineType] -> ShowS)
-> Show InlineType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> InlineType -> ShowS
showsPrec :: Int -> InlineType -> ShowS
$cshow :: InlineType -> String
show :: InlineType -> String
$cshowList :: [InlineType] -> ShowS
showList :: [InlineType] -> ShowS
Show, Typeable InlineType
Typeable InlineType =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> InlineType -> c InlineType)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c InlineType)
-> (InlineType -> Constr)
-> (InlineType -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c InlineType))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c InlineType))
-> ((forall b. Data b => b -> b) -> InlineType -> InlineType)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> InlineType -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> InlineType -> r)
-> (forall u. (forall d. Data d => d -> u) -> InlineType -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> InlineType -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> InlineType -> m InlineType)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> InlineType -> m InlineType)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> InlineType -> m InlineType)
-> Data InlineType
InlineType -> Constr
InlineType -> DataType
(forall b. Data b => b -> b) -> InlineType -> InlineType
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> InlineType -> u
forall u. (forall d. Data d => d -> u) -> InlineType -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> InlineType -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> InlineType -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> InlineType -> m InlineType
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> InlineType -> m InlineType
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c InlineType
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> InlineType -> c InlineType
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c InlineType)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c InlineType)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> InlineType -> c InlineType
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> InlineType -> c InlineType
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c InlineType
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c InlineType
$ctoConstr :: InlineType -> Constr
toConstr :: InlineType -> Constr
$cdataTypeOf :: InlineType -> DataType
dataTypeOf :: InlineType -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c InlineType)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c InlineType)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c InlineType)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c InlineType)
$cgmapT :: (forall b. Data b => b -> b) -> InlineType -> InlineType
gmapT :: (forall b. Data b => b -> b) -> InlineType -> InlineType
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> InlineType -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> InlineType -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> InlineType -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> InlineType -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> InlineType -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> InlineType -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> InlineType -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> InlineType -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> InlineType -> m InlineType
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> InlineType -> m InlineType
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> InlineType -> m InlineType
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> InlineType -> m InlineType
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> InlineType -> m InlineType
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> InlineType -> m InlineType
Data, Typeable)

singletonInlines :: InlineType -> Inlines
singletonInlines :: InlineType -> Inlines
singletonInlines = Seq Inline -> Inlines
Inlines (Seq Inline -> Inlines)
-> (InlineType -> Seq Inline) -> InlineType -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Inline -> Seq Inline
forall a. a -> Seq a
Seq.singleton (Inline -> Seq Inline)
-> (InlineType -> Inline) -> InlineType -> Seq Inline
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InlineType -> Inline
mkInline

mkInline :: InlineType -> Inline
mkInline :: InlineType -> Inline
mkInline InlineType
ilType = InlineType -> SourceRange -> Map Text Text -> Inline
Inline InlineType
ilType SourceRange
forall a. Monoid a => a
mempty Map Text Text
forall a. Monoid a => a
mempty

instance Rangeable Inlines where
  ranged :: SourceRange -> Inlines -> Inlines
ranged SourceRange
srcRange' (Inlines Seq Inline
ils) =
    Seq Inline -> Inlines
Inlines (Seq Inline -> Inlines) -> Seq Inline -> Inlines
forall a b. (a -> b) -> a -> b
$
      (Inline -> Inline) -> Seq Inline -> Seq Inline
forall a b. (a -> b) -> Seq a -> Seq b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
        (\(Inline InlineType
ilType SourceRange
srcRange Map Text Text
attrs) -> InlineType -> SourceRange -> Map Text Text -> Inline
Inline InlineType
ilType (SourceRange
srcRange SourceRange -> SourceRange -> SourceRange
forall a. Semigroup a => a -> a -> a
<> SourceRange
srcRange') Map Text Text
attrs)
        Seq Inline
ils

instance HasAttributes Inlines where
  addAttributes :: Attributes -> Inlines -> Inlines
addAttributes Attributes
attrs (Inlines Seq Inline
ils) =
    Seq Inline -> Inlines
Inlines (Seq Inline -> Inlines) -> Seq Inline -> Inlines
forall a b. (a -> b) -> a -> b
$
      (Inline -> Inline) -> Seq Inline -> Seq Inline
forall a b. (a -> b) -> Seq a -> Seq b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
        (\(Inline InlineType
ilType SourceRange
srcRange Map Text Text
ilAttrs) -> InlineType -> SourceRange -> Map Text Text -> Inline
Inline InlineType
ilType SourceRange
srcRange (Map Text Text -> Inline) -> Map Text Text -> Inline
forall a b. (a -> b) -> a -> b
$ Map Text Text
ilAttrs Map Text Text -> Map Text Text -> Map Text Text
forall a. Semigroup a => a -> a -> a
<> Attributes -> Map Text Text
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList Attributes
attrs)
        Seq Inline
ils

instance IsInline Inlines where
  lineBreak :: Inlines
lineBreak = InlineType -> Inlines
singletonInlines InlineType
LineBreak
  softBreak :: Inlines
softBreak = InlineType -> Inlines
singletonInlines InlineType
SoftBreak
  str :: Text -> Inlines
str = InlineType -> Inlines
singletonInlines (InlineType -> Inlines) -> (Text -> InlineType) -> Text -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> InlineType
Str
  entity :: Text -> Inlines
entity = InlineType -> Inlines
singletonInlines (InlineType -> Inlines) -> (Text -> InlineType) -> Text -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> InlineType
Entity
  escapedChar :: Char -> Inlines
escapedChar = InlineType -> Inlines
singletonInlines (InlineType -> Inlines) -> (Char -> InlineType) -> Char -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> InlineType
EscapedChar
  emph :: Inlines -> Inlines
emph = InlineType -> Inlines
singletonInlines (InlineType -> Inlines)
-> (Inlines -> InlineType) -> Inlines -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Inlines -> InlineType
Emph
  strong :: Inlines -> Inlines
strong = InlineType -> Inlines
singletonInlines (InlineType -> Inlines)
-> (Inlines -> InlineType) -> Inlines -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Inlines -> InlineType
Strong
  link :: Text -> Text -> Inlines -> Inlines
link Text
target Text
title Inlines
ils = InlineType -> Inlines
singletonInlines (InlineType -> Inlines) -> InlineType -> Inlines
forall a b. (a -> b) -> a -> b
$ Text -> Text -> Inlines -> InlineType
Link Text
target Text
title Inlines
ils
  image :: Text -> Text -> Inlines -> Inlines
image Text
target Text
title Inlines
ils = InlineType -> Inlines
singletonInlines (InlineType -> Inlines) -> InlineType -> Inlines
forall a b. (a -> b) -> a -> b
$ Text -> Text -> Inlines -> InlineType
Image Text
target Text
title Inlines
ils
  code :: Text -> Inlines
code = InlineType -> Inlines
singletonInlines (InlineType -> Inlines) -> (Text -> InlineType) -> Text -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> InlineType
Code
  rawInline :: Format -> Text -> Inlines
rawInline Format
format Text
txt = InlineType -> Inlines
singletonInlines (InlineType -> Inlines) -> InlineType -> Inlines
forall a b. (a -> b) -> a -> b
$ Format -> Text -> InlineType
RawInline Format
format Text
txt

newtype Blocks = Blocks (Seq Block)
  deriving (Int -> Blocks -> ShowS
[Blocks] -> ShowS
Blocks -> String
(Int -> Blocks -> ShowS)
-> (Blocks -> String) -> ([Blocks] -> ShowS) -> Show Blocks
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Blocks -> ShowS
showsPrec :: Int -> Blocks -> ShowS
$cshow :: Blocks -> String
show :: Blocks -> String
$cshowList :: [Blocks] -> ShowS
showList :: [Blocks] -> ShowS
Show, NonEmpty Blocks -> Blocks
Blocks -> Blocks -> Blocks
(Blocks -> Blocks -> Blocks)
-> (NonEmpty Blocks -> Blocks)
-> (forall b. Integral b => b -> Blocks -> Blocks)
-> Semigroup Blocks
forall b. Integral b => b -> Blocks -> Blocks
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
$c<> :: Blocks -> Blocks -> Blocks
<> :: Blocks -> Blocks -> Blocks
$csconcat :: NonEmpty Blocks -> Blocks
sconcat :: NonEmpty Blocks -> Blocks
$cstimes :: forall b. Integral b => b -> Blocks -> Blocks
stimes :: forall b. Integral b => b -> Blocks -> Blocks
Semigroup, Semigroup Blocks
Blocks
Semigroup Blocks =>
Blocks
-> (Blocks -> Blocks -> Blocks)
-> ([Blocks] -> Blocks)
-> Monoid Blocks
[Blocks] -> Blocks
Blocks -> Blocks -> Blocks
forall a.
Semigroup a =>
a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
$cmempty :: Blocks
mempty :: Blocks
$cmappend :: Blocks -> Blocks -> Blocks
mappend :: Blocks -> Blocks -> Blocks
$cmconcat :: [Blocks] -> Blocks
mconcat :: [Blocks] -> Blocks
Monoid, Typeable Blocks
Typeable Blocks =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Blocks -> c Blocks)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Blocks)
-> (Blocks -> Constr)
-> (Blocks -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Blocks))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Blocks))
-> ((forall b. Data b => b -> b) -> Blocks -> Blocks)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Blocks -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Blocks -> r)
-> (forall u. (forall d. Data d => d -> u) -> Blocks -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Blocks -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Blocks -> m Blocks)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Blocks -> m Blocks)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Blocks -> m Blocks)
-> Data Blocks
Blocks -> Constr
Blocks -> DataType
(forall b. Data b => b -> b) -> Blocks -> Blocks
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Blocks -> u
forall u. (forall d. Data d => d -> u) -> Blocks -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Blocks -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Blocks -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Blocks -> m Blocks
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Blocks -> m Blocks
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Blocks
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Blocks -> c Blocks
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Blocks)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Blocks)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Blocks -> c Blocks
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Blocks -> c Blocks
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Blocks
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Blocks
$ctoConstr :: Blocks -> Constr
toConstr :: Blocks -> Constr
$cdataTypeOf :: Blocks -> DataType
dataTypeOf :: Blocks -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Blocks)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Blocks)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Blocks)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Blocks)
$cgmapT :: (forall b. Data b => b -> b) -> Blocks -> Blocks
gmapT :: (forall b. Data b => b -> b) -> Blocks -> Blocks
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Blocks -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Blocks -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Blocks -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Blocks -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Blocks -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Blocks -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Blocks -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Blocks -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Blocks -> m Blocks
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Blocks -> m Blocks
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Blocks -> m Blocks
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Blocks -> m Blocks
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Blocks -> m Blocks
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Blocks -> m Blocks
Data, Typeable)

data Block = Block
  { Block -> BlockType
blockType :: BlockType,
    Block -> SourceRange
sourceRange :: SourceRange,
    Block -> Map Text Text
attributes :: Map Text Text
  }
  deriving (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, Typeable Block
Typeable Block =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Block -> c Block)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Block)
-> (Block -> Constr)
-> (Block -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Block))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Block))
-> ((forall b. Data b => b -> b) -> Block -> Block)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Block -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Block -> r)
-> (forall u. (forall d. Data d => d -> u) -> Block -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Block -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Block -> m Block)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Block -> m Block)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Block -> m Block)
-> Data Block
Block -> Constr
Block -> DataType
(forall b. Data b => b -> b) -> Block -> Block
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Block -> u
forall u. (forall d. Data d => d -> u) -> Block -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Block -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Block -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Block -> m Block
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Block -> m Block
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Block
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Block -> c Block
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Block)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Block)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Block -> c Block
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Block -> c Block
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Block
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Block
$ctoConstr :: Block -> Constr
toConstr :: Block -> Constr
$cdataTypeOf :: Block -> DataType
dataTypeOf :: Block -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Block)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Block)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Block)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Block)
$cgmapT :: (forall b. Data b => b -> b) -> Block -> Block
gmapT :: (forall b. Data b => b -> b) -> Block -> Block
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Block -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Block -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Block -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Block -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Block -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Block -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Block -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Block -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Block -> m Block
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Block -> m Block
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Block -> m Block
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Block -> m Block
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Block -> m Block
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Block -> m Block
Data, Typeable)

data BlockType
  = Paragraph Inlines
  | Plain Inlines
  | ThematicBreak
  | BlockQuote Blocks
  | CodeBlock Text Text
  | Heading Int Inlines
  | RawBlock Format Text
  | ReferenceLinkDefinition Text (Text, Text)
  | List ListType ListSpacing Blocks
  deriving (Int -> BlockType -> ShowS
[BlockType] -> ShowS
BlockType -> String
(Int -> BlockType -> ShowS)
-> (BlockType -> String)
-> ([BlockType] -> ShowS)
-> Show BlockType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BlockType -> ShowS
showsPrec :: Int -> BlockType -> ShowS
$cshow :: BlockType -> String
show :: BlockType -> String
$cshowList :: [BlockType] -> ShowS
showList :: [BlockType] -> ShowS
Show, Typeable BlockType
Typeable BlockType =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> BlockType -> c BlockType)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c BlockType)
-> (BlockType -> Constr)
-> (BlockType -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c BlockType))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BlockType))
-> ((forall b. Data b => b -> b) -> BlockType -> BlockType)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> BlockType -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> BlockType -> r)
-> (forall u. (forall d. Data d => d -> u) -> BlockType -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> BlockType -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> BlockType -> m BlockType)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> BlockType -> m BlockType)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> BlockType -> m BlockType)
-> Data BlockType
BlockType -> Constr
BlockType -> DataType
(forall b. Data b => b -> b) -> BlockType -> BlockType
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> BlockType -> u
forall u. (forall d. Data d => d -> u) -> BlockType -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BlockType -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BlockType -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BlockType -> m BlockType
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BlockType -> m BlockType
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BlockType
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BlockType -> c BlockType
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BlockType)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BlockType)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BlockType -> c BlockType
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BlockType -> c BlockType
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BlockType
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BlockType
$ctoConstr :: BlockType -> Constr
toConstr :: BlockType -> Constr
$cdataTypeOf :: BlockType -> DataType
dataTypeOf :: BlockType -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BlockType)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BlockType)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BlockType)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BlockType)
$cgmapT :: (forall b. Data b => b -> b) -> BlockType -> BlockType
gmapT :: (forall b. Data b => b -> b) -> BlockType -> BlockType
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BlockType -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BlockType -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BlockType -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BlockType -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> BlockType -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> BlockType -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BlockType -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BlockType -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BlockType -> m BlockType
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BlockType -> m BlockType
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BlockType -> m BlockType
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BlockType -> m BlockType
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BlockType -> m BlockType
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BlockType -> m BlockType
Data, Typeable)

singletonBlocks :: BlockType -> Blocks
singletonBlocks :: BlockType -> Blocks
singletonBlocks = Seq Block -> Blocks
Blocks (Seq Block -> Blocks)
-> (BlockType -> Seq Block) -> BlockType -> Blocks
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Block -> Seq Block
forall a. a -> Seq a
Seq.singleton (Block -> Seq Block)
-> (BlockType -> Block) -> BlockType -> Seq Block
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BlockType -> Block
mkBlock

mkBlock :: BlockType -> Block
mkBlock :: BlockType -> Block
mkBlock BlockType
blockType = BlockType -> SourceRange -> Map Text Text -> Block
Block BlockType
blockType SourceRange
forall a. Monoid a => a
mempty Map Text Text
forall a. Monoid a => a
mempty

instance Rangeable Blocks where
  ranged :: SourceRange -> Blocks -> Blocks
ranged SourceRange
srcRange' (Blocks Seq Block
blks) =
    Seq Block -> Blocks
Blocks (Seq Block -> Blocks) -> Seq Block -> Blocks
forall a b. (a -> b) -> a -> b
$
      (Block -> Block) -> Seq Block -> Seq Block
forall a b. (a -> b) -> Seq a -> Seq b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
        (\(Block BlockType
blkType SourceRange
srcRange Map Text Text
attrs) -> BlockType -> SourceRange -> Map Text Text -> Block
Block BlockType
blkType (SourceRange
srcRange SourceRange -> SourceRange -> SourceRange
forall a. Semigroup a => a -> a -> a
<> SourceRange
srcRange') Map Text Text
attrs)
        Seq Block
blks

instance HasAttributes Blocks where
  addAttributes :: Attributes -> Blocks -> Blocks
addAttributes Attributes
attrs (Blocks Seq Block
blks) =
    Seq Block -> Blocks
Blocks (Seq Block -> Blocks) -> Seq Block -> Blocks
forall a b. (a -> b) -> a -> b
$
      (Block -> Block) -> Seq Block -> Seq Block
forall a b. (a -> b) -> Seq a -> Seq b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
        (\(Block BlockType
blkType SourceRange
srcRange Map Text Text
blkAttrs) -> BlockType -> SourceRange -> Map Text Text -> Block
Block BlockType
blkType SourceRange
srcRange (Map Text Text -> Block) -> Map Text Text -> Block
forall a b. (a -> b) -> a -> b
$ Map Text Text
blkAttrs Map Text Text -> Map Text Text -> Map Text Text
forall a. Semigroup a => a -> a -> a
<> Attributes -> Map Text Text
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList Attributes
attrs)
        Seq Block
blks

instance IsBlock Inlines Blocks where
  paragraph :: Inlines -> Blocks
paragraph = BlockType -> Blocks
singletonBlocks (BlockType -> Blocks)
-> (Inlines -> BlockType) -> Inlines -> Blocks
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Inlines -> BlockType
Paragraph
  plain :: Inlines -> Blocks
plain = BlockType -> Blocks
singletonBlocks (BlockType -> Blocks)
-> (Inlines -> BlockType) -> Inlines -> Blocks
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Inlines -> BlockType
Plain
  thematicBreak :: Blocks
thematicBreak = BlockType -> Blocks
singletonBlocks BlockType
ThematicBreak
  blockQuote :: Blocks -> Blocks
blockQuote = BlockType -> Blocks
singletonBlocks (BlockType -> Blocks) -> (Blocks -> BlockType) -> Blocks -> Blocks
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Blocks -> BlockType
BlockQuote
  codeBlock :: Text -> Text -> Blocks
codeBlock Text
info Text
txt = BlockType -> Blocks
singletonBlocks (BlockType -> Blocks) -> BlockType -> Blocks
forall a b. (a -> b) -> a -> b
$ Text -> Text -> BlockType
CodeBlock Text
info Text
txt
  heading :: Int -> Inlines -> Blocks
heading Int
level Inlines
ils = BlockType -> Blocks
singletonBlocks (BlockType -> Blocks) -> BlockType -> Blocks
forall a b. (a -> b) -> a -> b
$ Int -> Inlines -> BlockType
Heading Int
level Inlines
ils
  rawBlock :: Format -> Text -> Blocks
rawBlock Format
format Text
txt = BlockType -> Blocks
singletonBlocks (BlockType -> Blocks) -> BlockType -> Blocks
forall a b. (a -> b) -> a -> b
$ Format -> Text -> BlockType
RawBlock Format
format Text
txt
  referenceLinkDefinition :: Text -> (Text, Text) -> Blocks
referenceLinkDefinition Text
label (Text
dest, Text
title) = BlockType -> Blocks
singletonBlocks (BlockType -> Blocks) -> BlockType -> Blocks
forall a b. (a -> b) -> a -> b
$ Text -> (Text, Text) -> BlockType
ReferenceLinkDefinition Text
label (Text
dest, Text
title)
  list :: ListType -> ListSpacing -> [Blocks] -> Blocks
list ListType
listType ListSpacing
listSpacing [Blocks]
blks = BlockType -> Blocks
singletonBlocks (BlockType -> Blocks) -> BlockType -> Blocks
forall a b. (a -> b) -> a -> b
$ ListType -> ListSpacing -> Blocks -> BlockType
List ListType
listType ListSpacing
listSpacing ([Blocks] -> Blocks
forall a. Monoid a => [a] -> a
mconcat [Blocks]
blks)