let str_to_TOC ?make_links ?list_type ?numbering
?(filename="<IN>") 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
let output_funs =
Bracetax_TOC_output.create ?list_type ?numbering ?make_links () in
let printer = Bracetax_generic_printer.build ~writer ~output_funs () in
Parser.do_transformation printer input_char filename;
(Buffer.contents out_buf, List.rev !errors)