package print-table

  1. Overview
  2. Docs
Simple Unicode/ANSI and Markdown text table rendering

Install

Dune Dependency

Authors

Maintainers

Sources

print-table-0.1.0.tbz
sha256=88189431c9f7c4bd81f55993cacd61971552648a9c9acf37153de14ad6e394e4
sha512=c69fc30a774e43dfac4c0e87be3245da8f2d7ee4fef52d1e55ca53fd8c039e317ed7caafeded2713dc42a706213f7af124b34a34d0bced417528c51bbda89105

Description

print-table provides a minimal library for rendering text tables with Unicode box-drawing characters and optional ANSI colors, or as GitHub-flavored Markdown.

The API is straightforward and declarative, designed for readable tables in command-line tools, tests, and tutorials.

This library has taken some inspiration from 2 existing and more feature-complete libraries, which we link to here for more advanced usages: see printbox and ascii_table.

Tags

table markdown

Published: 24 Jul 2025

README

CI Status Coverage Status OCaml-CI Build Status

Print_table provides a minimal library for rendering text tables with Unicode box-drawing characters and optional ANSI colors:

# 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 = [<abstr>; <abstr>]

# 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:

# 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.

Acknowledgments

This library has taken some inspiration from 2 existing and more feature-complete libraries, which we link to here for more advanced usages.

Dependencies (2)

  1. ocaml >= "4.14"
  2. dune >= "3.17"

Dev Dependencies (1)

  1. odoc with-doc

Used by

None

Conflicts

None

OCaml

Innovation. Community. Security.