https://github.com/mbarbin/print-table
Simple Unicode/ANSI and Markdown text table rendering for OCaml
https://github.com/mbarbin/print-table
markdown table
Last synced: 6 months ago
JSON representation
Simple Unicode/ANSI and Markdown text table rendering for OCaml
- Host: GitHub
- URL: https://github.com/mbarbin/print-table
- Owner: mbarbin
- License: isc
- Created: 2025-07-22T07:12:03.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2026-01-10T14:08:20.000Z (6 months ago)
- Last Synced: 2026-01-11T04:20:46.466Z (6 months ago)
- Topics: markdown, table
- Language: OCaml
- Homepage: https://mbarbin.github.io/print-table/
- Size: 85 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: COPYING.HEADER
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# print-table
[](https://github.com/mbarbin/print-table/actions/workflows/ci.yml)
[](https://coveralls.io/github/mbarbin/print-table?branch=main)
[](https://ocaml.ci.dev/github/mbarbin/print-table)
Print_table provides a minimal library for rendering text tables with Unicode box-drawing characters and optional ANSI colors:
```ocaml
# let columns =
Print_table.O.
[ Column.make ~header:"Name" (fun (name, _) -> Cell.text name)
; Column.make ~header:"Score" ~align:Right (fun (_, score) ->
Cell.text (Int.to_string score))
]
val columns : (string * int) Print_table.Column.t list = [; ]
# let rows = [ "Alice", 10; "Bob", 3 ] ;;
val rows : (string * int) list = [("Alice", 10); ("Bob", 3)]
# print_endline (Print_table.to_string_text (Print_table.make ~columns ~rows))
┌───────┬───────┐
│ Name │ Score │
├───────┼───────┤
│ Alice │ 10 │
│ Bob │ 3 │
└───────┴───────┘
- : unit = ()
```
Or as GitHub-flavored Markdown:
```ocaml
# print_endline (Print_table.to_string_markdown (Print_table.make ~columns ~rows))
| Name | Score |
|:------|------:|
| Alice | 10 |
| Bob | 3 |
- : unit = ()
```
which is rendered natively by GitHub like this:
| Name | Score |
|:------|------:|
| Alice | 10 |
| Bob | 3 |
## Code Documentation
The code documentation of the latest release is built with `odoc` and published to `GitHub` pages [here](https://mbarbin.github.io/print-table).
## Acknowledgments
This library has taken some inspiration from 2 existing and more feature-complete libraries, which we link to here for more advanced usages.
- [Printbox](https://github.com/c-cube/printbox)
- [Ascii_table](https://github.com/janestreet/textutils)