diff --git a/src/printbox-md/PrintBox_md.ml b/src/printbox-md/PrintBox_md.ml index 14ebc06..a953cfe 100644 --- a/src/printbox-md/PrintBox_md.ml +++ b/src/printbox-md/PrintBox_md.ml @@ -290,10 +290,11 @@ let pp c out b = rows) | B.Grid (_, [||]) -> () | B.Grid (bars, rows) when bars <> `None && is_native_table c rows -> + let n_rows = Array.length rows and n_cols = Array.length rows.(0) in let lengths = Array.fold_left (Array.map2 (fun len b -> max len @@ line_of_length_heuristic_exn c b)) - (Array.map (fun _ -> 0) rows.(0)) rows in - let n_rows = Array.length rows and n_cols = Array.length rows.(0) in + (Array.map (fun b -> line_of_length_heuristic_exn c b - 4) rows.(0)) + @@ Array.sub rows 1 (n_rows - 1) in Array.iteri (fun i header -> let header = remove_bold header in loop ~no_block:true ~no_md ~prefix:"" header; diff --git a/src/printbox-md/README.md b/src/printbox-md/README.md index f4db709..fb0b222 100644 --- a/src/printbox-md/README.md +++ b/src/printbox-md/README.md @@ -136,10 +136,10 @@ Trees are rendered as: There is a special case carved out for Markdown syntax tables. -Header |cells |[must be] |bold. -----------|---------|-------------|----------------- -Rows |[must be]|single |line. -[Only] |then |**we get** |a Markdown table. +Header|cells |[must be] |bold. +------|---------|----------|----------------- +Rows |[must be]|single |line. +[Only]|then |**we get**|a Markdown table.
diff --git a/test/test_md.expected b/test/test_md.expected index 936177c..8b0302e 100644 --- a/test/test_md.expected +++ b/test/test_md.expected @@ -61,14 +61,14 @@ Test default: > > > > > > -- header 1 |header 2 |[header 3] - ------------|------------|-------------- - cell 1.1 |[cell 1.2] |cell 1.3 - [cell 2.1] |cell 2.2 |**cell 2.3** -- > header 1 |header 2 |[header 3] - > ------------|------------|-------------- - > cell 1.1 |[cell 1.2] |cell 1.3 - > [cell 2.1] |cell 2.2 |**cell 2.3** +- header 1 |header 2 |[header 3] + ----------|----------|------------ + cell 1.1 |[cell 1.2]|cell 1.3 + [cell 2.1]|cell 2.2 |**cell 2.3** +- > header 1 |header 2 |[header 3] + > ----------|----------|------------ + > cell 1.1 |[cell 1.2]|cell 1.3 + > [cell 2.1]|cell 2.2 |**cell 2.3** Test uniform unfolded: @@ -262,14 +262,14 @@ Test foldable: > > > > > > -- header 1 |header 2 |[header 3] - ------------|------------|-------------- - cell 1.1 |[cell 1.2] |cell 1.3 - [cell 2.1] |cell 2.2 |**cell 2.3** -- > header 1 |header 2 |[header 3] - > ------------|------------|-------------- - > cell 1.1 |[cell 1.2] |cell 1.3 - > [cell 2.1] |cell 2.2 |**cell 2.3** +- header 1 |header 2 |[header 3] + ----------|----------|------------ + cell 1.1 |[cell 1.2]|cell 1.3 + [cell 2.1]|cell 2.2 |**cell 2.3** +- > header 1 |header 2 |[header 3] + > ----------|----------|------------ + > cell 1.1 |[cell 1.2]|cell 1.3 + > [cell 2.1]|cell 2.2 |**cell 2.3** diff --git a/test/test_md.expected.md b/test/test_md.expected.md index 936177c..8b0302e 100644 --- a/test/test_md.expected.md +++ b/test/test_md.expected.md @@ -61,14 +61,14 @@ Test default: > > > > > > -- header 1 |header 2 |[header 3] - ------------|------------|-------------- - cell 1.1 |[cell 1.2] |cell 1.3 - [cell 2.1] |cell 2.2 |**cell 2.3** -- > header 1 |header 2 |[header 3] - > ------------|------------|-------------- - > cell 1.1 |[cell 1.2] |cell 1.3 - > [cell 2.1] |cell 2.2 |**cell 2.3** +- header 1 |header 2 |[header 3] + ----------|----------|------------ + cell 1.1 |[cell 1.2]|cell 1.3 + [cell 2.1]|cell 2.2 |**cell 2.3** +- > header 1 |header 2 |[header 3] + > ----------|----------|------------ + > cell 1.1 |[cell 1.2]|cell 1.3 + > [cell 2.1]|cell 2.2 |**cell 2.3** Test uniform unfolded: @@ -262,14 +262,14 @@ Test foldable: > > > > > > -- header 1 |header 2 |[header 3] - ------------|------------|-------------- - cell 1.1 |[cell 1.2] |cell 1.3 - [cell 2.1] |cell 2.2 |**cell 2.3** -- > header 1 |header 2 |[header 3] - > ------------|------------|-------------- - > cell 1.1 |[cell 1.2] |cell 1.3 - > [cell 2.1] |cell 2.2 |**cell 2.3** +- header 1 |header 2 |[header 3] + ----------|----------|------------ + cell 1.1 |[cell 1.2]|cell 1.3 + [cell 2.1]|cell 2.2 |**cell 2.3** +- > header 1 |header 2 |[header 3] + > ----------|----------|------------ + > cell 1.1 |[cell 1.2]|cell 1.3 + > [cell 2.1]|cell 2.2 |**cell 2.3**