module Text.Tabl
( Alignment(..)
, Decoration(..)
, Environment(..)
, tabl
) where
import qualified Data.Text as T
import Text.Tabl.Alignment
import Text.Tabl.Ascii
import Text.Tabl.Decoration
import Text.Tabl.Environment
import Text.Tabl.Latex
import Text.Tabl.Util
tabl :: Environment
-> Decoration
-> Decoration
-> [Alignment]
-> [[T.Text]]
-> T.Text
tabl _ _ _ _ [] = T.empty
tabl _ _ _ _ [[]] = T.empty
tabl env hdecor vdecor aligns cells = render env hpres vpres ealigns ecells
where
render EnvAscii = ascii
render EnvLatex = latex
hpres = presence (length cells + 1) hdecor
vpres = presence (length (head cells) + 1) vdecor
columnCount = maximum $ map length cells
ecells = map (extend columnCount T.empty) cells
ealigns = extend columnCount AlignLeft aligns