require cmarkit 0.3
work around the issue reported at https://github.com/dbuenzli/cmarkit/issues/14 add a second table test, fix the tests for the 0.3 fixed layouting
This commit is contained in:
parent
46d8ba611c
commit
7f3a6719e2
3 changed files with 42 additions and 5 deletions
|
@ -45,7 +45,7 @@ depends: [
|
||||||
"cmdliner" {>= "1.1.0"}
|
"cmdliner" {>= "1.1.0"}
|
||||||
"uri"
|
"uri"
|
||||||
"fmt" {>= "0.8.7"}
|
"fmt" {>= "0.8.7"}
|
||||||
"cmarkit"
|
"cmarkit" {>= "0.3.0"}
|
||||||
"tar"
|
"tar"
|
||||||
"owee"
|
"owee"
|
||||||
"solo5-elftool" {>= "0.3.0"}
|
"solo5-elftool" {>= "0.3.0"}
|
||||||
|
|
|
@ -61,7 +61,8 @@ let md_to_html ?adjust_heading ?(safe = true) data =
|
||||||
in
|
in
|
||||||
let h' = make ?id ~layout ~level:(level + lvl) inline in
|
let h' = make ?id ~layout ~level:(level + lvl) inline in
|
||||||
Mapper.ret (Block.Heading (h', meta))
|
Mapper.ret (Block.Heading (h', meta))
|
||||||
| _ -> Mapper.default
|
| Block.Blocks _ -> Mapper.default
|
||||||
|
| x -> Mapper.ret x
|
||||||
in
|
in
|
||||||
let mapper = Mapper.make ~block () in
|
let mapper = Mapper.make ~block () in
|
||||||
Mapper.map_doc mapper doc)
|
Mapper.map_doc mapper doc)
|
||||||
|
|
|
@ -112,30 +112,65 @@ let test_table () =
|
||||||
|__}
|
|__}
|
||||||
in
|
in
|
||||||
let html = markdown_to_html ~adjust_heading:2 markdown in
|
let html = markdown_to_html ~adjust_heading:2 markdown in
|
||||||
(* NB: the maximum heading is 6 in cmarkit, thus we reduce the structure *)
|
|
||||||
let exp = {|<div role="region"><table>
|
let exp = {|<div role="region"><table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>a</th>
|
<th>a</th>
|
||||||
|
<th></th>
|
||||||
<th>b</th>
|
<th>b</th>
|
||||||
<th>c</th>
|
<th>c</th>
|
||||||
<th>d</th>
|
<th>d</th>
|
||||||
<th>e</th>
|
<th>e</th>
|
||||||
<th></th>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>entry</td>
|
<td>entry</td>
|
||||||
|
<td></td>
|
||||||
<td><strong>bla.file</strong></td>
|
<td><strong>bla.file</strong></td>
|
||||||
<td><strong>other.file</strong></td>
|
<td><strong>other.file</strong></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><em>another entry</em></td>
|
<td><em>another entry</em></td>
|
||||||
|
<td></td>
|
||||||
<td><strong>another.file</strong></td>
|
<td><strong>another.file</strong></td>
|
||||||
<td><strong>another.other</strong></td>
|
<td><strong>another.other</strong></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
</table></div>|} in
|
||||||
|
Alcotest.(check string "table is rendered as html" exp html)
|
||||||
|
|
||||||
|
let test_table2 () =
|
||||||
|
let markdown = {__|| a | | b | c | d | e |
|
||||||
|
| --------------------- |-| -------------- | -------------- | --------------- | ------ |
|
||||||
|
| entry | | | | **bla.file** | **other.file** |
|
||||||
|
| _another entry_ | | | **another.file** | **another.other** | |
|
||||||
|
|__}
|
||||||
|
in
|
||||||
|
let html = markdown_to_html ~adjust_heading:2 markdown in
|
||||||
|
let exp = {|<div role="region"><table>
|
||||||
|
<tr>
|
||||||
|
<th>a</th>
|
||||||
|
<th></th>
|
||||||
|
<th>b</th>
|
||||||
|
<th>c</th>
|
||||||
|
<th>d</th>
|
||||||
|
<th>e</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>entry</td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td><strong>bla.file</strong></td>
|
||||||
|
<td><strong>other.file</strong></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><em>another entry</em></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td><strong>another.file</strong></td>
|
||||||
|
<td><strong>another.other</strong></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table></div>|} in
|
</table></div>|} in
|
||||||
|
@ -157,6 +192,7 @@ let markdown_tests = [
|
||||||
Alcotest.test_case "fragment link" `Quick test_fragment_link;
|
Alcotest.test_case "fragment link" `Quick test_fragment_link;
|
||||||
Alcotest.test_case "heading adjustment" `Quick test_heading_adjustment;
|
Alcotest.test_case "heading adjustment" `Quick test_heading_adjustment;
|
||||||
Alcotest.test_case "table" `Quick test_table;
|
Alcotest.test_case "table" `Quick test_table;
|
||||||
|
Alcotest.test_case "table2" `Quick test_table2;
|
||||||
]
|
]
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
|
|
Loading…
Reference in a new issue