-- | Convenience functions for HTML construction
module HtmlConOps where
import Html
import HtmlTags
-- ** HTML construction
-- *** Overal document structure
html = ctx HTML . (nl:)
title = ctx TITLE
head' = ctx HEAD . (nl:)
body = ctx BODY . (nl:)
body' attrs = ctx' BODY attrs . (nl:)
-- *** Paragraphs and line breaks
br = cmd BR
p = ctxie P
p' = cmd P -- obsolete
hr = cmd HR
-- *** Images
img src = cmd' IMG [("SRC",src)]
imgalt src alt = cmd' IMG [("SRC",src),("ALT",alt)]
-- *** Headers
h1 = ctx H1
h2 = ctx H2
h3 = ctx H3
h4 = ctx H4
h5 = ctx H5
h6 = ctx H6
-- *** Lists
ol = ctx OL
ul = ctx UL
menu = ctx MENU . map li
dir = ctx DIR . map li
li' = cmd LI -- obsolete
li = ctxie LI
dl = ctx DL
dlcompact = ctx' DL [("COMPACT","")]
dt = ctxie DT
dd = ctxie DD
-- *** Forms
form = form' []
form' = ctx' FORM
input name attrs = cmd' INPUT (("name",name):attrs)
submit label = cmd' INPUT [("type","submit"),("value",label)]
reset label = cmd' INPUT [("type","reset"),("value",label)]
-- *** Links
href url = ctx' A [("HREF",url)]
target name = ctx' A [("NAME",name)]
-- *** Text
strong = ctx STRONG
em = ctx EM
-- ** Tables
tr = ctxie TR
td = ctxie TD
-- *** Generic
cmd t = cmd' t []
cmd' t as = HtmlCommand (t,attrs as)
ctx t = ctx' t []
ctx' t as = HtmlContext (t,attrs as)
ctxie s = ctxie' s []
ctxie' s attrs = ctx' s (("implicitend",""):attrs)
-- ** Various
pre = ctx PRE
ctx_class s c = ctx' s [("CLASS",c)]
div_class = ctx_class DIV
span_class = ctx_class SPAN
txt = HtmlChars
nl = txt "\n"
-- ^ Can be used to improve readability of generated HTML