Skip to content

Commit

Permalink
Fix: forgot about the impact of removing the bold style
Browse files Browse the repository at this point in the history
on Markdown table header lengths.
  • Loading branch information
lukstafi committed Jan 26, 2024
1 parent e1b96d3 commit f9ace94
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 38 deletions.
5 changes: 3 additions & 2 deletions src/printbox-md/PrintBox_md.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/printbox-md/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<div>
<table class="framed">
Expand Down
32 changes: 16 additions & 16 deletions test/test_md.expected
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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**
</details>


Expand Down
32 changes: 16 additions & 16 deletions test/test_md.expected.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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**
</details>


Expand Down

0 comments on commit f9ace94

Please sign in to comment.