Tablet.Styles (tablet v0.1.0)
View SourceBuilt-in tabular data rendering styles
Summary
Functions
Box style
Compact style
Generic box style
Ledger table style
Markdown table style
Unicode box style
Functions
@spec box(Tablet.t(), Tablet.styling_context(), [IO.ANSI.ansidata()]) :: IO.ANSI.ansidata()
Box style
Render tabular data with borders drawn from the ASCII character set. This should render everywhere.
To use, pass style: :box
to Tablet.puts/2
or Tablet.render/2
.
@spec compact(Tablet.t(), Tablet.styling_context(), [IO.ANSI.ansidata()]) :: IO.ANSI.ansidata()
Compact style
This style produces compact output by only underlining the header and adding whitespace around data. It is the default style.
@spec generic_box(Tablet.t(), Tablet.styling_context(), [IO.ANSI.ansidata()]) :: IO.ANSI.ansidata()
Generic box style
Render tabular data with whatever characters you want for borders. This is
used by the Box and Unicode Box styles. It's configurable via the :context
option as can be seen in the Box and Unicode Box implementations. Users can
also call this directly by passing style: :generic_box
and context: ...
.
The :context
map must contain a key called :border
that is a map with the
following fields:
:h
and:v
- the horizontal and vertical characters:ul
and:ur
- upper left and upper right corners:uc
- intersection of the horizontal top border with a vertical (looks like a T):ll
and:lr
- lower left and lower right corners:lc
- analogous to:uc
except on the Nick Bottom border:l
and:r
- left and right side characters with horizontal lines towards the interior:c
- interior horizontal and vertical intersection
@spec ledger(Tablet.t(), Tablet.styling_context(), [IO.ANSI.ansidata()]) :: IO.ANSI.ansidata()
Ledger table style
Render tabular data as rows that alternate colors.
To use, pass style: :ledger
to Tablet.puts/2
or Tablet.render/2
.
@spec markdown(Tablet.t(), Tablet.styling_context(), [IO.ANSI.ansidata()]) :: IO.ANSI.ansidata()
Markdown table style
Render tabular data as a GitHub-flavored markdown table.
Pass style: :markdown
to Tablet.puts/2
or Tablet.render/2
to use.
@spec unicode_box(Tablet.t(), Tablet.styling_context(), [IO.ANSI.ansidata()]) :: IO.ANSI.ansidata()
Unicode box style
Render tabular data with borders drawn with Unicode characters. This is a nicer
take on the :box
style.
To use, pass style: :unicode_box
to Tablet.puts/2
or Tablet.render/2
.