···152152 | [] -> targets
153153 | _ -> targets @ ppxs @ [ "ppxlib_register" ]
154154 in
155155- let env = Env.empty in
155155+ let env = Env.singleton "x-ocaml.lib" in
156156 let env, all_ppxs = dependencies ~ppx:true ppxs env in
157157 let _env, all_libs = dependencies ~ppx:false targets env in
158158 let all = all_ppxs @ all_libs in
···88 | Format of id * string
99 | Setup
10101111-type output = Stdout of string | Stderr of string | Meta of string
1111+type output =
1212+ | Stdout of string
1313+ | Stderr of string
1414+ | Meta of string
1515+ | Html of string
12161317type response =
1418 | Merlin_response of id * Merlin_protocol.answer
+11-6
src/cell.ml
···158158 refresh_lines_from ~editor
159159160160let render_message msg =
161161+ let raw_html s =
162162+ let el = El.div [] in
163163+ let el_t = El.to_jv el in
164164+ Jv.set el_t "innerHTML" (Jv.of_jstr @@ Jstr.of_string s);
165165+ el
166166+ in
161167 let kind, text =
162168 match msg with
163163- | X_protocol.Stdout str -> ("stdout", str)
164164- | Stderr str -> ("stderr", str)
165165- | Meta str -> ("meta", str)
169169+ | X_protocol.Stdout str -> ("stdout", El.txt' str)
170170+ | Stderr str -> ("stderr", El.txt' str)
171171+ | Meta str -> ("meta", El.txt' str)
172172+ | Html str -> ("html", raw_html str)
166173 in
167167- El.pre
168168- ~at:[ At.class' (Jstr.of_string ("caml_" ^ kind)) ]
169169- [ El.txt (Jstr.of_string text) ]
174174+ El.pre ~at:[ At.class' (Jstr.of_string ("caml_" ^ kind)) ] [ text ]
170175171176let add_message t loc msg =
172177 Editor.add_message t.cm loc (List.map render_message msg)
+1-2
src/editor.ml
···3939let refresh_messages ed =
4040 Code_mirror.Editor.View.dispatch ed.view
4141 (Code_mirror.Compartment.reconfigure ed.messages_comp
4242- [ render_messages ed ]);
4343- Code_mirror.Editor.View.request_measure ed.view
4242+ [ render_messages ed ])
44434544let custom_ln editor =
4645 Code_mirror.Editor.View.line_numbers (fun x ->
···11+let id = ref (0, 0)
22+33+let output_html m =
44+ let id, loc = !id in
55+ Js_of_ocaml.Worker.post_message
66+ (X_protocol.resp_to_bytes
77+ (X_protocol.Top_response_at (id, loc, [ Html m ])));
88+ ()
+5
worker-lib/x_ocaml_lib.mli
···11+val output_html : string -> unit
22+33+(**/**)
44+55+val id : (int * int) ref
···6767 List.rev out
6868 in
6969 let respond ~(at_loc : Location.t) =
7070- let loc = at_loc.loc_end.pos_cnum - line_number in
7070+ let loc = at_loc.loc_end.pos_cnum in
7171 let out = get_out () in
7272 output ~loc out
7373 in
···8989 | Ptop_dir { pdir_loc = loc; _ } -> loc
9090 | _ -> assert false
9191 in
9292+ X_ocaml_lib.id := (id, at_loc.loc_end.pos_cnum);
9293 try
9394 Location.reset ();
9495 let phrase = preprocess_phrase phrase in