{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE OverloadedStrings #-}
module Knit.Report.Input.Table.Colonnade
(
addColonnadeTextTable
, addColonnadeHtmlTable
, addColonnadeCellTable
)
where
import qualified Colonnade as C
import qualified Text.Blaze.Colonnade as BC
import qualified Text.Blaze.Html as BH
import qualified Text.Blaze.Html5.Attributes as BHA
import Knit.Report.Input.Html.Blaze ( addBlaze )
import Data.Text ( Text )
import qualified Polysemy as P
import qualified Knit.Effect.Pandoc as PE
import qualified Knit.Effect.PandocMonad as PM
addColonnadeTextTable
:: (PM.PandocEffects effs, P.Member PE.ToPandoc effs, Foldable f)
=> C.Colonnade C.Headed a Text
-> f a
-> P.Sem effs ()
addColonnadeTextTable colonnade rows = do
let toCell t = BC.Cell (BHA.style "border: 1px solid black") (BH.toHtml t)
addBlaze $ BC.encodeCellTable
(BHA.style "border: 1px solid black; border-collapse: collapse")
(fmap toCell colonnade)
rows
addColonnadeHtmlTable
:: (PM.PandocEffects effs, P.Member PE.ToPandoc effs, Foldable f)
=> BH.Attribute
-> C.Colonnade C.Headed a BH.Html
-> f a
-> P.Sem effs ()
addColonnadeHtmlTable attr colonnade rows =
addBlaze $ BC.encodeHtmlTable attr colonnade rows
addColonnadeCellTable
:: (PM.PandocEffects effs, P.Member PE.ToPandoc effs, Foldable f)
=> BH.Attribute
-> C.Colonnade C.Headed a BC.Cell
-> f a
-> P.Sem effs ()
addColonnadeCellTable attr colonnade rows =
addBlaze $ BC.encodeCellTable attr colonnade rows