let str_to_html
?make_section_links ?(doc=false) ?title ?css_link ?(print_comments=false)
?(filename="<IN>") ?class_hook ?img_hook ?url_hook
?separate_header ?(deny_bypass=false) in_str =
let errors = ref [] in
let error = fun e -> errors := e :: !errors in
let out_buf = Buffer.create 42 in
let write = Buffer.add_string out_buf in
let input_char =
let cpt = ref (-1) in
(fun () -> try Some (incr cpt; in_str.[!cpt]) with e -> None) in
let writer = make_writer ~write ~error in
if doc then (
writer.w_write
(Bracetax_HTML_printer.header ~comment:"Generated with BraceTax" ?title
?stylesheet_link:css_link ());
);
let printer =
Bracetax_HTML_printer.build ?class_hook ?img_hook ?url_hook ?separate_header
?make_section_links
~writer ~print_comments () in
Parser.do_transformation ~deny_bypass printer input_char filename;
if doc then (
writer.w_write (Bracetax_HTML_printer.footer ());
);
(Buffer.contents out_buf, List.rev !errors)