let str_to_latex ?(doc=false) ?title ?use_package ?(deny_bypass=false)
?(print_comments=false) ?(href_is_footnote=false) ?img_hook ?url_hook
?table_caption_after
?separate_header ?(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
if doc then
writer.w_write
(Bracetax_latex_printer.header
~comment:"Generated with BraceTax" ?title
?stylesheet_link:use_package ());
let printer =
Bracetax_latex_printer.build
~writer ~print_comments ~href_is_footnote ?table_caption_after
?separate_header ?img_hook ?url_hook () in
Parser.do_transformation ~deny_bypass printer input_char filename;
if doc then (
writer.w_write (Bracetax_latex_printer.footer ());
);
(Buffer.contents out_buf, List.rev !errors)