{-# LANGUAGE OverloadedStrings #-}
module Drasil.Data.Formats.HTML.Core
(
HTML(..), HTMLBody(..), HTMLHead(..), TagType(..), CustomTag(..), Attr(..),
Format(..), HLevel(..), Row(..), Cell(..), LItem(..), DItem(..), ListType(..),
attr, id_, class_, rawText, rawText', customTag,
bold, bold_, emphasis, emphasis_, subscript, subscript_, superscript, superscript_,
span, span_, toHLevel, figureImage, inlineScript, externalScript, stylesheet
)
where
import Data.Char (isAsciiLower, isAsciiUpper, isDigit)
import Data.String (IsString(..))
import Data.Text (Text)
import qualified Data.Text as T
import Prelude hiding (span)
data Attr = Attr
Text
Text
deriving (Int -> Attr -> ShowS
[Attr] -> ShowS
Attr -> [Char]
(Int -> Attr -> ShowS)
-> (Attr -> [Char]) -> ([Attr] -> ShowS) -> Show Attr
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Attr -> ShowS
showsPrec :: Int -> Attr -> ShowS
$cshow :: Attr -> [Char]
show :: Attr -> [Char]
$cshowList :: [Attr] -> ShowS
showList :: [Attr] -> ShowS
Show, Attr -> Attr -> Bool
(Attr -> Attr -> Bool) -> (Attr -> Attr -> Bool) -> Eq Attr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Attr -> Attr -> Bool
== :: Attr -> Attr -> Bool
$c/= :: Attr -> Attr -> Bool
/= :: Attr -> Attr -> Bool
Eq)
data HTML = HTML [HTMLHead] [HTMLBody]
deriving (Int -> HTML -> ShowS
[HTML] -> ShowS
HTML -> [Char]
(Int -> HTML -> ShowS)
-> (HTML -> [Char]) -> ([HTML] -> ShowS) -> Show HTML
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HTML -> ShowS
showsPrec :: Int -> HTML -> ShowS
$cshow :: HTML -> [Char]
show :: HTML -> [Char]
$cshowList :: [HTML] -> ShowS
showList :: [HTML] -> ShowS
Show, HTML -> HTML -> Bool
(HTML -> HTML -> Bool) -> (HTML -> HTML -> Bool) -> Eq HTML
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HTML -> HTML -> Bool
== :: HTML -> HTML -> Bool
$c/= :: HTML -> HTML -> Bool
/= :: HTML -> HTML -> Bool
Eq)
data HTMLHead
= Script [Attr] Text
| Title Text
| Meta [Attr]
| Link Relation File [Attr]
deriving (Int -> HTMLHead -> ShowS
[HTMLHead] -> ShowS
HTMLHead -> [Char]
(Int -> HTMLHead -> ShowS)
-> (HTMLHead -> [Char]) -> ([HTMLHead] -> ShowS) -> Show HTMLHead
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HTMLHead -> ShowS
showsPrec :: Int -> HTMLHead -> ShowS
$cshow :: HTMLHead -> [Char]
show :: HTMLHead -> [Char]
$cshowList :: [HTMLHead] -> ShowS
showList :: [HTMLHead] -> ShowS
Show, HTMLHead -> HTMLHead -> Bool
(HTMLHead -> HTMLHead -> Bool)
-> (HTMLHead -> HTMLHead -> Bool) -> Eq HTMLHead
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HTMLHead -> HTMLHead -> Bool
== :: HTMLHead -> HTMLHead -> Bool
$c/= :: HTMLHead -> HTMLHead -> Bool
/= :: HTMLHead -> HTMLHead -> Bool
Eq)
data HTMLBody
= Div [Attr] [HTMLBody]
| Paragraph [Attr] [HTMLBody]
| TextFormat Format [Attr] [HTMLBody]
| Heading HLevel [Attr] [HTMLBody]
| List ListType [Attr] [LItem]
| Section [Attr] [HTMLBody]
| Table [Attr] [Row]
| DescriptionList [Attr] [DItem]
| Anchor URL [Attr] [HTMLBody]
| Figure [Attr] [HTMLBody]
| FigCaption [Attr] [HTMLBody]
| Img File Text [Attr]
| RawText Text
| Custom CustomTag [Attr] [HTMLBody]
| Text
deriving (Int -> HTMLBody -> ShowS
[HTMLBody] -> ShowS
HTMLBody -> [Char]
(Int -> HTMLBody -> ShowS)
-> (HTMLBody -> [Char]) -> ([HTMLBody] -> ShowS) -> Show HTMLBody
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HTMLBody -> ShowS
showsPrec :: Int -> HTMLBody -> ShowS
$cshow :: HTMLBody -> [Char]
show :: HTMLBody -> [Char]
$cshowList :: [HTMLBody] -> ShowS
showList :: [HTMLBody] -> ShowS
Show, HTMLBody -> HTMLBody -> Bool
(HTMLBody -> HTMLBody -> Bool)
-> (HTMLBody -> HTMLBody -> Bool) -> Eq HTMLBody
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HTMLBody -> HTMLBody -> Bool
== :: HTMLBody -> HTMLBody -> Bool
$c/= :: HTMLBody -> HTMLBody -> Bool
/= :: HTMLBody -> HTMLBody -> Bool
Eq)
instance IsString HTMLBody where
fromString :: [Char] -> HTMLBody
fromString = Text -> HTMLBody
RawText (Text -> HTMLBody) -> ([Char] -> Text) -> [Char] -> HTMLBody
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> Text
T.pack
type Relation = Text
type URL = Text
type File = Text
data Format = Bold | Emphasis | Subscript | Superscript | Span
deriving (Int -> Format -> ShowS
[Format] -> ShowS
Format -> [Char]
(Int -> Format -> ShowS)
-> (Format -> [Char]) -> ([Format] -> ShowS) -> Show Format
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Format -> ShowS
showsPrec :: Int -> Format -> ShowS
$cshow :: Format -> [Char]
show :: Format -> [Char]
$cshowList :: [Format] -> ShowS
showList :: [Format] -> ShowS
Show, Format -> Format -> Bool
(Format -> Format -> Bool)
-> (Format -> Format -> Bool) -> Eq Format
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Format -> Format -> Bool
== :: Format -> Format -> Bool
$c/= :: Format -> Format -> Bool
/= :: Format -> Format -> Bool
Eq)
data HLevel = H1 | H2 | H3 | H4 | H5 | H6
deriving (Int -> HLevel -> ShowS
[HLevel] -> ShowS
HLevel -> [Char]
(Int -> HLevel -> ShowS)
-> (HLevel -> [Char]) -> ([HLevel] -> ShowS) -> Show HLevel
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HLevel -> ShowS
showsPrec :: Int -> HLevel -> ShowS
$cshow :: HLevel -> [Char]
show :: HLevel -> [Char]
$cshowList :: [HLevel] -> ShowS
showList :: [HLevel] -> ShowS
Show, HLevel -> HLevel -> Bool
(HLevel -> HLevel -> Bool)
-> (HLevel -> HLevel -> Bool) -> Eq HLevel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HLevel -> HLevel -> Bool
== :: HLevel -> HLevel -> Bool
$c/= :: HLevel -> HLevel -> Bool
/= :: HLevel -> HLevel -> Bool
Eq, Int -> HLevel
HLevel -> Int
HLevel -> [HLevel]
HLevel -> HLevel
HLevel -> HLevel -> [HLevel]
HLevel -> HLevel -> HLevel -> [HLevel]
(HLevel -> HLevel)
-> (HLevel -> HLevel)
-> (Int -> HLevel)
-> (HLevel -> Int)
-> (HLevel -> [HLevel])
-> (HLevel -> HLevel -> [HLevel])
-> (HLevel -> HLevel -> [HLevel])
-> (HLevel -> HLevel -> HLevel -> [HLevel])
-> Enum HLevel
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 :: HLevel -> HLevel
succ :: HLevel -> HLevel
$cpred :: HLevel -> HLevel
pred :: HLevel -> HLevel
$ctoEnum :: Int -> HLevel
toEnum :: Int -> HLevel
$cfromEnum :: HLevel -> Int
fromEnum :: HLevel -> Int
$cenumFrom :: HLevel -> [HLevel]
enumFrom :: HLevel -> [HLevel]
$cenumFromThen :: HLevel -> HLevel -> [HLevel]
enumFromThen :: HLevel -> HLevel -> [HLevel]
$cenumFromTo :: HLevel -> HLevel -> [HLevel]
enumFromTo :: HLevel -> HLevel -> [HLevel]
$cenumFromThenTo :: HLevel -> HLevel -> HLevel -> [HLevel]
enumFromThenTo :: HLevel -> HLevel -> HLevel -> [HLevel]
Enum, HLevel
HLevel -> HLevel -> Bounded HLevel
forall a. a -> a -> Bounded a
$cminBound :: HLevel
minBound :: HLevel
$cmaxBound :: HLevel
maxBound :: HLevel
Bounded)
toHLevel :: Int -> HLevel
toHLevel :: Int -> HLevel
toHLevel Int
0 = HLevel
H1
toHLevel Int
1 = HLevel
H2
toHLevel Int
2 = HLevel
H3
toHLevel Int
3 = HLevel
H4
toHLevel Int
4 = HLevel
H5
toHLevel Int
_ = HLevel
H6
data ListType = Ordered | Unordered
deriving (Int -> ListType -> ShowS
[ListType] -> ShowS
ListType -> [Char]
(Int -> ListType -> ShowS)
-> (ListType -> [Char]) -> ([ListType] -> ShowS) -> Show ListType
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ListType -> ShowS
showsPrec :: Int -> ListType -> ShowS
$cshow :: ListType -> [Char]
show :: ListType -> [Char]
$cshowList :: [ListType] -> ShowS
showList :: [ListType] -> ShowS
Show, ListType -> ListType -> Bool
(ListType -> ListType -> Bool)
-> (ListType -> ListType -> Bool) -> Eq ListType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ListType -> ListType -> Bool
== :: ListType -> ListType -> Bool
$c/= :: ListType -> ListType -> Bool
/= :: ListType -> ListType -> Bool
Eq)
data LItem = LItem [Attr] [HTMLBody]
deriving (Int -> LItem -> ShowS
[LItem] -> ShowS
LItem -> [Char]
(Int -> LItem -> ShowS)
-> (LItem -> [Char]) -> ([LItem] -> ShowS) -> Show LItem
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LItem -> ShowS
showsPrec :: Int -> LItem -> ShowS
$cshow :: LItem -> [Char]
show :: LItem -> [Char]
$cshowList :: [LItem] -> ShowS
showList :: [LItem] -> ShowS
Show, LItem -> LItem -> Bool
(LItem -> LItem -> Bool) -> (LItem -> LItem -> Bool) -> Eq LItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LItem -> LItem -> Bool
== :: LItem -> LItem -> Bool
$c/= :: LItem -> LItem -> Bool
/= :: LItem -> LItem -> Bool
Eq)
data DItem
= DTerm [Attr] [HTMLBody]
| DDetails [Attr] [HTMLBody]
deriving (Int -> DItem -> ShowS
[DItem] -> ShowS
DItem -> [Char]
(Int -> DItem -> ShowS)
-> (DItem -> [Char]) -> ([DItem] -> ShowS) -> Show DItem
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DItem -> ShowS
showsPrec :: Int -> DItem -> ShowS
$cshow :: DItem -> [Char]
show :: DItem -> [Char]
$cshowList :: [DItem] -> ShowS
showList :: [DItem] -> ShowS
Show, DItem -> DItem -> Bool
(DItem -> DItem -> Bool) -> (DItem -> DItem -> Bool) -> Eq DItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DItem -> DItem -> Bool
== :: DItem -> DItem -> Bool
$c/= :: DItem -> DItem -> Bool
/= :: DItem -> DItem -> Bool
Eq)
data Row = Row [Attr] [Cell]
deriving (Int -> Row -> ShowS
[Row] -> ShowS
Row -> [Char]
(Int -> Row -> ShowS)
-> (Row -> [Char]) -> ([Row] -> ShowS) -> Show Row
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Row -> ShowS
showsPrec :: Int -> Row -> ShowS
$cshow :: Row -> [Char]
show :: Row -> [Char]
$cshowList :: [Row] -> ShowS
showList :: [Row] -> ShowS
Show, 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)
data Cell
= [Attr] [HTMLBody]
| TData [Attr] [HTMLBody]
deriving (Int -> Cell -> ShowS
[Cell] -> ShowS
Cell -> [Char]
(Int -> Cell -> ShowS)
-> (Cell -> [Char]) -> ([Cell] -> ShowS) -> Show Cell
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Cell -> ShowS
showsPrec :: Int -> Cell -> ShowS
$cshow :: Cell -> [Char]
show :: Cell -> [Char]
$cshowList :: [Cell] -> ShowS
showList :: [Cell] -> ShowS
Show, 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)
newtype CustomTag = CT Text
deriving (Int -> CustomTag -> ShowS
[CustomTag] -> ShowS
CustomTag -> [Char]
(Int -> CustomTag -> ShowS)
-> (CustomTag -> [Char])
-> ([CustomTag] -> ShowS)
-> Show CustomTag
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CustomTag -> ShowS
showsPrec :: Int -> CustomTag -> ShowS
$cshow :: CustomTag -> [Char]
show :: CustomTag -> [Char]
$cshowList :: [CustomTag] -> ShowS
showList :: [CustomTag] -> ShowS
Show, CustomTag -> CustomTag -> Bool
(CustomTag -> CustomTag -> Bool)
-> (CustomTag -> CustomTag -> Bool) -> Eq CustomTag
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CustomTag -> CustomTag -> Bool
== :: CustomTag -> CustomTag -> Bool
$c/= :: CustomTag -> CustomTag -> Bool
/= :: CustomTag -> CustomTag -> Bool
Eq, Eq CustomTag
Eq CustomTag =>
(CustomTag -> CustomTag -> Ordering)
-> (CustomTag -> CustomTag -> Bool)
-> (CustomTag -> CustomTag -> Bool)
-> (CustomTag -> CustomTag -> Bool)
-> (CustomTag -> CustomTag -> Bool)
-> (CustomTag -> CustomTag -> CustomTag)
-> (CustomTag -> CustomTag -> CustomTag)
-> Ord CustomTag
CustomTag -> CustomTag -> Bool
CustomTag -> CustomTag -> Ordering
CustomTag -> CustomTag -> CustomTag
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 :: CustomTag -> CustomTag -> Ordering
compare :: CustomTag -> CustomTag -> Ordering
$c< :: CustomTag -> CustomTag -> Bool
< :: CustomTag -> CustomTag -> Bool
$c<= :: CustomTag -> CustomTag -> Bool
<= :: CustomTag -> CustomTag -> Bool
$c> :: CustomTag -> CustomTag -> Bool
> :: CustomTag -> CustomTag -> Bool
$c>= :: CustomTag -> CustomTag -> Bool
>= :: CustomTag -> CustomTag -> Bool
$cmax :: CustomTag -> CustomTag -> CustomTag
max :: CustomTag -> CustomTag -> CustomTag
$cmin :: CustomTag -> CustomTag -> CustomTag
min :: CustomTag -> CustomTag -> CustomTag
Ord)
data TagType = Standard | Void
deriving (Int -> TagType -> ShowS
[TagType] -> ShowS
TagType -> [Char]
(Int -> TagType -> ShowS)
-> (TagType -> [Char]) -> ([TagType] -> ShowS) -> Show TagType
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TagType -> ShowS
showsPrec :: Int -> TagType -> ShowS
$cshow :: TagType -> [Char]
show :: TagType -> [Char]
$cshowList :: [TagType] -> ShowS
showList :: [TagType] -> ShowS
Show, TagType -> TagType -> Bool
(TagType -> TagType -> Bool)
-> (TagType -> TagType -> Bool) -> Eq TagType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TagType -> TagType -> Bool
== :: TagType -> TagType -> Bool
$c/= :: TagType -> TagType -> Bool
/= :: TagType -> TagType -> Bool
Eq)
customTag :: Text -> CustomTag
customTag :: Text -> CustomTag
customTag Text
t
| Text -> Bool
isSanitary Text
t = Text -> CustomTag
CT Text
t
| Bool
otherwise = [Char] -> CustomTag
forall a. HasCallStack => [Char] -> a
error ([Char] -> CustomTag) -> [Char] -> CustomTag
forall a b. (a -> b) -> a -> b
$ [Char]
"Bad custom tag name: " [Char] -> ShowS
forall a. Semigroup a => a -> a -> a
<> Text -> [Char]
T.unpack Text
t
isSanitary :: Text -> Bool
isSanitary :: Text -> Bool
isSanitary Text
t = Bool -> Bool
not (Text -> Bool
T.null Text
t) Bool -> Bool -> Bool
&& Char -> Bool
isAsciiLetter (HasCallStack => Text -> Char
Text -> Char
T.head Text
t) Bool -> Bool -> Bool
&& (Char -> Bool) -> Text -> Bool
T.all Char -> Bool
isAllowedChar Text
t
where
isAsciiLetter :: Char -> Bool
isAsciiLetter Char
c = Char -> Bool
isAsciiLower Char
c Bool -> Bool -> Bool
|| Char -> Bool
isAsciiUpper Char
c
isAllowedChar :: Char -> Bool
isAllowedChar Char
c = Char -> Bool
isAsciiLetter Char
c Bool -> Bool -> Bool
|| Char -> Bool
isDigit Char
c Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'-'
attr :: Text -> Text -> Attr
attr :: Text -> Text -> Attr
attr = Text -> Text -> Attr
Attr
id_ :: Text -> Attr
id_ :: Text -> Attr
id_ = Text -> Text -> Attr
attr Text
"id"
class_ :: [Text] -> Attr
class_ :: [Text] -> Attr
class_ = Text -> Text -> Attr
attr Text
"class" (Text -> Attr) -> ([Text] -> Text) -> [Text] -> Attr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Text] -> Text
T.unwords
rawText :: Text -> HTMLBody
rawText :: Text -> HTMLBody
rawText = Text -> HTMLBody
RawText
rawText' :: String -> HTMLBody
rawText' :: [Char] -> HTMLBody
rawText' = [Char] -> HTMLBody
forall a. IsString a => [Char] -> a
fromString
textFormat :: Format -> [Attr] -> Text -> HTMLBody
textFormat :: Format -> [Attr] -> Text -> HTMLBody
textFormat Format
fmt [Attr]
attrs Text
txt = Format -> [Attr] -> [HTMLBody] -> HTMLBody
TextFormat Format
fmt [Attr]
attrs [Text -> HTMLBody
RawText Text
txt]
bold, emphasis, subscript, superscript, span :: [Attr] -> Text -> HTMLBody
bold :: [Attr] -> Text -> HTMLBody
bold = Format -> [Attr] -> Text -> HTMLBody
textFormat Format
Bold
emphasis :: [Attr] -> Text -> HTMLBody
emphasis = Format -> [Attr] -> Text -> HTMLBody
textFormat Format
Emphasis
subscript :: [Attr] -> Text -> HTMLBody
subscript = Format -> [Attr] -> Text -> HTMLBody
textFormat Format
Subscript
superscript :: [Attr] -> Text -> HTMLBody
superscript = Format -> [Attr] -> Text -> HTMLBody
textFormat Format
Superscript
span :: [Attr] -> Text -> HTMLBody
span = Format -> [Attr] -> Text -> HTMLBody
textFormat Format
Span
bold_, emphasis_, subscript_, superscript_ :: [HTMLBody] -> HTMLBody
bold_ :: [HTMLBody] -> HTMLBody
bold_ = Format -> [Attr] -> [HTMLBody] -> HTMLBody
TextFormat Format
Bold []
emphasis_ :: [HTMLBody] -> HTMLBody
emphasis_ = Format -> [Attr] -> [HTMLBody] -> HTMLBody
TextFormat Format
Emphasis []
subscript_ :: [HTMLBody] -> HTMLBody
subscript_ = Format -> [Attr] -> [HTMLBody] -> HTMLBody
TextFormat Format
Subscript []
superscript_ :: [HTMLBody] -> HTMLBody
superscript_ = Format -> [Attr] -> [HTMLBody] -> HTMLBody
TextFormat Format
Superscript []
span_ :: [Attr] -> [HTMLBody] -> HTMLBody
span_ :: [Attr] -> [HTMLBody] -> HTMLBody
span_ = Format -> [Attr] -> [HTMLBody] -> HTMLBody
TextFormat Format
Span
figureImage :: [Attr] -> [Attr] -> File -> Text -> Text -> HTMLBody
figureImage :: [Attr] -> [Attr] -> Text -> Text -> Text -> HTMLBody
figureImage [Attr]
attrsFig [Attr]
attrsImg Text
src Text
altText Text
captionTxt =
[Attr] -> [HTMLBody] -> HTMLBody
Figure [Attr]
attrsFig [Text -> Text -> [Attr] -> HTMLBody
Img Text
src Text
altText [Attr]
attrsImg, [Attr] -> [HTMLBody] -> HTMLBody
FigCaption [] [Text -> HTMLBody
RawText Text
captionTxt]]
inlineScript :: Text -> HTMLHead
inlineScript :: Text -> HTMLHead
inlineScript = [Attr] -> Text -> HTMLHead
Script []
externalScript :: File -> [Attr] -> HTMLHead
externalScript :: Text -> [Attr] -> HTMLHead
externalScript Text
src [Attr]
attrs = [Attr] -> Text -> HTMLHead
Script (Text -> Text -> Attr
attr Text
"src" Text
src Attr -> [Attr] -> [Attr]
forall a. a -> [a] -> [a]
: Text -> Text -> Attr
attr Text
"type" Text
"text/javascript" Attr -> [Attr] -> [Attr]
forall a. a -> [a] -> [a]
: [Attr]
attrs) Text
forall a. Monoid a => a
mempty
stylesheet :: Text -> HTMLHead
stylesheet :: Text -> HTMLHead
stylesheet Text
css = Text -> Text -> [Attr] -> HTMLHead
Link Text
"stylesheet" (Text
css Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
".css") [Text -> Text -> Attr
attr Text
"type" Text
"text/css"]