Skip to content

Commit 51385ff

Browse files
committed
mrkdwn: propagate loop args properly
1 parent f65d55a commit 51385ff

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/mrkdwn.ml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,20 @@ let rec mrkdwn_of_md md =
2525
Buffer.add_char b ' '
2626
done
2727
in
28-
let rec f ?(fst_p_in_li = true) ?(is_in_list = false) list_indent tl = function
28+
let rec loop ?(fst_p_in_li = true) ?(is_in_list = false) list_indent =
2929
(* [list_indent: int] is the indentation level in number of spaces.
3030
[fst_p_in_li: bool] is used to apply different indentation to the first
3131
paragraph in a list items.
3232
[is_in_list: bool] is necessary to know if we are inside a paragraph
3333
which is inside a list item because those need to be indented!
3434
*)
35+
let loop ?(fst_p_in_li = fst_p_in_li) ?(is_in_list = is_in_list) list_indent l =
36+
loop ~fst_p_in_li ~is_in_list list_indent l
37+
in
38+
function
39+
| [] -> ()
40+
| el :: tl ->
41+
match el with
3542
| X _ -> loop list_indent tl
3643
| Blockquote q ->
3744
(* mrkdwn doesn't support nested quotes, but output '>' chars anyway*)
@@ -179,9 +186,6 @@ let rec mrkdwn_of_md md =
179186
(* the string "\n" renders NL *)
180187
nl_if_needed_above b;
181188
loop list_indent tl
182-
and loop ?(fst_p_in_li = true) ?(is_in_list = false) list_indent = function
183-
| hd :: tl -> f ~fst_p_in_li ~is_in_list list_indent tl hd
184-
| [] -> ()
185189
in
186190
(* print the document *)
187191
loop 0 md;

0 commit comments

Comments
 (0)