{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
module Language.Ltml.AST.Text
( TextTree (..)
, HeadingTextTree
, FootnoteTextTree
, RichTextTree
, TableTextTree
, ParagraphTextTree
, HardLineBreak (..)
, Enumeration (..)
, EnumItem (..)
, SentenceStart (..)
, FootnoteReference (..)
)
where
import Data.Text (Text)
import Data.Text.FromWhitespace (FromWhitespace, fromWhitespace)
import Data.Typography (FontStyle)
import Data.Void (Void)
import Language.Lsd.AST.Type.Enum (EnumFormat)
import Language.Ltml.AST.Label (Label)
import Language.Ltml.AST.Node (Node)
data TextTree lbrk fnref style enum special
= Word Text
| Space
| NonBreakingSpace
| LineBreak lbrk
| Special special
| Reference Label
| Styled style [TextTree lbrk fnref style enum special]
| Enum enum
| fnref
deriving (Int -> TextTree lbrk fnref style enum special -> ShowS
[TextTree lbrk fnref style enum special] -> ShowS
TextTree lbrk fnref style enum special -> String
(Int -> TextTree lbrk fnref style enum special -> ShowS)
-> (TextTree lbrk fnref style enum special -> String)
-> ([TextTree lbrk fnref style enum special] -> ShowS)
-> Show (TextTree lbrk fnref style enum special)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall lbrk fnref style enum special.
(Show lbrk, Show special, Show style, Show enum, Show fnref) =>
Int -> TextTree lbrk fnref style enum special -> ShowS
forall lbrk fnref style enum special.
(Show lbrk, Show special, Show style, Show enum, Show fnref) =>
[TextTree lbrk fnref style enum special] -> ShowS
forall lbrk fnref style enum special.
(Show lbrk, Show special, Show style, Show enum, Show fnref) =>
TextTree lbrk fnref style enum special -> String
$cshowsPrec :: forall lbrk fnref style enum special.
(Show lbrk, Show special, Show style, Show enum, Show fnref) =>
Int -> TextTree lbrk fnref style enum special -> ShowS
showsPrec :: Int -> TextTree lbrk fnref style enum special -> ShowS
$cshow :: forall lbrk fnref style enum special.
(Show lbrk, Show special, Show style, Show enum, Show fnref) =>
TextTree lbrk fnref style enum special -> String
show :: TextTree lbrk fnref style enum special -> String
$cshowList :: forall lbrk fnref style enum special.
(Show lbrk, Show special, Show style, Show enum, Show fnref) =>
[TextTree lbrk fnref style enum special] -> ShowS
showList :: [TextTree lbrk fnref style enum special] -> ShowS
Show)
instance FromWhitespace [TextTree a b c d e] where
fromWhitespace :: Text -> [TextTree a b c d e]
fromWhitespace Text
"" = []
fromWhitespace Text
_ = [TextTree a b c d e
forall lbrk fnref style enum special.
TextTree lbrk fnref style enum special
Space]
type HeadingTextTree = TextTree Void FootnoteReference Void Void Void
type = TextTree HardLineBreak Void FontStyle Void Void
type RichTextTree =
TextTree HardLineBreak FootnoteReference FontStyle Enumeration Void
type TableTextTree =
TextTree HardLineBreak FootnoteReference FontStyle Void Void
type ParagraphTextTree =
TextTree
HardLineBreak
FootnoteReference
FontStyle
Enumeration
SentenceStart
data HardLineBreak = HardLineBreak
deriving (Int -> HardLineBreak -> ShowS
[HardLineBreak] -> ShowS
HardLineBreak -> String
(Int -> HardLineBreak -> ShowS)
-> (HardLineBreak -> String)
-> ([HardLineBreak] -> ShowS)
-> Show HardLineBreak
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HardLineBreak -> ShowS
showsPrec :: Int -> HardLineBreak -> ShowS
$cshow :: HardLineBreak -> String
show :: HardLineBreak -> String
$cshowList :: [HardLineBreak] -> ShowS
showList :: [HardLineBreak] -> ShowS
Show)
data Enumeration = Enumeration EnumFormat [Node EnumItem]
deriving (Int -> Enumeration -> ShowS
[Enumeration] -> ShowS
Enumeration -> String
(Int -> Enumeration -> ShowS)
-> (Enumeration -> String)
-> ([Enumeration] -> ShowS)
-> Show Enumeration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Enumeration -> ShowS
showsPrec :: Int -> Enumeration -> ShowS
$cshow :: Enumeration -> String
show :: Enumeration -> String
$cshowList :: [Enumeration] -> ShowS
showList :: [Enumeration] -> ShowS
Show)
newtype EnumItem = EnumItem [RichTextTree]
deriving (Int -> EnumItem -> ShowS
[EnumItem] -> ShowS
EnumItem -> String
(Int -> EnumItem -> ShowS)
-> (EnumItem -> String) -> ([EnumItem] -> ShowS) -> Show EnumItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EnumItem -> ShowS
showsPrec :: Int -> EnumItem -> ShowS
$cshow :: EnumItem -> String
show :: EnumItem -> String
$cshowList :: [EnumItem] -> ShowS
showList :: [EnumItem] -> ShowS
Show)
newtype SentenceStart = SentenceStart (Maybe Label)
deriving (Int -> SentenceStart -> ShowS
[SentenceStart] -> ShowS
SentenceStart -> String
(Int -> SentenceStart -> ShowS)
-> (SentenceStart -> String)
-> ([SentenceStart] -> ShowS)
-> Show SentenceStart
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SentenceStart -> ShowS
showsPrec :: Int -> SentenceStart -> ShowS
$cshow :: SentenceStart -> String
show :: SentenceStart -> String
$cshowList :: [SentenceStart] -> ShowS
showList :: [SentenceStart] -> ShowS
Show)
newtype = Label
deriving (Int -> FootnoteReference -> ShowS
[FootnoteReference] -> ShowS
FootnoteReference -> String
(Int -> FootnoteReference -> ShowS)
-> (FootnoteReference -> String)
-> ([FootnoteReference] -> ShowS)
-> Show FootnoteReference
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FootnoteReference -> ShowS
showsPrec :: Int -> FootnoteReference -> ShowS
$cshow :: FootnoteReference -> String
show :: FootnoteReference -> String
$cshowList :: [FootnoteReference] -> ShowS
showList :: [FootnoteReference] -> ShowS
Show)