From 92fb616980057462637d3c232d917a5998e3067f Mon Sep 17 00:00:00 2001 From: Robur Date: Mon, 13 Mar 2023 11:41:59 +0000 Subject: [PATCH] Update omd to 2.0.0~alpha3 --- lib/utils.ml | 16 ++++++++-------- test/markdown_to_html.ml | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/utils.ml b/lib/utils.ml index bb4fa3f..57cc779 100644 --- a/lib/utils.ml +++ b/lib/utils.ml @@ -74,19 +74,19 @@ module Omd = struct Some (Omd.Definition_list (attr, def_elts)) | Omd.Code_block _ | Omd.Thematic_break _ as v -> Some v - | Omd.Table (attr, inline_alignments, inlines) -> - let inline_alignments = + | Omd.Table (attr, header_row, rows) -> + let header_row = List.fold_left (fun acc (cell, alignment) -> match acc with | None -> None | Some xs -> Option.map (fun cell -> xs @ [ cell, alignment ]) (safe_inline cell)) - (Some []) inline_alignments + (Some []) header_row in Option.map - (fun inline_alignments -> - let inlines = + (fun header_row -> + let rows = List.filter_map (fun row -> List.fold_left (fun acc cell -> match acc with @@ -94,10 +94,10 @@ module Omd = struct | Some xs -> Option.map (fun cell -> xs @ [ cell ]) (safe_inline cell)) (Some []) row) - inlines + rows in - Omd.Table (attr, inline_alignments, inlines)) - inline_alignments + Omd.Table (attr, header_row, rows)) + header_row and safe_def_elts { term ; defs } = let defs = List.filter_map safe_inline defs in safe_inline term diff --git a/test/markdown_to_html.ml b/test/markdown_to_html.ml index 4ad62ce..e9c3b17 100644 --- a/test/markdown_to_html.ml +++ b/test/markdown_to_html.ml @@ -3,12 +3,12 @@ let markdown_to_html = Builder_web__Utils.Omd.html_of_string let test_simple () = let markdown = {|# Hello world|} in let html = markdown_to_html markdown in - Alcotest.(check string "simple html" "

Hello world

\n" html) + Alcotest.(check string "simple html" "

Hello world

\n" html) let test_html_script () = let markdown = {|# |} in let html = markdown_to_html markdown in - Alcotest.(check string "html script header" "

Hello world

\n" html) + Alcotest.(check string "html script header" "

Hello world

\n" html) let test_preserve_span_content () = let markdown = {|* My ref