Skip to content

Commit

Permalink
Construct a formatter specifically for printing signature declaration…
Browse files Browse the repository at this point in the history
…s to HTML

Replacing the usage of `Format.stdbuf` for pretty-printing to HTML files with a newly constructed buffer ensures that the `Format.stdbuf` is not altered unexpectedly.
  • Loading branch information
MartyO256 committed May 27, 2022
1 parent d96a9a6 commit 785fac6
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/core/recsgn.ml
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,15 @@ let sgnDeclToHtml =
function
| Ext.Sgn.Comment { content; _ } -> Html.appendAsComment content
| d ->
let margin = Format.pp_get_margin Format.str_formatter () in
Html.printing := true;
(* Format.set_margin 150; *)
Format.pp_set_margin Format.str_formatter 200;
Pretty.Ext.DefaultPrinter.fmt_ppr_sgn_decl Format.str_formatter d;
Html.append (Format.flush_str_formatter ());
Format.pp_set_margin (Format.str_formatter) margin;

let html_buffer = Buffer.create 16 in
let html_formatter = Format.formatter_of_buffer html_buffer in
Format.pp_set_margin html_formatter 200;
Format.fprintf html_formatter "%a" Pretty.Ext.DefaultPrinter.fmt_ppr_sgn_decl d;
Format.pp_print_flush html_formatter ();
Html.append (Buffer.contents html_buffer);

Html.printing := false

let rec apply_global_pragmas =
Expand Down

0 comments on commit 785fac6

Please sign in to comment.