let rec print html fmt rep_ele =
match rep_ele with
Leaf f ->
Format.pp_print_string fmt (f ())
| Tag t ->
let s =
"<"^t.tag^
(List.fold_left
(fun acc -> fun (att,f) -> acc^" "^att^"=\""^(f ())^"\"")
""
t.atts)^
">"
in
Format.pp_print_string fmt s;
List.iter (print html fmt) t.tag_subs ;
if must_close html t.tag then
Format.pp_print_string fmt ("</"^t.tag^">")
| List list ->
let l = list.f () in
List.iter
(fun ele ->
List.iter (print html fmt) (list.list_subs ele)
)
l
| Cond c ->
List.iter (print html fmt)
(if c.cond () then
c.subs_then
else
c.subs_else)
| Sub s ->
let r = s.sub_rep () in
List.iter (print html fmt) r.rep_eles