Update omd to 2.0.0~alpha3
This commit is contained in:
parent
02dbe1af37
commit
92fb616980
2 changed files with 10 additions and 10 deletions
16
lib/utils.ml
16
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
|
||||
|
|
|
@ -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" "<h1>Hello world</h1>\n" html)
|
||||
Alcotest.(check string "simple html" "<h1 id=\"hello-world\">Hello world</h1>\n" html)
|
||||
|
||||
let test_html_script () =
|
||||
let markdown = {|# <script>Hello world</script>|} in
|
||||
let html = markdown_to_html markdown in
|
||||
Alcotest.(check string "html script header" "<h1>Hello world</h1>\n" html)
|
||||
Alcotest.(check string "html script header" "<h1 id=\"hello-world\">Hello world</h1>\n" html)
|
||||
|
||||
let test_preserve_span_content () =
|
||||
let markdown = {|* <span id="myref">My ref</span>
|
||||
|
|
Loading…
Reference in a new issue