File tree Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -166,7 +166,7 @@ let diffable_pretty_to_string json =
166
166
in
167
167
Pretty. to_string (f (Yojson.Basic. pretty_format ~std: true json))
168
168
169
- let prepare_ipynb_for_saving data =
169
+ let prepare_ipynb_for_saving no_split_lines data =
170
170
let open Yojson.Basic in
171
171
let json = from_string data in
172
172
@@ -176,9 +176,12 @@ let prepare_ipynb_for_saving data =
176
176
177
177
(* rewrite the json with an empty notebook name *)
178
178
let json = replace_dict " metadata" (replace_dict " name" (`String " " ) metadata) json in
179
- let json = process_lines split json in
179
+ let json =
180
+ if no_split_lines then to_string ~std: true json
181
+ else diffable_pretty_to_string (process_lines split json)
182
+ in
180
183
181
- filename, diffable_pretty_to_string json
184
+ filename, json
182
185
183
186
let load_ipynb_for_serving path nbname =
184
187
let open Yojson.Basic in
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ val empty_notebook : string -> string
19
19
val file_or_path : string -> string * string
20
20
21
21
(* * extract notebook name from json, then remove it *)
22
- val prepare_ipynb_for_saving : string -> string * string
22
+ val prepare_ipynb_for_saving : bool -> string -> string * string
23
23
24
24
val load_ipynb_for_serving : (string -> string ) -> string -> string Lwt .t
25
25
Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ let configure_js_serve () =
56
56
! serve_file_path
57
57
end
58
58
59
+ let no_split_lines = ref false
59
60
60
61
let () =
61
62
Arg. (parse (align [
@@ -75,6 +76,7 @@ let () =
75
76
" -completion" , Set (Kernel. (kernel_args.completion)), " enable tab completion" ;
76
77
" -object-info" , Set (Kernel. (kernel_args.object_info)), " enable introspection" ;
77
78
" -browser" , Set_string (browser), " <exe> browser command [xdg-open]" ;
79
+ " -no-split-lines" , Set (no_split_lines), " dont split lines when saving" ;
78
80
" -v" , Unit (fun () -> incr verbose), " increase verbosity" ;
79
81
])
80
82
(fun s -> file_or_path := s)
@@ -260,7 +262,7 @@ let get_filename_of_ipynb s =
260
262
let save_notebook guid body =
261
263
let old_filename = Kernel.M. filename_of_notebook_guid guid in
262
264
(* lwt new_filename = get_filename_of_ipynb body in*)
263
- let new_filename, body = Files. prepare_ipynb_for_saving body in
265
+ let new_filename, body = Files. prepare_ipynb_for_saving ! no_split_lines body in
264
266
lwt () = Lwt_io. (with_file ~mode: output
265
267
(filename (new_filename ^ " .ipynb" ))
266
268
(fun f -> write f body))
You can’t perform that action at this time.
0 commit comments