Skip to content

Commit 8796b38

Browse files
committed
Fix extra empty line between parts in to-md direction
1 parent 49be5a1 commit 8796b38

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

bin/test/main.ml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,12 @@ let run_toplevel_tests ?root c ppf tests t =
183183
Block.pp_footer ppf ()
184184

185185
let trim l =
186-
let rec aux = function
187-
| [] -> []
188-
| h::t -> if String.trim h = "" then aux t else String.trim h :: t
186+
let rec trim_front = function
187+
| ""::t -> trim_front t
188+
| l -> l
189189
in
190-
let no_head = aux l in
191-
let no_tail = List.rev (aux (List.rev no_head)) in
192-
no_tail
190+
let rev_trim l = trim_front (List.rev (trim_front l)) in
191+
rev_trim (List.rev_map String.trim l)
193192

194193
type file = { first: Mdx_top.Part.file; current: Mdx_top.Part.file }
195194

test/sync_to_md.md.expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ let () =
3737
()
3838
;;
3939

40-
4140
let x = 34
4241
let f = 42.3
4342
let s = "toto"
@@ -48,7 +47,6 @@ let () =
4847
print_float f
4948
;;
5049

51-
5250
let () =
5351
print_string s
5452
;;

0 commit comments

Comments
 (0)