# tabelline 0.2.0: API reference

Every name tabelline exports, generated from the source when the site is built: 404 names in
16 modules, each with its signatures, its doc comment, gt's and Great Tables' names for the
same thing, and the shortest example of the specs that uses it, with what it prints.
The same, as a page: https://pietroppeter.github.io/tabelline/api/ (each `###` below links to its entry); as JSON: https://pietroppeter.github.io/tabelline/api.json .

How to read it: every verb takes the table first (`t: sink Tabella`) and returns the new one; in a
`tabella(data): body` each line is a verb without its table (`tabHeader "Title"`). A `ColSel` is a
column name, a list of names or a rule (`everything()`, `numeric()`, `startsWith("x")`); a `RowSel`
is a row index of the data (not as shown), a list, a slice or `where(it["col"] > 1)`.

## Index

One line per name: its kind, gt's name when it has one, and the first sentence of its doc comment. The entries follow, module by module.

- **Colours** (`tabelline/colors`): 13 names
  - `Rgb` type
  - `isCssColorName` func: One of the 148 colour names of CSS.
  - `rColor` func: The hex value of one of R's colour names beyond CSS's, which gt and Great Tables take (`sienna4` is "#8B472...
  - `cssColor` func: A colour as CSS reads it: one of R's names becomes its hex value, anything else (a hex value, a CSS name, `...
  - `parseColor` func: `#rgb`, `#rrggbb`, any of the 148 CSS colour names (`darkgreen`, `rebeccapurple`) or of R's (`sienna4`, `gr...
  - `toHex` func
  - `mix` func
  - `interpolate` func: The colour at `t` in 0..1 along a palette of evenly spaced stops.
  - `luminance` func
  - `contrast` func
  - `idealTextColor` func: Dark or light text, whichever contrasts more with `fill`.
  - `palettes` const
  - `palette` func: A named palette (see `palettes`), or a comma-separated list of colours.
- **Data, text and selectors** (`tabelline/core`): 107 names
  - `ValueKind` type
  - `Value` type: One cell of the table data.
  - `null` func
  - `toValue` func: A seq is a list: `toValue(@[1, 4, 2])`.
  - `list` func: A list of values in one cell: `list(1, 4, 2)`.
  - `record` func: A record in one cell, its fields in order: `record({"x": toValue(1), "y": toValue(2)})`.
  - `isNull` func
  - `isNumber` func
  - `isList` func
  - `isRecord` func
  - `toFloat` func: The value as a float; NaN for anything else that is not a number.
  - `len` func: The number of items of a list or fields of a record; 0 for any other value.
  - `[]` func: An item of a list: `v[0]`.
  - `contains` func: Whether a record has a field `name`: `"x" in v`.
  - `.` template: A field of a record by its name: `v.x` is `v["x"]`.
  - `$` func
  - `==` func
  - `<` func: Numbers and texts in order; lists item by item, as words are; anything else is not ordered.
  - `<=` func
  - `cellNames` func: The names in a cell, for verbs that take several (icons, images, flags): the items of a list, or the parts ...
  - `Column` type
  - `TableData` type: Named columns of equal length.
  - `nrows` func
  - `ncols` func
  - `names` func
  - `colIndex` func
  - `hasColumn` func
  - `kindOf` func: The kind of a column: the kind of its non-missing values (vkFloat when ints and floats mix).
  - `isNumeric` func
  - `addColumn` proc
  - `toTableData` proc: Rows as Nim objects or named tuples, one field per column: `toTableData(@[(name: "Mercury", moons: 0), (nam...
  - `toValues` func
  - `parseCsv` proc: A CSV text with a header line.
  - `readCsv` proc: `parseCsv` of a file.
  - `Row` type: One row of the data, as seen by a row predicate (`where`): `it.mass`, `it.index`.
  - `TextKind` type
  - `Text` type: A label or note: plain text (escaped when rendered), Markdown, or raw HTML.
  - `md` func · gt `md()`: Markdown text, for labels and notes: `md("**Mass** (10^24^ kg)")`.
  - `html` func · gt `html()`: Raw HTML text, used as is.
  - `toText` converter
  - `toText` func: A Text is already one (so a `colsLabel` block can mix `"Mass"` and `md("...")`).
  - `isEmpty` func
  - `ColSelKind` type
  - `ColSel` type: Which columns a verb applies to.
  - `toColSel` converter
  - `cols` func
  - `everything` func
  - `startsWith` func: The columns whose name starts with any of `prefixes`: `startsWith(["pop_", "pct_"])` (in brackets: `startsW...
  - `endsWith` func
  - `containing` func
  - `numeric` func
  - `textual` func
  - `positions` func: Columns by their place in the data, from 0, as rows are: `positions(0, 2)`; a negative place counts from th...
  - `+` func: The columns of `a` or `b`: `startsWith("pop") + "year"`.
  - `-` func: The columns of `a` that are not in `b`: `numeric() - "year"`.
  - `&` func: The columns of both `a` and `b`: `startsWith("pop") & numeric()`.
  - `ofKind` func: The columns whose values are of these kinds (a missing value counts as any kind), as gt's `where(is.logical...
  - `matches` func: The columns whose name passes `test`, any proc of a string, as gt's `matches()` (which takes a regular expr...
  - `named` template: The columns whose name, `it`, makes `cond` true: `named(it.len == 4 and it[0] == 'y')`.
  - `resolve` func
  - `RowSelKind` type
  - `RowSel` type: Which rows a verb applies to: all of them (the default), indices (`[0, 2]`, `0..3`, 0-based; `-1` or `^1` i...
  - `allRows` func
  - `toRowSel` converter: `^1` is the last row, as `-1` is.
  - `where` template: Rows where `cond` holds, with `it` the row: `where(it["type"] == "Gas giant")`.
  - `resolve` proc
  - `CellStyle` type: CSS declarations for some cells.
  - `StyleNs` type: A background colour (a hex value, a CSS or R colour name), with `alpha` from 0 (clear) to 1, as gt's `cell_...
  - `LocNs` type: A background colour (a hex value, a CSS or R colour name), with `alpha` from 0 (clear) to 1, as gt's `cell_...
  - `style` const
  - `loc` const
  - `fill` func · gt `cell_fill()`: A background colour (a hex value, a CSS or R colour name), with `alpha` from 0 (clear) to 1, as gt's `cell_...
  - `text` func · gt `cell_text()`: The text of the cells: `vAlign` is "top", "middle" or "bottom" (gt's `v_align`), `indent` a CSS length, "1....
  - `Side` type
  - `borders` func · gt `cell_borders()`
  - `css` func: Any CSS, as declarations: `style.css("letter-spacing: 0.1em; font-variant: small-caps")`.
  - `toCss` func
  - `Align` type
  - `ColRole` type
  - `ColInfo` type: The boxhead entry of one column: how its label and cells are shown.
  - `Spanner` type: A label over a run of columns; `level` 1 sits right above the column labels.
  - `RenderContext` type
  - `FormatFn` type: Turns one value into its shown text.
  - `FormatRule` type
  - `LocKind` type
  - `Target` type: A resolved location: `cells` for the body and the stub (row, column), `names` for column labels, spanners a...
  - `Loc` type: An unresolved location, from the `loc` namespace: `loc.body(cols = "mass", rows = [0])`.
  - `StyleRule` type
  - `Footnote` type
  - `TransformRule` type: A proc over the shown text of the cells at a location (`textTransform`).
  - `Aggregate` type: How a summary row sums up a column: a proc from the column's non-missing values (of the group, or of the wh...
  - `AggNs` type: Summary rows added by `summaryRows` (for some groups) or `grandSummaryRows` (`grand`).
  - `SummaryRule` type: Summary rows added by `summaryRows` (for some groups) or `grandSummaryRows` (`grand`).
  - `MergeKind` type
  - `MergeRule` type: Columns shown together in the first one (`colsMerge` and its cousins), at render time.
  - `FootnoteMarks` type
  - `TabOptions` type: Table-wide looks, like gt's `tab_options()`.
  - `Tabella` type: A display table: the data and everything said about how to show it.
  - `colInfo` func
  - `visibleData` func: The data columns shown in the body, in display order (not the stub, groups or hidden ones).
  - `hasSummaries` func
  - `hasStub` func: A stub is shown for the row names, and for the labels of summary rows (as in gt, a table with summary rows ...
  - `hasRowNames` func
  - `hasGroups` func
  - `stubColumns` func: The columns of the stub, the highest level first: `tabella(data, rownameCol = ["mfr", "model"])` gives `@["...
  - `groupAsColumn` func: The group labels are a column of the stub (`rowGroupAsColumn`), not a row above each group.
  - `stubWidth` func: How many columns the stub takes: the group labels (as a column), the higher levels, the row names (or the s...
  - `PatternRef` type: One `{...}` of a merge pattern: `{2}` is column 2, `{2.lo}` the field `lo` of the record in column 2, and `...
  - `patternRefs` func: The `{...}` of `pattern`, with the text inside the braces; a `{` with no `}` is text.
- **Locales** (`tabelline/localize`): 13 names
  - `Locale` type
  - `dateSkeletons` const: The flexible date styles of gt: each is a CLDR skeleton, written in each locale's own order.
  - `timeSkeletons` const: The flexible time styles of gt that need no time zone.
  - `normalizeTag` func: "de_CH", "DE-ch" and "de-CH" are the same locale.
  - `hasLocale` func: Whether CLDR has data for this tag (after `normalizeTag`).
  - `getLocale` func: The conventions of a locale: `getLocale("it").months[0]` is "gennaio".
  - `skeleton` func: The pattern of a flexible style in this locale ("" when it is not one).
  - `currencyInfo` func: The English name, the symbol and the decimals of an ISO 4217 code: `currencyInfo("JPY")` is ("Japanese Yen"...
  - `isCurrency` func: Whether CLDR knows this ISO 4217 code.
  - `splitPattern` func: The text before and after the number in a CLDR number pattern (its positive part): "#,##0.00 ¤" is ("", " ...
  - `negativePattern` func: The text around a negative number: the pattern's negative part, or "" (a minus sign is added).
  - `withCurrency` func: The number and the symbol, placed and spaced as the pattern says.
  - `formatPattern` func: Writes a date or a time with a CLDR pattern: `formatPattern(getLocale("it"), "d MMMM y", 2026, 11, 7)` is "...
- **Formats** (`tabelline/formats`): 72 names
  - `Marks` type
  - `localeMarks` func: Digit group and decimal marks for a locale, from CLDR: `localeMarks("it")` is (".", ","), `localeMarks("de-...
  - `escapeHtml` func
  - `sigfigDecimals` func: How many decimals show `nSigfig` significant figures of `x`: 3 for 0.01234 and 3 figures, 0 for 12345 (whic...
  - `formatNumber` func: `formatNumber(1234.5678)` is "1,234.57"; `formatNumber(1234.5, 1, sepMark = ".", decMark = ",")` is "1.234,5".
  - `formatCompact` func: Large numbers with a suffix: 1234567 is "1.2M"; with `nSigfig = 3`, "1.23M".
  - `toSuperscript` func: `toSuperscript("-2")` is "⁻²" (`^s` when a character has no superscript).
  - `toSubscript` func: `toSubscript("2")` is "₂" (`_s` when a character has no subscript).
  - `formatScientific` func: `formatScientific(5.97e24)` is "5.97 × 10²⁴"; `expStyle` "e" is "5.97e24" and "E" "5.97E24", as gt's `e...
  - `formatPercent` func: `formatPercent(0.123)` is "12.3%"; `pattern` is a locale's (`getLocale("fr").percentPattern` is "#,##0 %", ...
  - `currencySymbol` func: The symbol of an ISO 4217 code, from CLDR (English): "EUR" is "€", "CHF" is "CHF", "CAD" is "CA$".
  - `formatCurrency` func: `formatCurrency(49.95, "EUR")` is "€49.95".
  - `formatRoman` func: `formatRoman(2026)` is "MMXXVI".
  - `dateStyles` const: gt's fixed date styles, as CLDR patterns, with names in the locale's language.
  - `formatDate` proc: An ISO date ("2015-01-15", or the date part of a datetime) in one of `dateStyles`, a flexible style of `dat...
  - `formatInteger` func: `formatInteger(1234.6)` is "1,235"; `locale = "it"`, "1.235".
  - `formatEngineering` func: Scientific notation with exponents in steps of three: `formatEngineering(12345)` is "12.35 × 10³".
  - `formatNumberSi` func: A number with an SI prefix: `formatNumberSi(12345, "g")` is "12.35 kg".
  - `formatPartsper` func: Fractions as parts per thousand ("per-mille", ‰), ten thousand ("per-myriad", ‱), hundred thousand ("pc...
  - `formatBytes` func: Sizes in bytes: `formatBytes(1500)` is "1.5 kB", `formatBytes(1536, "binary")` is "1.5 KiB".
  - `formatIndex` func: Letters for 1, 2, 3, ...: "A", "B", ...
  - `formatSpelledNum` func: Numbers from zero to one hundred in English words: `formatSpelledNum(42)` is "forty-two"; other numbers sta...
  - `timeStyles` const: Named time styles: 14:35:00, 14:35, 2:35:00 PM, 2:35 PM, 2 PM, 14:35, 14:35:00.
  - `formatTime` func: A time ("14:35", "14:35:07", or the time of an ISO datetime) in one of `timeStyles` or `timeSkeletons`, wit...
  - `strftimeToCldr` func: A strftime format (`"%Y-%m-%d %H:%M"`, as Python's and Great Tables' `format_str`) as a CLDR pattern: %Y %y...
  - `formatDatetime` proc: An ISO datetime ("2026-11-07T14:35:00" or "2026-11-07 14:35") as a date and a time, in the date and time st...
  - `formatDuration` func: A length of time in weeks, days, hours, minutes and seconds: `formatDuration(7503)` is "2h 5m 3s"; `duratio...
  - `tfStyles` const: Named pairs of texts for booleans, as gt's `tf_style`.
  - `formatTf` func: A boolean in one of `tfStyles`: `formatTf(true, "yes-no")` is "yes".
  - `formatFlag` func: Country codes (ISO 3166-1, two or three letters, comma or space separated) as flag emoji: `formatFlag("IT")...
  - `inlineMarkdown` func: Inline Markdown: `**bold**` and `__bold__`, `*italic*` and `_italic_`, `~~struck~~`, `` `code` ``, `[text](...
  - `mdToHtml` func: Markdown with paragraphs (a blank line between them) and lists (`- item`, `1.
  - `textToHtml` func
  - `decodeEntities` func: The text of HTML entities: `&mdash;` is "—", `&#8212;` and `&#x2014;` too (for text and Markdown output);...
  - `textToPlain` func
  - `fmt` proc · gt `fmt()`: The general formatter: `fn(value, ctx)` gives the text of each (non-missing) cell.
  - `fmtNumber` proc · gt `fmt_number()`: Numbers with a fixed number of decimals and digit grouping: `fmtNumber("mass", decimals = 1)`.
  - `fmtInteger` proc · gt `fmt_integer()`
  - `fmtPercent` proc · gt `fmt_percent()`: Fractions as percentages: 0.123 is "12.3%" (`scaleValues = false` for values already in %), "12,3 %" in Fre...
  - `fmtCurrency` proc · gt `fmt_currency()`: Numbers as amounts of a currency (any ISO 4217 code), with its symbol and its decimals, in the locale's way...
  - `fmtScientific` proc · gt `fmt_scientific()`: Scientific notation: 5.97e24 is "5.97 × 10²⁴"; `expStyle` "e" or "E" writes "5.97e24".
  - `fmtRoman` proc · gt `fmt_roman()`
  - `fmtDate` proc · gt `fmt_date()`: ISO date strings in a `dateStyles` style ("month_day_year", ...), a flexible style ("yMMMd"), or a std/time...
  - `fmtMarkdown` proc · gt `fmt_markdown()`: Cell text as Markdown (inline: emphasis, code, links).
  - `subMissing` proc · gt `sub_missing()`: Shows missing values as `missingText` (by default they are blank): a text, or Markdown, `md("**STABLE**")`,...
  - `subZero` proc · gt `sub_zero()`: Shows zeros as `zeroText`.
  - `fmtEngineering` proc · gt `fmt_engineering()`: Scientific notation with exponents in steps of three: 12345 is "12.35 × 10³".
  - `fmtNumberSi` proc · gt `fmt_number_si()`: Numbers with SI prefixes and a unit: 12345 with `unit = "g"` is "12.35 kg".
  - `fmtPartsper` proc · gt `fmt_partsper()`: Fractions as parts per thousand (‰), ten thousand (‱), million (ppm), ...
  - `fmtBytes` proc · gt `fmt_bytes()`: Sizes in bytes: kB, MB, GB (`standard = "decimal"`) or KiB, MiB, GiB (`"binary"`).
  - `fmtIndex` proc · gt `fmt_index()`: Whole numbers as letters: 1 is "A", 27 is "AA" (see `formatIndex`).
  - `fmtSpelledNum` proc · gt `fmt_spelled_num()`: Whole numbers from zero to one hundred in English words.
  - `fmtTime` proc · gt `fmt_time()`: Times ("14:35:00", or the time of a datetime) in one of `timeStyles` or `timeSkeletons`.
  - `fmtDatetime` proc · gt `fmt_datetime()`: ISO datetimes as a date and a time, each in its style, or with a strftime `formatStr` (`"%Y/%m/%d %H:%M"`),...
  - `fmtDuration` proc · gt `fmt_duration()`: Numbers as lengths of time: 7503 seconds is "2h 5m 3s" (see `formatDuration`).
  - `fmtUrl` proc · gt `fmt_url()`: Addresses as links: the address is the text, unless `label` is given or the cell is a Markdown link `[label...
  - `fmtEmail` proc · gt `fmt_email()`: Email addresses as `mailto:` links, as `fmtUrl` does for web addresses.
  - `countryName` func: The English name of a country or territory by its two- or three-letter code (ISO 3166-1), from Unicode CLDR...
  - `circleFlag` func: The round flag of a two- or three-letter country code, as inline SVG (HatScripts' circle-flags, MIT, which ...
  - `fmtFlag` proc · gt `fmt_flag()`: Two-letter (or three-letter) country codes as flags, one or several (a list, or separated by commas).
  - `subSmallVals` proc · gt `sub_small_vals()`: Shows numbers closer to zero than `threshold` (but not zero) as `smallPattern`, with the threshold for `{x}...
  - `subLargeVals` proc · gt `sub_large_vals()`: Shows numbers at or beyond `threshold` as `largePattern`: ">=1T".
  - `subValues` proc · gt `sub_values()`: Shows the values for which `fn` holds as `replacement`.
  - `fmtTf` proc · gt `fmt_tf()`: Booleans as two texts: a named `tfStyle` ("true-false", "yes-no", "check-mark", "circles", "arrows", ...
  - `formatFraction` func: A number as a mixed fraction: `formatFraction(2.25)` is "2 1/4", `formatFraction(0.333)` is "1/3".
  - `formatBins` proc: A bin written as an interval, `"[10,20)"` or `"(0,5]"`, as a range: "10–20".
  - `formatCountry` func: Country codes (comma or space separated) as names: `formatCountry("IT, FR")` is "Italy, France".
  - `fmtFraction` proc · gt `fmt_fraction()`: Numbers as mixed fractions: 2.25 is "2 1/4" (see `formatFraction`).
  - `fmtBins` proc · gt `fmt_bins()`: Intervals such as "[10,20)" as ranges, "10–20"; `fmt` formats both ends: `fmtBins("size", fmt = x => form...
  - `fmtPassthrough` proc · gt `fmt_passthrough()`: Values shown as they are, in a `pattern`; with `escape = false` a value is HTML.
  - `fmtCountry` proc · gt `fmt_country()`: Two- or three-letter country codes as English names, from CLDR: "IT" is "Italy".
  - `fmtAuto` proc · gt `fmt_auto()`: A format for each column, from its values: numbers with as many decimals as they need (up to 3), very small...
- **Units** (`tabelline/units`): 6 names
  - `formatChem` func: A chemical formula or reaction, in gt's notation: `formatChem("CuSO4 * 5H2O")` is "CuSO₄⋅5 H₂O", `for...
  - `formatUnits` func: Units in gt's notation: `formatUnits("kg/m^3")` is "kg/m³", `formatUnits("m /s")` is "m s⁻¹", `formatUn...
  - `withUnits` func: A label with units between `{{` and `}}`: the units are formatted, the rest goes through `plain`.
  - `fmtUnits` proc · gt `fmt_units()`: Cells written in gt's units notation, shown as units: `"m s^-2"` is "m s⁻²".
  - `fmtChem` proc · gt `fmt_chem()`: Cells written as chemical formulas or reactions: `"H2SO4"` is "H₂SO₄".
  - `colsUnits` proc · gt `cols_units()`: Units for column labels, in gt's notation: `colsUnits({"density": "kg/m^3"})` shows the label "density, kg/...
- **The verbs** (`tabelline/verbs`): 99 names
  - `initTabella` proc: A display table for `data`.
  - `tabHeader` proc · gt `tab_header()`
  - `tabStubhead` proc · gt `tab_stubhead()`
  - `tabSpanner` proc · gt `tab_spanner()`: A label over `columns`.
  - `tabSpannerDelim` proc · gt `tab_spanner_delim()`: Spanners and labels from column names: `"size.mass"` gets the label "mass" under a spanner "size".
  - `tabCaption` proc · gt `tab_caption()`: A caption for the table (an HTML `<caption>`), for screen readers and for figures.
  - `tabSourceNote` proc · gt `tab_source_note()`
  - `tabRowGroup` proc · gt `tab_row_group()`: Puts `rows` in a group (made when it is new).
  - `tabStub` proc: Chooses the stub (and the row groups) of a table already made, as Great Tables' `tab_stub(rowname_col, grou...
  - `rmHeader` proc · gt `rm_header()`: Removes the title and the subtitle.
  - `rmStubhead` proc · gt `rm_stubhead()`
  - `rmCaption` proc · gt `rm_caption()`
  - `rmSpanners` proc · gt `rm_spanners()`: Removes the spanners with these labels, or at these levels; with neither, every spanner.
  - `rmFootnotes` proc · gt `rm_footnotes()`: Removes the footnotes at these indices (0-based, in the order they were added), or all.
  - `rmSourceNotes` proc · gt `rm_source_notes()`: Removes the source notes at these indices (0-based), or all.
  - `title` func
  - `subtitle` func
  - `stubhead` func
  - `columnLabels` func
  - `spanners` func
  - `stub` func: The stub's cells of `rows`; with `labels`, the rows whose stub reads one of them (`loc.stub(labels = ["bana...
  - `rowGroups` func: The groups of these rows: `loc.rowGroups(rows = where(it.mass > 100))`, as Great Tables' `loc.row_groups(ro...
  - `body` func: The data cells of `cols` and `rows`.
  - `sourceNotes` func
  - `header` func: The title and the subtitle together.
  - `columnHeader` func: The stub head, the spanners and the column labels together.
  - `footer` func: The footnotes and the source notes together.
  - `spannerLabels` func: The same as `loc.spanners`, by Great Tables' name.
  - `footnotes` func
  - `summary` func: The cells of the summary rows of `groups` (all, by default), in `columns`, for the rows labelled `rows` (al...
  - `summaryStub` func: The labels of the summary rows, in the stub.
  - `grandSummary` func: The cells of the grand summary rows.
  - `grandSummaryStub` func: The labels of the grand summary rows, in the stub.
  - `resolve` proc
  - `tabStyle` proc: Styles the cells at `locations`: `tabStyle(style.fill("#FFF3B0"), loc.body(rows = [2]))`.
  - `tabFootnote` proc: A note in the footer, marked at each of `locations` (no location: a plain footnote, no mark).
  - `textTransform` proc · gt `text_transform()`: Changes the shown text at `locations` (by default the body) with a proc: for cells the proc gets the format...
  - `textReplace` proc · gt `text_replace()`: Replaces every `pattern` (plain text, not a regex) with `replacement`.
  - `textCaseMatch` proc · gt `text_case_match()`: Changes texts by cases, `{"old": "new"}`: with `replace = "all"` a text equal to a case becomes its new tex...
  - `colsLabel` proc · gt `cols_label()`: `colsLabel({"mass": "Mass", "diameter": "Diameter"})`.
  - `colsAlign` proc · gt `cols_align()`
  - `colsWidth` proc · gt `cols_width()`: CSS widths: `colsWidth({"name": "120px", "notes": "30%"})`.
  - `colsHide` proc · gt `cols_hide()`
  - `colsUnhide` proc · gt `cols_unhide()`
  - `colsMove` proc · gt `cols_move()`: Moves `columns` (in their given order) right after the column `after`.
  - `colsLabelWith` proc · gt `cols_label_with()`: Relabels columns with a proc over their labels: `colsLabelWith(everything(), capitalizeAscii)`.
  - `colsMoveToEnd` proc · gt `cols_move_to_end()`
  - `colsReorder` proc: Puts `columns` in the given order, in the places they hold: the other columns stay put.
  - `colsMoveToStart` proc · gt `cols_move_to_start()`
  - `rowOrder` proc · gt `row_order()`: Shows the rows sorted by `columns` (the first decides, the next break ties), within their groups; `reverse`...
  - `rowGroupOrder` proc · gt `row_group_order()`: Shows the row groups in this order; groups not listed follow, as they were.
  - `agg` const
  - `sum` func: The sum of the numbers (an int when they are all ints).
  - `mean` func: The mean of the numbers.
  - `median` func: The median of the numbers (the mean of the two middle ones when they are even).
  - `std` func: The standard deviation of the numbers, of a sample (divided by n - 1, as R's `sd` and Polars' `std`).
  - `min` func: The smallest value (of numbers, or of texts).
  - `max` func: The largest value (of numbers, or of texts).
  - `count` func: How many values are not missing.
  - `aggregate` proc: An aggregate of your own, from a proc of the non-missing values to one value: `aggregate(proc (vs: seq[Valu...
  - `toFormatFn` proc: A format from a proc of a float (`(x: float) => formatNumber(x, 1)`), of a value (`(v: Value) => $v`), both...
  - `summaryRows` proc · gt `summary_rows()`: Adds rows that sum up each row group (or the `groups` listed), one for each aggregate in `fns`, labelled in...
  - `grandSummaryRows` proc · gt `grand_summary_rows()`: Adds rows that sum up the whole table, every row of every group, one for each aggregate in `fns`: at the bo...
  - `dataColor` proc · gt `data_color()`: Colours cells by value, each column on its own: a number column along `palette` from the low to the high en...
  - `tabOptions` macro · gt `tab_options()`: Sets any of `TabOptions`' fields by name, checked when compiling: `t.tabOptions(rowStriping = true, heading...
  - `optRowStriping` proc · gt `opt_row_striping()`
  - `optAlignTableHeader` proc · gt `opt_align_table_header()`
  - `optAllCaps` proc · gt `opt_all_caps()`: Small capitals (upper case, smaller and bolder) in the column labels, the stub and the row group labels, or...
  - `optTableFont` proc · gt `opt_table_font()`: The table's font, as a CSS font stack: `optTableFont(systemFonts("humanist"))`.
  - `fontStackNames` const: The names `systemFonts` knows, in Great Tables' order.
  - `systemFonts` func · gt `system_fonts()`: One of Great Tables' fifteen font stacks, fonts that are on most systems, as CSS text: `systemFonts("old-st...
  - `defaultFonts` func · gt `default_fonts()`: gt's default font stack, as CSS text (tabelline's default, `tableFontNames`, is close to it).
  - `CssTheme` type: Where a table takes its colours and font from (`optCssTheme`): for each, the name of a CSS variable of the ...
  - `cssTheme` func: A theme to keep and reuse with `optCssTheme(theme)`.
  - `optCssTheme` proc: Every colour of the table, and its font, from `theme`: see `optCssTheme()`.
  - `optVerticalPadding` proc · gt `opt_vertical_padding()`: Scales the vertical padding of the heading, the column labels and the rows (gt: 0 to 3).
  - `optHorizontalPadding` proc · gt `opt_horizontal_padding()`: Scales the horizontal padding of the heading, the column labels and the rows (gt: 0 to 3).
  - `optTableOutline` proc · gt `opt_table_outline()`: A line all around the table.
  - `optStylize` proc · gt `opt_stylize()`: A ready-made look, gt's and Great Tables' `opt_stylize()`: `style` 1 to 6, in one of `color` "blue", "cyan"...
  - `optTableLines` proc · gt `opt_table_lines()`: The table's lines: `"all"` adds vertical lines between cells, `"none"` takes every line away, `"default"` b...
  - `optFootnoteMarks` proc · gt `opt_footnote_marks()`: By gt's names: "numbers", "letters", "LETTERS", "standard" (*, †, ‡, §) or "extended" (with ‖, ¶).
  - `optFootnoteSpec` proc · gt `opt_footnote_spec()`: How marks look, in the table (`specRef`) and in the footer (`specFtr`): "^" raised, "i" italic, "b" bold, "...
  - `optFootnoteOrder` proc · gt `opt_footnote_order()`: The order of the footnotes: marked ones first (the default), last ("marks_last"), or as they were added ("p...
  - `optCss` proc · gt `opt_css()`: CSS for the table, scoped to it (rules that start with `#` are left as they are); `add = false` replaces wh...
  - `colsMerge` proc · gt `cols_merge()`: Shows the formatted values of `columns` together, in the first one, with `pattern`: `{1}`, `{2}`, ...
  - `colsMergeUncert` proc · gt `cols_merge_uncert()`: A value and its uncertainty in one cell: `12.3 ± 0.4` (just the value when the uncertainty is missing).
  - `colsMergeRange` proc · gt `cols_merge_range()`: A range in one cell, with an en dash: `1990–2000` (just the start when the end is missing).
  - `colsMergeNPct` proc · gt `cols_merge_n_pct()`: A count and its percentage in one cell: `12 (4.5%)`; a zero count shows no percentage.
  - `colsAdd` proc · gt `cols_add()`: Adds a column: at the end, or `before` or `after` another one.
  - `summaryColumns` proc · gt `summary_columns()`: Adds a column for each aggregate in `fns`, summing up `columns` across each row: `summaryColumns(fns = {"to...
  - `rowsAdd` proc · gt `rows_add()`: Adds rows, given as a table of some of the columns (the others are missing): at the end, or `before` or `af...
  - `rowsHide` proc · gt `rows_hide()`: Hides rows: they are not shown, nor summed up by summary rows, but stay in the data.
  - `rowsUnhide` proc · gt `rows_unhide()`: Shows hidden rows again (all of them, by default).
  - `tabStubIndent` proc · gt `tab_stub_indent()`: Indents the stub cells of `rows` at a level from 0 (none) to 5.
  - `colsAlignDecimal` proc · gt `cols_align_decimal()`: Aligns the numbers of `columns` on their decimal mark, by padding each formatted cell on the right with fig...
  - `colsLabelRotate` proc: Turns the labels of `columns` on their side, for narrow columns: read from the bottom up (`"sideways-lr"`) ...
  - `fromColumn` func · gt `from_column()`: A style value taken, for each cell, from `column` of the same row: `tabStyle(style.fill(fromColumn("colour"...
  - `tabStyleBody` proc · gt `tab_style_body()`: Styles the body cells whose value is one of `values` (compared as text, or as numbers), contains `pattern`,...
  - `initTabellaPreview` proc: A preview of a big table: its first `topN` rows, its last `bottomN` rows and the rows of `moreRows` (not fr...
- **Building a table** (`tabelline/build`): 30 names
  - `BuiltRow` type
  - `BuiltSummary` type
  - `BuiltGroup` type
  - `Built` type
  - `cellKey` func
  - `colKey` func
  - `spannerKey` func
  - `groupKey` func
  - `summaryKey` func: A cell of a group's summary row (the stub cell when `col` is "").
  - `grandKey` func
  - `renderText` func
  - `renderLabel` func: A label (of a column, a spanner, the stubhead): like `renderText`, and units between `{{` and `}}` are form...
  - `columnLabel` func: The label of a column, with its units (`colsUnits`), placed by the column's pattern or else by `unitsPatter...
  - `formatValue` proc: `v` as the cell at `row` of `col` would be formatted: the last format that covers the cell.
  - `formatCell` proc: The shown text of one cell: the last format that covers it, then any substitution.
  - `markText` func: The mark of footnote `n` (from 1): numbers, letters, capitals, the four standard symbols (*, †, ‡, §) ...
  - `wrapMark` func: `s` inside the brackets that `spec` asks for: "(" gives "(1)", "[" gives "[1]".
  - `markSpanHtml` func: A mark (or marks) as HTML: raised with "^", italic with "i", bold with "b".
  - `keysOf` proc: The location keys a target covers, as the renderers name them.
  - `displayOrder` proc: The rows of the data in the order they are shown (before grouping), without hidden rows.
  - `fillPattern` func: `pattern` with each `{...}` replaced by `lookup` (its text, and whether the value is missing); a part in `<...
  - `shownCell` proc: The text of a body cell: merged with other columns (`colsMerge`) or formatted.
  - `transformCell` proc: The shown text of a cell after the text transforms that cover it, in the order given.
  - `build` proc
  - `marksHtml` proc
  - `marksText` proc
  - `footMarkHtml` proc
  - `footMarkText` proc
  - `spannerLevels` func: How many rows of spanners sit over the visible columns.
  - `spannerAt` func: The index of the spanner over `col` at `level`, or -1.
- **HTML** (`tabelline/render_html`): 6 names
  - `nanoplotCss` const
  - `tabellaCss` let: The CSS of every table, the same for all of them: each value is a CSS variable named after its option (`--t...
  - `tabellaStyle` let: `tabellaCss` in a `<style>` element, as `toHtml` writes it.
  - `styleVars` proc: The variables of the options `o` changes, for the `style` of the table's `<div>`: changed from the defaults...
  - `toHtml` proc: The table as an HTML fragment (a `<div>` holding the `<table>`), ready to put in a page.
  - `save` proc: Writes the table as a standalone HTML page, as gt's `gtsave("x.html")`.
- **Text and Markdown** (`tabelline/render_text`): 3 names
  - `toText` proc: The table drawn with box characters, like a dataframe printed at the console, but with the formats, the stu...
  - `$` proc: `echo t` draws the table.
  - `toMarkdown` proc: A GitHub-flavoured Markdown table, with the title above and the notes below.
- **Reading a table back** (`tabelline/extract`): 3 names
  - `extractCells` proc · gt `extract_cells()`: The shown text of the body cells of `columns` and `rows`, column by column, each in the order the table sho...
  - `extractBody` proc · gt `extract_body()`: The body as a table of texts, in the order shown: a column `group` (when the table has row groups), the stu...
  - `extractSummary` proc · gt `extract_summary()`: The summary rows as a table of texts: `group` ("" for a grand summary row), `label`, and a cell for each vi...
- **Pictures** (`tabelline/pictures`): 10 names
  - `Icon` type: A Font Awesome icon: its name, style ("solid", "regular" or "brands"), label and drawing (an SVG path on a ...
  - `findIcon` proc: The icon for a name: a short name ("star", the regular style when there are two), a full name ("fas fa-star...
  - `hasIcon` proc: Whether `name` is a Font Awesome Free icon (see `findIcon`).
  - `icon` proc: The icon for a name (see `findIcon`); raises `ValueError` for an unknown one.
  - `iconSvg` proc: An icon as inline SVG, `height` high and as wide as its shape: `iconSvg("star")`.
  - `fmtIcon` proc · gt `fmt_icon()`: Names of Font Awesome Free icons as icons: "star", or several, in a list or separated by commas ("hard-driv...
  - `imageDataUrl` proc: A file as a data URL, its type from its extension: `imageDataUrl("moon.png")` is "data:image/png;base64,...".
  - `fmtImage` proc · gt `fmt_image()`: File names as images: each cell holds one or more names (a list, or separated by commas), found in `path` a...
  - `localImage` proc · gt `local_image()`: A local image as `Text`, for a title, a label, a note or a cell of `fmtMarkdown`: the file is read now and ...
  - `webImage` proc · gt `web_image()`: An image on the web as `Text`, the address left as it is (the page loads it), as gt's `web_image()`.
- **Nanoplots** (`tabelline/nanoplots`): 14 names
  - `NanoplotOptions` type: The look of a nanoplot, after Great Tables' `nanoplot_options()` (see `nanoplotOptions`).
  - `at` func: The value of a per-point option for point `i`: the list repeats.
  - `nanoplotOptions` func · gt `nanoplot_options()`
  - `nanoplotValues` func: The values of a nanoplot cell: a number, a list of numbers (`@[1, 4, 2]`), a record with the values in `y` ...
  - `nanoplotXValues` proc: The places of the values on the x axis: the field `x` of a record (`(x: @[1, 2, 4], y: @[3, 5, 4])`, Great ...
  - `plotTypes` const: The kinds of nanoplot: "shape" is tabelline's, not Great Tables'.
  - `refKeywords` const: The keywords of a reference line or area: a statistic of the values.
  - `nanoplotLabel` proc: A value as a nanoplot writes it, short, as Great Tables does: "0", integers below 100 as they are, 3 signif...
  - `shapeSide` func: The side of the square a shape fills: its width or its height, the larger.
  - `nanoplotSummary` proc: The values in words, for a screen reader: "Line plot of 8 values from 12 to 47, ending at 30".
  - `nanoplotSvg` proc: One nanoplot as inline SVG: a line, bar or box plot of the values `y` (NaN for a missing one), or with `sin...
  - `nanoplotText` proc: A nanoplot in text: a sparkline of the values ("▁▃▅█ 1–9", on the axis of `expandY` too), a bar o...
  - `fmtNanoplot` proc: Nanoplots of the values in each cell (see `nanoplotValues`: a list, a record of `x` and `y`, or a text of n...
  - `colsNanoplot` proc · gt `cols_nanoplot()`: A new column of nanoplots, one per row, of the values of several `columns` (in their order): after gt's `co...
- **Everything at once** (`tabelline`): 3 names
  - `tabella` macro: `tabella(data, rownameCol = "name")` is a table for `data` (see `initTabella`), and with a body, `tabella(d...
  - `tabellaPreview` macro: `tabellaPreview(data, topN = 5, bottomN = 1)` is a preview of a big table (see `initTabellaPreview`), and w...
  - `tableData` macro: Columns as `name: [values]` lines, each value converted on its own, so a column can mix numbers with `nil` ...
- **Datasets** (`tabelline/datasets`): 13 names
  - `planetsCsv` const: Units: mass 10^24 kg, diameter km, density kg/m³, gravity m/s², day length hours, distance from the Sun 1...
  - `exibbleCsv` const
  - `isoleCsv` const: island, country, area (km²), population, city (the largest).
  - `cittaCsv` const: city, state (three-letter code), population within city limits, counted (the date of the count).
  - `gtcars` proc · gt `gtcars()`: 47 deluxe automobiles from the 2014-2017 model years, with their performance and price (gt's `gtcars`).
  - `countrypops` proc · gt `countrypops()`: The population of every country, every year from 1960 to 2022 (World Bank; gt's `countrypops`).
  - `illness` proc · gt `illness()`: Daily tests of a patient with yellow fever, days 3 to 9, with their normal ranges (gt's `illness`).
  - `metro` proc · gt `metro()`: The stations of the Paris Metro, with their lines and passengers in 2021 (gt's `metro`).
  - `planets` proc
  - `exibble` proc · gt `exibble()`
  - `isole` proc
  - `citta` proc
  - `tavolaPitagorica` proc: An n×n times table: a column `×` with 1..n, then one column per factor ("1" ..
- **In nimib** (`tabelline/nimib`): 8 names
  - `NbTable` type
  - `newNbTable` proc
  - `nbtableToHtml` proc
  - `dump` method
  - `nbTableToMd` func
  - `tableHtml` proc: The HTML of `t` for this page: with `tabellaCss` the first time on the page, without it afterwards.
  - `table` proc
  - `nbTable` macro: Adds a table to the page: `nbTable t` for a table `t`, and `nbTable data` for a table of `data` as it is.
- **From nanuq** (`tabelline/nanuq`): 2 names
  - `toTableData` proc: Copies every column of `df`, in order: integers become ints, floats floats, booleans bools, strings strings...
  - `initTabella` proc: A display table for a nanuq DataFrame, so that `tabella(df): body` works as for any data.

## Colours (`tabelline/colors`)

Colours for `dataColor`: hex parsing, palettes, linear interpolation and the text colour that reads best on a fill (WCAG relative luminance).

### Rgb (type) · [#colors-Rgb](https://pietroppeter.github.io/tabelline/api/#colors-Rgb)

```nim
Rgb = tuple[r, g, b: float]
```

### isCssColorName (func) · [#colors-isCssColorName](https://pietroppeter.github.io/tabelline/api/#colors-isCssColorName)

```nim
func isCssColorName(name: string): bool
```

One of the 148 colour names of CSS.

### rColor (func) · [#colors-rColor](https://pietroppeter.github.io/tabelline/api/#colors-rColor)

```nim
func rColor(name: string): string
```

The hex value of one of R's colour names beyond CSS's, which gt and Great Tables take
(`sienna4` is "#8B4726", `grey50` "#7F7F7F"); "" for any other text.

### cssColor (func) · [#colors-cssColor](https://pietroppeter.github.io/tabelline/api/#colors-cssColor)

```nim
func cssColor(c: string): string
```

A colour as CSS reads it: one of R's names becomes its hex value, anything else (a hex
value, a CSS name, `var(--x)`) is left as it is.

### parseColor (func) · [#colors-parseColor](https://pietroppeter.github.io/tabelline/api/#colors-parseColor)

```nim
func parseColor(c: string): Rgb
```

`#rgb`, `#rrggbb`, any of the 148 CSS colour names (`darkgreen`, `rebeccapurple`) or of R's
(`sienna4`, `grey50`).

### toHex (func) · [#colors-toHex](https://pietroppeter.github.io/tabelline/api/#colors-toHex)

```nim
func toHex(c: Rgb): string
```

### mix (func) · [#colors-mix](https://pietroppeter.github.io/tabelline/api/#colors-mix)

```nim
func mix(a, b: Rgb; t: float): Rgb
```

### interpolate (func) · [#colors-interpolate](https://pietroppeter.github.io/tabelline/api/#colors-interpolate)

```nim
func interpolate(palette: openArray[string]; t: float): string
```

The colour at `t` in 0..1 along a palette of evenly spaced stops.

### luminance (func) · [#colors-luminance](https://pietroppeter.github.io/tabelline/api/#colors-luminance)

```nim
func luminance(c: Rgb): float
```

### contrast (func) · [#colors-contrast](https://pietroppeter.github.io/tabelline/api/#colors-contrast)

```nim
func contrast(a, b: Rgb): float
```

### idealTextColor (func) · [#colors-idealTextColor](https://pietroppeter.github.io/tabelline/api/#colors-idealTextColor)

```nim
func idealTextColor(fill: string; dark = "#1a1a1a"; light = "#FFFFFF"): string
```

Dark or light text, whichever contrasts more with `fill`.

### palettes (const) · [#colors-palettes](https://pietroppeter.github.io/tabelline/api/#colors-palettes)

```nim
palettes = (data: [(0, "", []), (0, "", []), (0, "", []), (0, "", []),
                   (0, "", []), (0, "", []), (0, "", []), (0, "", []), (
    8053033860643646504, "rdylgn",
    ["#D73027", "#FC8D59", "#FEE08B", "#D9EF8B", "#91CF60", "#1A9850"]),
                   (0, "", []), (0, "", []), (0, "", []), (-8928340921496638260,
    "quaderno", ["#FFFFFF", "#DCEBFA", "#A9CCF0", "#6FA3DB", "#3C6FB6"]), (
    1723379612904976973, "rdbu",
    ["#2166AC", "#92C5DE", "#F7F7F7", "#F4A582", "#B2182B"]), (0, "", []),
                   (0, "", []), (134456633375568208, "greens", ["#F7FCF5",
    "#C7E9C0", "#74C476", "#238B45", "#00441B"]), (-6731458568632991919, "reds",
    ["#FFF5F0", "#FCBBA1", "#FB6A4A", "#CB181D", "#67000D"]), (0, "", []),
                   (0, "", []), (0, "", []), (0, "", []), (0, "", []), (
    -5639196860620556009, "great-tables", ["#000000", "#DF536B", "#61D04F",
    "#2297E6", "#28E2E5", "#CD0BBC", "#F5C710", "#9E9E9E"]), (0, "", []),
                   (0, "", []), (2460717392810645242, "blues", ["#F7FBFF",
    "#C6DBEF", "#6BAED6", "#2171B5", "#08306B"]), (5823032332022599610,
    "matite", ["#E63946", "#F4A261", "#E9C46A", "#2A9D8F", "#457B9D", "#8E7DBE"]),
                   (0, "", []), (1203107158067285821, "viridis", ["#440154",
    "#3B528B", "#21908C", "#5DC963", "#FDE725"]), (0, "", []), (
    2396891131824504447, "pastelli", ["#FFF3B0", "#FFD6A5", "#FFADAD",
                                      "#E4C1F9", "#A0C4FF", "#9BF6FF", "#CAFFBF"])],
            counter: 10)
```

### palette (func) · [#colors-palette](https://pietroppeter.github.io/tabelline/api/#colors-palette)

```nim
func palette(name: string): seq[string]
```

A named palette (see `palettes`), or a comma-separated list of colours.

## Data, text and selectors (`tabelline/core`)

The data model of tabelline.

### ValueKind (type) · [#core-ValueKind](https://pietroppeter.github.io/tabelline/api/#core-ValueKind)

```nim
ValueKind = enum
  vkNull, vkBool, vkInt, vkFloat, vkString, vkList, vkRecord
```

### Value (type) · [#core-Value](https://pietroppeter.github.io/tabelline/api/#core-Value)

```nim
Value = object
  case kind*: ValueKind
  of vkNull:
    nil
  of vkBool:
    b*: bool
  of vkInt:
    i*: int
  of vkFloat:
    f*: float
  of vkString:
    s*: string
  of vkList:
    items*: seq[Value]
  of vkRecord:
    fields*: seq[(string, Value)]
```

One cell of the table data. `vkNull` is a missing value. A cell can hold more than one
value: a list (`@[1, 4, 2]`) or a record (`(x: 1, y: 2)`), with fields in order.

### null (func) · [#core-null](https://pietroppeter.github.io/tabelline/api/#core-null)

```nim
func null(): Value
```

### toValue (func) · [#core-toValue](https://pietroppeter.github.io/tabelline/api/#core-toValue)

```nim
func toValue(v: Value): Value
func toValue(x: bool): Value
func toValue(x: SomeInteger): Value
func toValue(x: SomeFloat): Value
func toValue(x: string): Value
func toValue(x: char): Value
func toValue(x: enum): Value
func toValue[T](x: Option[T]): Value
func toValue(x: typeof(nil)): Value
func toValue[T](x: seq[T]): Value
func toValue[I, T](x: array[I, T]): Value
func toValue[T: object | tuple](x: T): Value
```

A seq is a list: `toValue(@[1, 4, 2])`.

Example (spec table-parts):

```nim
let t = tabella(planets(), rownameCol = "planet"):
  colsHide everything()
  colsAdd "moons per Earth mass", proc (r: Row): Value = toValue(r.moons.toFloat / r.mass.toFloat * 5.97)
  fmtNumber "moons per Earth mass", decimals = 1
echo t
```

```text
┌─────────┬──────────────────────┐
│         │ moons per Earth mass │
╞═════════╪══════════════════════╡
│ Mercury │                  0.0 │
│ Venus   │                  0.0 │
│ Earth   │                  1.0 │
│ Mars    │                 18.6 │
│ Jupiter │                  0.3 │
│ Saturn  │                  1.5 │
│ Uranus  │                  1.9 │
│ Neptune │                  0.9 │
└─────────┴──────────────────────┘
```

### list (func) · [#core-list](https://pietroppeter.github.io/tabelline/api/#core-list)

```nim
func list(items: varargs[Value, toValue]): Value
```

A list of values in one cell: `list(1, 4, 2)`.

### record (func) · [#core-record](https://pietroppeter.github.io/tabelline/api/#core-record)

```nim
func record(fields: openArray[(string, Value)]): Value
```

A record in one cell, its fields in order: `record({"x": toValue(1), "y": toValue(2)})`.

### isNull (func) · [#core-isNull](https://pietroppeter.github.io/tabelline/api/#core-isNull)

```nim
func isNull(v: Value): bool
```

### isNumber (func) · [#core-isNumber](https://pietroppeter.github.io/tabelline/api/#core-isNumber)

```nim
func isNumber(v: Value): bool
```

### isList (func) · [#core-isList](https://pietroppeter.github.io/tabelline/api/#core-isList)

```nim
func isList(v: Value): bool
```

### isRecord (func) · [#core-isRecord](https://pietroppeter.github.io/tabelline/api/#core-isRecord)

```nim
func isRecord(v: Value): bool
```

### toFloat (func) · [#core-toFloat](https://pietroppeter.github.io/tabelline/api/#core-toFloat)

```nim
func toFloat(v: Value): float
```

The value as a float; NaN for anything else that is not a number. Raises `ValueError` for a
list or a record: they hold several values.

Example (spec table-parts):

```nim
let t = tabella(planets(), rownameCol = "planet"):
  colsHide everything()
  colsAdd "moons per Earth mass", proc (r: Row): Value = toValue(r.moons.toFloat / r.mass.toFloat * 5.97)
  fmtNumber "moons per Earth mass", decimals = 1
echo t
```

```text
┌─────────┬──────────────────────┐
│         │ moons per Earth mass │
╞═════════╪══════════════════════╡
│ Mercury │                  0.0 │
│ Venus   │                  0.0 │
│ Earth   │                  1.0 │
│ Mars    │                 18.6 │
│ Jupiter │                  0.3 │
│ Saturn  │                  1.5 │
│ Uranus  │                  1.9 │
│ Neptune │                  0.9 │
└─────────┴──────────────────────┘
```

### len (func) · [#core-len](https://pietroppeter.github.io/tabelline/api/#core-len)

```nim
func len(v: Value): int
```

The number of items of a list or fields of a record; 0 for any other value.

### [] (func) · [#core-op5B5D](https://pietroppeter.github.io/tabelline/api/#core-op5B5D)

```nim
func `[]`(v: Value; i: int): Value
func `[]`(v: Value; name: string): Value
func `[]`(d: TableData; name: string): lent Column
func `[]`(d: TableData; name: string; row: int): Value
func `[]`(r: Row; name: string): Value
```

An item of a list: `v[0]`. Raises `IndexDefect` beyond its end, `ValueError` for a value
that is not a list.

### contains (func) · [#core-contains](https://pietroppeter.github.io/tabelline/api/#core-contains)

```nim
func contains(v: Value; name: string): bool
```

Whether a record has a field `name`: `"x" in v`.

Example (spec formatting):

```nim
let dir = getTempDir()
writeFile(dir / "dot.svg", "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2 2'><circle cx='1' cy='1' r='1'/></svg>")
let d = tableData:
  pic: ["dot"]
let t = tabella(d):
  fmtImage "pic", path = dir, filePattern = "{x}.svg"
echo t
echo t.toHtml.contains("<img src=\"data:image/svg+xml;base64,")
```

```text
┌─────┐
│ pic │
╞═════╡
│ dot │
└─────┘
true
```

### . (template) · [#core-op2E](https://pietroppeter.github.io/tabelline/api/#core-op2E)

```nim
template `.`(v: Value; field: untyped): Value
template `.`(r: Row; field: untyped): Value
```

A field of a record by its name: `v.x` is `v["x"]`. A name that Value already has (`kind`,
`i`, `f`, `s`, `b`, `items`, `fields`, `len`, ...) is that, not the field: write `v["kind"]`.

### $ (func) · [#core-op24](https://pietroppeter.github.io/tabelline/api/#core-op24)

```nim
func `$`(v: Value): string
```

### == (func) · [#core-op3D3D](https://pietroppeter.github.io/tabelline/api/#core-op3D3D)

```nim
func `==`(a, b: Value): bool
func `==`(a: Value; b: SomeNumber): bool
func `==`(a: Value; b: string): bool
func `==`(a: Value; b: bool): bool
```

### < (func) · [#core-op3C](https://pietroppeter.github.io/tabelline/api/#core-op3C)

```nim
func `<`(a: Value; b: SomeNumber): bool
func `<`(a: SomeNumber; b: Value): bool
func `<`(a: Value; b: string): bool
func `<`(a, b: Value): bool
```

Numbers and texts in order; lists item by item, as words are; anything else is not ordered.

### <= (func) · [#core-op3C3D](https://pietroppeter.github.io/tabelline/api/#core-op3C3D)

```nim
func `<=`(a: Value; b: SomeNumber): bool
func `<=`(a: SomeNumber; b: Value): bool
```

### cellNames (func) · [#core-cellNames](https://pietroppeter.github.io/tabelline/api/#core-cellNames)

```nim
func cellNames(v: Value): seq[string]
```

The names in a cell, for verbs that take several (icons, images, flags): the items of a
list, or the parts of a text separated by commas.

### Column (type) · [#core-Column](https://pietroppeter.github.io/tabelline/api/#core-Column)

```nim
Column = object
  name*: string
  values*: seq[Value]
```

### TableData (type) · [#core-TableData](https://pietroppeter.github.io/tabelline/api/#core-TableData)

```nim
TableData = ref object
  columns*: seq[Column]
```

Named columns of equal length. Built once (from rows, columns or CSV) and only read.

### nrows (func) · [#core-nrows](https://pietroppeter.github.io/tabelline/api/#core-nrows)

```nim
func nrows(d: TableData): int
```

Example (spec table-data):

```nim
echo tabella(tavolaPitagorica(4), rownameCol = "×")
echo isole().nrows, " islands, ", citta().nrows, " cities; the largest: ", isole()["island", 0], ", ", citta()["city", 0]
```

```text
┌───┬───┬───┬────┬────┐
│   │ 1 │ 2 │  3 │  4 │
╞═══╪═══╪═══╪════╪════╡
│ 1 │ 1 │ 2 │  3 │  4 │
│ 2 │ 2 │ 4 │  6 │  8 │
│ 3 │ 3 │ 6 │  9 │ 12 │
│ 4 │ 4 │ 8 │ 12 │ 16 │
└───┴───┴───┴────┴────┘
194 islands, 95 cities; the largest: Sicily, Berlin
```

### ncols (func) · [#core-ncols](https://pietroppeter.github.io/tabelline/api/#core-ncols)

```nim
func ncols(d: TableData): int
```

### names (func) · [#core-names](https://pietroppeter.github.io/tabelline/api/#core-names)

```nim
func names(d: TableData): seq[string]
```

Example (spec formatting):

```nim
let d = tableData:
  codes: ["IT", "jpn", "FR, DE", "XX"]
let t = tabella(d):
  colsAdd "names", d["codes"].values
  fmtCountry "names"
echo t
```

```text
┌────────┬─────────────────┐
│ codes  │ names           │
╞════════╪═════════════════╡
│ IT     │ Italy           │
│ jpn    │ Japan           │
│ FR, DE │ France, Germany │
│ XX     │ XX              │
└────────┴─────────────────┘
```

### colIndex (func) · [#core-colIndex](https://pietroppeter.github.io/tabelline/api/#core-colIndex)

```nim
func colIndex(d: TableData; name: string): int
```

### hasColumn (func) · [#core-hasColumn](https://pietroppeter.github.io/tabelline/api/#core-hasColumn)

```nim
func hasColumn(d: TableData; name: string): bool
```

### kindOf (func) · [#core-kindOf](https://pietroppeter.github.io/tabelline/api/#core-kindOf)

```nim
func kindOf(c: Column): ValueKind
```

The kind of a column: the kind of its non-missing values (vkFloat when ints and floats mix).

### isNumeric (func) · [#core-isNumeric](https://pietroppeter.github.io/tabelline/api/#core-isNumeric)

```nim
func isNumeric(c: Column): bool
```

### addColumn (proc) · [#core-addColumn](https://pietroppeter.github.io/tabelline/api/#core-addColumn)

```nim
proc addColumn(d: TableData; name: string; values: seq[Value])
```

tabelline's own (not in gt)

### toTableData (proc) · [#core-toTableData](https://pietroppeter.github.io/tabelline/api/#core-toTableData)

```nim
proc toTableData[T: object | tuple](rows: openArray[T]): TableData
proc toTableData(columns: openArray[(string, seq[Value])]): TableData
```

Rows as Nim objects or named tuples, one field per column:
`toTableData(@[(name: "Mercury", moons: 0), (name: "Earth", moons: 1)])`.

tabelline's own (not in gt)

### toValues (func) · [#core-toValues](https://pietroppeter.github.io/tabelline/api/#core-toValues)

```nim
func toValues[T](xs: openArray[T]): seq[Value]
```

### parseCsv (proc) · [#core-parseCsv](https://pietroppeter.github.io/tabelline/api/#core-parseCsv)

```nim
proc parseCsv(text: string; sep = ','; comment = ""): TableData
```

A CSV text with a header line. Each value is read as an int, a float, a bool, a missing value
(empty, NA) or else a string; a column mixing ints and floats is a float column. A column
with a number written with a zero in front (`"0400"`, a code) stays text, as written. With a
`comment` such as `"#"`, a line that starts with it (after any spaces) is skipped, so a file
can say where its data comes from.

tabelline's own (not in gt)

Example (spec table-data):

```nim
type Pupil = object
  name: string
  stars: int
echo tabella(@[Pupil(name: "Ada", stars: 3), Pupil(name: "Bruno", stars: 1)])
let d = tableData:
  subject: ["maths", "art"]
  mark: [9, nil]
echo tabella(d)
let tavola = tableData:
  `×`: collect(for i in 1 .. 3: i)
  for j in 1 .. 3:
    $j: collect(for i in 1 .. 3: i * j)
echo tabella(tavola, rownameCol = "×")
echo tabella(parseCsv("# from a notebook\na,b\n1,2.5\n2,3\n", comment = "#"))
```

```text
┌───────┬───────┐
│ name  │ stars │
╞═══════╪═══════╡
│ Ada   │     3 │
│ Bruno │     1 │
└───────┴───────┘
┌─────────┬──────┐
│ subject │ mark │
╞═════════╪══════╡
│ maths   │    9 │
│ art     │      │
└─────────┴──────┘
┌───┬───┬───┬───┐
│   │ 1 │ 2 │ 3 │
╞═══╪═══╪═══╪═══╡
│ 1 │ 1 │ 2 │ 3 │
│ 2 │ 2 │ 4 │ 6 │
│ 3 │ 3 │ 6 │ 9 │
└───┴───┴───┴───┘
┌───┬─────┐
│ a │   b │
╞═══╪═════╡
│ 1 │ 2.5 │
│ 2 │ 3.0 │
└───┴─────┘
```

### readCsv (proc) · [#core-readCsv](https://pietroppeter.github.io/tabelline/api/#core-readCsv)

```nim
proc readCsv(path: string; sep = ','; comment = ""): TableData
```

`parseCsv` of a file.

tabelline's own (not in gt)

### Row (type) · [#core-Row](https://pietroppeter.github.io/tabelline/api/#core-Row)

```nim
Row = object
  data*: TableData
  index*: int
```

One row of the data, as seen by a row predicate (`where`): `it.mass`, `it.index`.

### TextKind (type) · [#core-TextKind](https://pietroppeter.github.io/tabelline/api/#core-TextKind)

```nim
TextKind = enum
  tkPlain, tkMarkdown, tkHtml
```

### Text (type) · [#core-Text](https://pietroppeter.github.io/tabelline/api/#core-Text)

```nim
Text = object
  kind*: TextKind
  s*: string
```

A label or note: plain text (escaped when rendered), Markdown, or raw HTML.

### md (func) · [#core-md](https://pietroppeter.github.io/tabelline/api/#core-md)

```nim
func md(s: string): Text
```

Markdown text, for labels and notes: `md("**Mass** (10^24^ kg)")`.

gt: `md()` · Great Tables: `md()`

### html (func) · [#core-html](https://pietroppeter.github.io/tabelline/api/#core-html)

```nim
func html(s: string): Text
```

Raw HTML text, used as is.

gt: `html()` · Great Tables: `html()`

Example (spec table-parts):

```nim
let t = tabella(tavolaPitagorica(2)):
  tabHeader md("The **times** table"), html("of <span style=\"color: red\">two</span>")
echo "<strong>times</strong>" in t.toHtml, " ", "<span style=\"color: red\">two</span>" in t.toHtml
echo t
```

```text
true true
The times table
   of two
┌───┬───┬───┐
│ × │ 1 │ 2 │
╞═══╪═══╪═══╡
│ 1 │ 1 │ 2 │
│ 2 │ 2 │ 4 │
└───┴───┴───┘
```

### toText (converter) · [#core-toText](https://pietroppeter.github.io/tabelline/api/#core-toText)

```nim
converter toText(s: string): Text
```

### toText (func) · [#core-toText](https://pietroppeter.github.io/tabelline/api/#core-toText)

```nim
func toText(t: Text): Text
```

A Text is already one (so a `colsLabel` block can mix `"Mass"` and `md("...")`).

### isEmpty (func) · [#core-isEmpty](https://pietroppeter.github.io/tabelline/api/#core-isEmpty)

```nim
func isEmpty(t: Text): bool
```

### ColSelKind (type) · [#core-ColSelKind](https://pietroppeter.github.io/tabelline/api/#core-ColSelKind)

```nim
ColSelKind = enum
  csNames, csAll, csStartsWith, csEndsWith, csContains, csNumeric, csTextual,
  csPositions, csUnion, csMinus, csBoth, csKinds, csMatches
```

### ColSel (type) · [#core-ColSel](https://pietroppeter.github.io/tabelline/api/#core-ColSel)

```nim
ColSel = object
  case kind*: ColSelKind
  of csNames:
    names*: seq[string]
  of csStartsWith, csEndsWith, csContains:
    parts*: seq[string]
  of csPositions:
    positions*: seq[int]
  of csUnion, csMinus, csBoth:
    sels*: seq[ColSel]
  of csKinds:
    kinds*: set[ValueKind]
  of csMatches:
    test*: proc (name: string): bool
  else:
    nil
```

Which columns a verb applies to. A string or an array of strings converts to one, and
`everything()`, `startsWith(...)`, `endsWith(...)`, `containing(...)`, `numeric()`,
`textual()`, `positions(...)`, `ofKind(...)` (by the kind of the values), `matches(...)`
and `named(...)` (any rule on the name) select by rule; `a + b` is the columns of either
(in the order of the data), `a - b` those of `a` that are not in `b`, `a & b` those of
both. Resolved against the data when the verb is called.

### toColSel (converter) · [#core-toColSel](https://pietroppeter.github.io/tabelline/api/#core-toColSel)

```nim
converter toColSel(name: string): ColSel
converter toColSel[N: static int](names: array[N, string]): ColSel
converter toColSel(names: seq[string]): ColSel
```

### cols (func) · [#core-cols](https://pietroppeter.github.io/tabelline/api/#core-cols)

```nim
func cols(names: varargs[string]): ColSel
```

Example (spec nim-sugar):

```nim
let t = tabella(tavolaPitagorica(4), rownameCol = "×"):
  tabHeader "Squares"
  for i in 1 .. 4:
    tabFootnote "a square", loc.body(cols = $i, rows = [i - 1])
echo t
```

```text
           Squares
┌───┬─────┬─────┬─────┬──────┐
│   │   1 │   2 │   3 │    4 │
╞═══╪═════╪═════╪═════╪══════╡
│ 1 │ 1^1 │   2 │   3 │    4 │
│ 2 │   2 │ 4^1 │   6 │    8 │
│ 3 │   3 │   6 │ 9^1 │   12 │
│ 4 │   4 │   8 │  12 │ 16^1 │
└───┴─────┴─────┴─────┴──────┘
1 a square
```

### everything (func) · [#core-everything](https://pietroppeter.github.io/tabelline/api/#core-everything)

```nim
func everything(): ColSel
```

Example (spec table-parts):

```nim
let t = tabella(planets(), rownameCol = "planet"):
  colsHide everything()
  colsAdd "moons per Earth mass", proc (r: Row): Value = toValue(r.moons.toFloat / r.mass.toFloat * 5.97)
  fmtNumber "moons per Earth mass", decimals = 1
echo t
```

```text
┌─────────┬──────────────────────┐
│         │ moons per Earth mass │
╞═════════╪══════════════════════╡
│ Mercury │                  0.0 │
│ Venus   │                  0.0 │
│ Earth   │                  1.0 │
│ Mars    │                 18.6 │
│ Jupiter │                  0.3 │
│ Saturn  │                  1.5 │
│ Uranus  │                  1.9 │
│ Neptune │                  0.9 │
└─────────┴──────────────────────┘
```

### startsWith (func) · [#core-startsWith](https://pietroppeter.github.io/tabelline/api/#core-startsWith)

```nim
func startsWith(prefixes: varargs[string]): ColSel
```

The columns whose name starts with any of `prefixes`: `startsWith(["pop_", "pct_"])` (in
brackets: `startsWith(a, b)` with two texts is `strutils.startsWith`).

### endsWith (func) · [#core-endsWith](https://pietroppeter.github.io/tabelline/api/#core-endsWith)

```nim
func endsWith(suffixes: varargs[string]): ColSel
```

### containing (func) · [#core-containing](https://pietroppeter.github.io/tabelline/api/#core-containing)

```nim
func containing(parts: varargs[string]): ColSel
```

### numeric (func) · [#core-numeric](https://pietroppeter.github.io/tabelline/api/#core-numeric)

```nim
func numeric(): ColSel
```

### textual (func) · [#core-textual](https://pietroppeter.github.io/tabelline/api/#core-textual)

```nim
func textual(): ColSel
```

### positions (func) · [#core-positions](https://pietroppeter.github.io/tabelline/api/#core-positions)

```nim
func positions(ix: varargs[int]): ColSel
func positions(s: HSlice[int, int]): ColSel
```

Columns by their place in the data, from 0, as rows are: `positions(0, 2)`; a negative
place counts from the end (-1 is the last column).

### + (func) · [#core-op2B](https://pietroppeter.github.io/tabelline/api/#core-op2B)

```nim
func `+`(a, b: ColSel): ColSel
```

The columns of `a` or `b`: `startsWith("pop") + "year"`.

### - (func) · [#core-op2D](https://pietroppeter.github.io/tabelline/api/#core-op2D)

```nim
func `-`(a, b: ColSel): ColSel
```

The columns of `a` that are not in `b`: `numeric() - "year"`.

### & (func) · [#core-op26](https://pietroppeter.github.io/tabelline/api/#core-op26)

```nim
func `&`(a, b: ColSel): ColSel
func `&`(a, b: CellStyle): CellStyle
```

The columns of both `a` and `b`: `startsWith("pop") & numeric()`.

### ofKind (func) · [#core-ofKind](https://pietroppeter.github.io/tabelline/api/#core-ofKind)

```nim
func ofKind(kinds: varargs[ValueKind]): ColSel
```

The columns whose values are of these kinds (a missing value counts as any kind), as gt's
`where(is.logical)` and Great Tables' `cs.by_dtype(pl.Boolean)`: `ofKind(vkBool)`.

### matches (func) · [#core-matches](https://pietroppeter.github.io/tabelline/api/#core-matches)

```nim
func matches(test: proc (name: string): bool): ColSel
```

The columns whose name passes `test`, any proc of a string, as gt's `matches()` (which takes
a regular expression): `matches(proc (n: string): bool = n.len == 4)`.

### named (template) · [#core-named](https://pietroppeter.github.io/tabelline/api/#core-named)

```nim
template named(cond: untyped): ColSel
```

The columns whose name, `it`, makes `cond` true: `named(it.len == 4 and it[0] == 'y')`.

### resolve (func) · [#core-resolve](https://pietroppeter.github.io/tabelline/api/#core-resolve)

```nim
func resolve(sel: ColSel; d: TableData): seq[string]
```

### RowSelKind (type) · [#core-RowSelKind](https://pietroppeter.github.io/tabelline/api/#core-RowSelKind)

```nim
RowSelKind = enum
  rsAll, rsIndices, rsWhere
```

### RowSel (type) · [#core-RowSel](https://pietroppeter.github.io/tabelline/api/#core-RowSel)

```nim
RowSel = object
  case kind*: RowSelKind
  of rsIndices:
    indices*: seq[int]
  of rsWhere:
    pred*: proc (r: Row): bool
  of rsAll:
    nil
```

Which rows a verb applies to: all of them (the default), indices (`[0, 2]`, `0..3`, 0-based; `-1` or `^1` is the last row)
or a predicate (`where(it.mass > 1)`).

### allRows (func) · [#core-allRows](https://pietroppeter.github.io/tabelline/api/#core-allRows)

```nim
func allRows(): RowSel
```

### toRowSel (converter) · [#core-toRowSel](https://pietroppeter.github.io/tabelline/api/#core-toRowSel)

```nim
converter toRowSel(i: int): RowSel
converter toRowSel(i: BackwardsIndex): RowSel
converter toRowSel[N: static int](ix: array[N, int]): RowSel
converter toRowSel(ix: seq[int]): RowSel
converter toRowSel(s: HSlice[int, int]): RowSel
converter toRowSel[T: Ordinal](s: set[T]): RowSel
```

`^1` is the last row, as `-1` is.

### where (template) · [#core-where](https://pietroppeter.github.io/tabelline/api/#core-where)

```nim
template where(cond: untyped): RowSel
```

Rows where `cond` holds, with `it` the row: `where(it["type"] == "Gas giant")`.

tabelline's own (not in gt)

Example (spec nim-sugar):

```nim
let t = tabella(planets(), rownameCol = "planet"):
  colsHide ["type", "density", "gravity", "day_length", "distance", "orbital_period", "mean_temp", "rings", "diameter"]
  rowsHide where(it.moons < 10)
echo t
```

```text
┌─────────┬────────┬───────┐
│         │   mass │ moons │
╞═════════╪════════╪═══════╡
│ Jupiter │ 1898.0 │    95 │
│ Saturn  │  568.0 │   146 │
│ Uranus  │   86.8 │    28 │
│ Neptune │  102.0 │    16 │
└─────────┴────────┴───────┘
```

### resolve (proc) · [#core-resolve](https://pietroppeter.github.io/tabelline/api/#core-resolve)

```nim
proc resolve(sel: RowSel; d: TableData): seq[int]
```

### CellStyle (type) · [#core-CellStyle](https://pietroppeter.github.io/tabelline/api/#core-CellStyle)

```nim
CellStyle = object
  css*: seq[(string, string)]
```

CSS declarations for some cells. Build with `style.fill`, `style.text`, `style.borders` and
join with `&`: `style.fill("#fff3b0") & style.text(weight = "bold")`.

### StyleNs (type) · [#core-StyleNs](https://pietroppeter.github.io/tabelline/api/#core-StyleNs)

```nim
StyleNs = object
```

A background colour (a hex value, a CSS or R colour name), with `alpha` from 0 (clear) to 1,
as gt's `cell_fill(color, alpha)`.

### LocNs (type) · [#core-LocNs](https://pietroppeter.github.io/tabelline/api/#core-LocNs)

```nim
LocNs = object
```

A background colour (a hex value, a CSS or R colour name), with `alpha` from 0 (clear) to 1,
as gt's `cell_fill(color, alpha)`.

### style (const) · [#core-style](https://pietroppeter.github.io/tabelline/api/#core-style)

```nim
style = ()
```

### loc (const) · [#core-loc](https://pietroppeter.github.io/tabelline/api/#core-loc)

```nim
loc = ()
```

### fill (func) · [#core-fill](https://pietroppeter.github.io/tabelline/api/#core-fill)

```nim
func fill(_: StyleNs; color: string; alpha = 1.0): CellStyle
```

A background colour (a hex value, a CSS or R colour name), with `alpha` from 0 (clear) to 1,
as gt's `cell_fill(color, alpha)`.

gt: `cell_fill()` · Great Tables: `style.fill()`

Example (spec formatting):

```nim
let d = tableData:
  week: ["one", "two"]
  steps: [toValue(@[4, 8, 6]), toValue((x: @["2026-11-02", "2026-11-03", "2026-11-09"], y: @[5, 7, 9]))]
let t = tabella(d, rownameCol = "week"):
  fmtNanoplot "steps", options = nanoplotOptions(dataPointFillColor = @["#D64545", "#2E7D32"])
echo t
let x = nanoplotXValues(d["steps", 1])
echo t.toHtml.count("fill=\"#2E7D32\""), " green points; the last is ", (x[2] - x[0]) / 86400, " days after the first"
```

```text
┌─────┬─────────┐
│     │ steps   │
╞═════╪═════════╡
│ one │ ▁█▅ 4–8 │
│ two │ ▁▅█ 5–9 │
└─────┴─────────┘
2 green points; the last is 7.0 days after the first
```

### text (func) · [#core-text](https://pietroppeter.github.io/tabelline/api/#core-text)

```nim
func text(_: StyleNs; color = ""; font = ""; size = ""; align = ""; vAlign = "";
          weight = ""; style = ""; decorate = ""; transform = "";
          whitespace = ""; indent = ""): CellStyle
```

The text of the cells: `vAlign` is "top", "middle" or "bottom" (gt's `v_align`), `indent`
a CSS length, "1.5em" (gt's `indent`).

gt: `cell_text()` · Great Tables: `style.text()`

Example (spec table-parts):

```nim
let d = tableData:
  mfr: ["Ferrari", "Ferrari", "Ford", "Ford", "Fiat"]
  model: ["Roma", "Portofino", "GT", "Mustang", "500"]
  hp: [612, 600, 647, 450, 69]
let t = tabella(d, rownameCol = ["mfr", "model"]):
  tabStubhead "car"
  tabStyle style.text(weight = "bold"), loc.stub(cols = "mfr")
echo t
echo "stub: ", stubColumns(t).join(", "), "; cells over two rows: ", t.toHtml.count("rowspan=\"2\"")
```

```text
┌─────────┬───────────┬─────┐
│ car     │           │  hp │
╞═════════╪═══════════╪═════╡
│ Ferrari │ Roma      │ 612 │
│         │ Portofino │ 600 │
│ Ford    │ GT        │ 647 │
│         │ Mustang   │ 450 │
│ Fiat    │ 500       │  69 │
└─────────┴───────────┴─────┘
stub: mfr, model; cells over two rows: 2
```

### Side (type) · [#core-Side](https://pietroppeter.github.io/tabelline/api/#core-Side)

```nim
Side = enum
  sTop = "top", sRight = "right", sBottom = "bottom", sLeft = "left"
```

### borders (func) · [#core-borders](https://pietroppeter.github.io/tabelline/api/#core-borders)

```nim
func borders(_: StyleNs; sides: set[Side] = {sTop, sRight, sBottom, sLeft};
             color = "#000000"; style = "solid"; weight = "1px"): CellStyle
```

gt: `cell_borders()` · Great Tables: `style.borders()`

### css (func) · [#core-css](https://pietroppeter.github.io/tabelline/api/#core-css)

```nim
func css(_: StyleNs; declarations: string): CellStyle
```

Any CSS, as declarations: `style.css("letter-spacing: 0.1em; font-variant: small-caps")`.

### toCss (func) · [#core-toCss](https://pietroppeter.github.io/tabelline/api/#core-toCss)

```nim
func toCss(s: CellStyle): string
```

### Align (type) · [#core-Align](https://pietroppeter.github.io/tabelline/api/#core-Align)

```nim
Align = enum
  alAuto = "auto", alLeft = "left", alCenter = "center", alRight = "right"
```

### ColRole (type) · [#core-ColRole](https://pietroppeter.github.io/tabelline/api/#core-ColRole)

```nim
ColRole = enum
  crData, crStub, crGroup
```

### ColInfo (type) · [#core-ColInfo](https://pietroppeter.github.io/tabelline/api/#core-ColInfo)

```nim
ColInfo = object
  name*: string
  label*: Text
  units*: string             ## units in gt's notation, shown with the label (`colsUnits`)
  unitsPattern*: string      ## how: `{1}` is the label, `{2}` the units
  align*: Align
  width*: string
  hidden*: bool
  role*: ColRole
```

The boxhead entry of one column: how its label and cells are shown.

### Spanner (type) · [#core-Spanner](https://pietroppeter.github.io/tabelline/api/#core-Spanner)

```nim
Spanner = object
  label*: Text
  columns*: seq[string]
  level*: int
```

A label over a run of columns; `level` 1 sits right above the column labels.

### RenderContext (type) · [#core-RenderContext](https://pietroppeter.github.io/tabelline/api/#core-RenderContext)

```nim
RenderContext = enum
  rcHtml, rcText
```

### FormatFn (type) · [#core-FormatFn](https://pietroppeter.github.io/tabelline/api/#core-FormatFn)

```nim
FormatFn = proc (v: Value; ctx: RenderContext): string
```

Turns one value into its shown text. In `rcHtml` the result is HTML (escape what you add).

### FormatRule (type) · [#core-FormatRule](https://pietroppeter.github.io/tabelline/api/#core-FormatRule)

```nim
FormatRule = object
  columns*: seq[string]
  rows*: seq[int]            ## empty: every row
  fn*: FormatFn
  nullsToo*: bool            ## also called on missing values (substitutions are)
  applies*: proc (v: Value): bool ## a substitution: the values it replaces, even with ""
  wholeValue*: bool          ## takes a list or record whole (pictures); else item by item
```

### LocKind (type) · [#core-LocKind](https://pietroppeter.github.io/tabelline/api/#core-LocKind)

```nim
LocKind = enum
  lkTitle, lkSubtitle, lkStubhead, lkSpanners, lkColumnLabels, lkStub,
  lkRowGroups, lkBody, lkFootnotes, lkSourceNotes, lkHeader, lkColumnHeader,
  lkFooter, lkSummary, lkSummaryStub, lkGrandSummary, lkGrandSummaryStub
```

### Target (type) · [#core-Target](https://pietroppeter.github.io/tabelline/api/#core-Target)

```nim
Target = object
  kind*: LocKind
  cells*: seq[(int, string)]
  names*: seq[string]
  labels*: seq[string]
  columns*: seq[string]
```

A resolved location: `cells` for the body and the stub (row, column), `names` for
column labels, spanners and row groups. For summary rows, `names` are the groups, `labels`
the labels of the summary rows (empty: all of them) and `columns` the columns.

### Loc (type) · [#core-Loc](https://pietroppeter.github.io/tabelline/api/#core-Loc)

```nim
Loc = object
  kind*: LocKind
  cols*: ColSel
  rows*: RowSel
  names*: seq[string]
  labels*: seq[string]       ## summary rows, by label; stub rows, by their label
  mask*: proc (v: Value; col: Column): bool ## `loc.body(mask = ...)`: the cells that pass
```

An unresolved location, from the `loc` namespace: `loc.body(cols = "mass", rows = [0])`.

### StyleRule (type) · [#core-StyleRule](https://pietroppeter.github.io/tabelline/api/#core-StyleRule)

```nim
StyleRule = object
  target*: Target
  style*: CellStyle
```

### Footnote (type) · [#core-Footnote](https://pietroppeter.github.io/tabelline/api/#core-Footnote)

```nim
Footnote = object
  note*: Text
  target*: Target
```

### TransformRule (type) · [#core-TransformRule](https://pietroppeter.github.io/tabelline/api/#core-TransformRule)

```nim
TransformRule = object
  target*: Target
  fn*: proc (s: string): string
```

A proc over the shown text of the cells at a location (`textTransform`).

### Aggregate (type) · [#core-Aggregate](https://pietroppeter.github.io/tabelline/api/#core-Aggregate)

```nim
Aggregate = object
  name*: string              ## "sum", "count", ... ("" for a proc of your own)
  fn*: proc (values: seq[Value]): Value
```

How a summary row sums up a column: a proc from the column's non-missing values (of the
group, or of the whole table) to one value. Built in: `agg.sum`, `agg.mean`, `agg.median`,
`agg.min`, `agg.max`, `agg.count`, `agg.std`; any proc with `aggregate(myProc)`.

### AggNs (type) · [#core-AggNs](https://pietroppeter.github.io/tabelline/api/#core-AggNs)

```nim
AggNs = object
```

Summary rows added by `summaryRows` (for some groups) or `grandSummaryRows` (`grand`).

### SummaryRule (type) · [#core-SummaryRule](https://pietroppeter.github.io/tabelline/api/#core-SummaryRule)

```nim
SummaryRule = object
  grand*: bool
  groups*: seq[string]       ## the groups summarised (empty: all of them)
  columns*: seq[string]      ## the columns summarised; the others show `missingText`
  fns*: seq[(string, Aggregate)] ## (label, aggregate): one row each
  shown*: Table[string, string] ## label -> the text shown in the stub, when `textTransform` changed it
  top*: bool                 ## above the group (or the table) instead of below
  fmt*: FormatFn             ## nil: the column's format
  missingText*: string
```

Summary rows added by `summaryRows` (for some groups) or `grandSummaryRows` (`grand`).

### MergeKind (type) · [#core-MergeKind](https://pietroppeter.github.io/tabelline/api/#core-MergeKind)

```nim
MergeKind = enum
  mkPattern, mkUncert, mkRange, mkNPct
```

### MergeRule (type) · [#core-MergeRule](https://pietroppeter.github.io/tabelline/api/#core-MergeRule)

```nim
MergeRule = object
  kind*: MergeKind
  columns*: seq[string]      ## the first is where the merged text goes
  rows*: seq[int]            ## empty: every row
  pattern*: string           ## `{1}`, `{2}`, ... with `<<...>>` for a part dropped when a value is missing
```

Columns shown together in the first one (`colsMerge` and its cousins), at render time.

### FootnoteMarks (type) · [#core-FootnoteMarks](https://pietroppeter.github.io/tabelline/api/#core-FootnoteMarks)

```nim
FootnoteMarks = enum
  fmNumbers, fmLetters, fmCapitals, fmStandard, fmExtended
```

### TabOptions (type) · [#core-TabOptions](https://pietroppeter.github.io/tabelline/api/#core-TabOptions)

```nim
TabOptions = object
  tableWidth* = "auto"
  tableMarginLeft* = "auto"
  tableMarginRight* = "auto"
  tableFontNames* = "system-ui, -apple-system, \'Segoe UI\', Roboto, Helvetica, Arial, sans-serif"
  tableFontSize* = "16px"
  tableFontColor* = "#333333"
  tableBackgroundColor* = "#FFFFFF"
  tableBorderTopColor* = "#A8A8A8"
  tableBorderTopWidth* = "2px"
  tableBorderBottomColor* = "#A8A8A8"
  tableBorderBottomWidth* = "2px"
  headingAlign* = "center"
  headingBackgroundColor* = ""
  headingTitleFontSize* = "125%"
  headingTitleFontWeight* = "initial"
  headingSubtitleFontSize* = "85%"
  headingSubtitleFontWeight* = "normal"
  headingBorderBottomColor* = "#D3D3D3"
  columnLabelsBackgroundColor* = ""
  columnLabelsFontSize* = "100%"
  columnLabelsFontWeight* = "normal"
  columnLabelsTextTransform* = "inherit"
  columnLabelsBorderBottomColor* = "#D3D3D3"
  columnLabelsBorderBottomWidth* = "2px"
  rowGroupBackgroundColor* = ""
  rowGroupFontWeight* = "initial"
  rowGroupBorderColor* = "#D3D3D3"
  stubBackgroundColor* = ""
  stubFontWeight* = "initial"
  stubSticky* = false        ## the stub stays in view when a wide table scrolls sideways
  headingPadding* = "4px"
  headingPaddingHorizontal* = "5px"
  columnLabelsPadding* = "5px"
  columnLabelsPaddingHorizontal* = "5px"
  dataRowPadding* = "8px"
  dataRowPaddingHorizontal* = "5px"
  tableBorderTopStyle* = "solid"
  tableBorderBottomStyle* = "solid"
  tableBorderLeftStyle* = "none"
  tableBorderLeftWidth* = "2px"
  tableBorderLeftColor* = "#D3D3D3"
  tableBorderRightStyle* = "none"
  tableBorderRightWidth* = "2px"
  tableBorderRightColor* = "#D3D3D3"
  tableBodyVlinesColor* = "" ## "" for no vertical lines
  tableBodyHlinesColor* = "#D3D3D3"
  rowStriping* = false
  rowStripingBackgroundColor* = "rgba(128,128,128,0.05)"
  summaryRowBackgroundColor* = "" ## "" for the table's background
  summaryRowTextTransform* = "inherit"
  summaryRowPadding* = "8px"
  summaryRowPaddingHorizontal* = "5px"
  summaryRowBorderStyle* = "solid"
  summaryRowBorderWidth* = "2px"
  summaryRowBorderColor* = "#D3D3D3"
  grandSummaryRowBackgroundColor* = ""
  grandSummaryRowTextTransform* = "inherit"
  grandSummaryRowPadding* = "8px"
  grandSummaryRowPaddingHorizontal* = "5px"
  grandSummaryRowBorderStyle* = "double"
  grandSummaryRowBorderWidth* = "6px"
  grandSummaryRowBorderColor* = "#D3D3D3"
  footnotesFontSize* = "90%"
  footnotesMarks* = fmNumbers
  footnotesMarksCustom*: seq[string] ## marks of your own; when set, `footnotesMarks` is ignored
  footnotesSpecRef* = "^"    ## how marks look in the table: ^ raised, i italic, b bold, ( or [ around
  footnotesSpecFtr* = "^"    ## the same, in the footer
  footnotesOrder* = "marks_first" ## or "marks_last", "preserve_order"
  sourceNotesFontSize* = "90%"
  containerOverflowX* = "auto"
  containerOverflowY* = "auto"
  containerWidth* = "auto"
  containerHeight* = "auto"
  containerPaddingX* = "0px"
  containerPaddingY* = "0px"
  tableLayout* = "auto"      ## or "fixed", as CSS's table-layout
  tableFontWeight* = "normal"
  tableFontStyle* = "normal"
  headingBorderBottomStyle* = "solid"
  headingBorderBottomWidth* = "2px"
  headingBorderLrStyle* = "none"
  headingBorderLrWidth* = "1px"
  headingBorderLrColor* = "#D3D3D3"
  columnLabelsBorderTopStyle* = "none"
  columnLabelsBorderTopWidth* = "2px"
  columnLabelsBorderTopColor* = "#D3D3D3"
  columnLabelsBorderBottomStyle* = "solid"
  columnLabelsBorderLrStyle* = "none"
  columnLabelsBorderLrWidth* = "1px"
  columnLabelsBorderLrColor* = "#D3D3D3"
  columnLabelsVlinesStyle* = "none"
  columnLabelsVlinesWidth* = "1px"
  columnLabelsVlinesColor* = "#D3D3D3"
  rowGroupFontSize* = "100%"
  rowGroupTextTransform* = "inherit"
  rowGroupPadding* = "8px"
  rowGroupPaddingHorizontal* = "5px"
  rowGroupBorderTopStyle* = "solid"
  rowGroupBorderTopWidth* = "2px"
  rowGroupBorderTopColor* = "" ## "" for `rowGroupBorderColor`
  rowGroupBorderBottomStyle* = "solid"
  rowGroupBorderBottomWidth* = "2px"
  rowGroupBorderBottomColor* = "" ## "" for `rowGroupBorderColor`
  rowGroupBorderLeftStyle* = "none"
  rowGroupBorderLeftWidth* = "1px"
  rowGroupBorderLeftColor* = "#D3D3D3"
  rowGroupBorderRightStyle* = "none"
  rowGroupBorderRightWidth* = "1px"
  rowGroupBorderRightColor* = "#D3D3D3"
  tableBodyHlinesStyle* = "solid"
  tableBodyHlinesWidth* = "1px"
  tableBodyVlinesStyle* = "solid"
  tableBodyVlinesWidth* = "1px"
  tableBodyBorderTopStyle* = "none"
  tableBodyBorderTopWidth* = "2px"
  tableBodyBorderTopColor* = "#D3D3D3"
  tableBodyBorderBottomStyle* = "none"
  tableBodyBorderBottomWidth* = "2px"
  tableBodyBorderBottomColor* = "#D3D3D3"
  stubFontSize* = "100%"
  stubTextTransform* = "inherit"
  stubBorderStyle* = "solid"
  stubBorderWidth* = "2px"
  stubBorderColor* = ""      ## "" for `tableBodyHlinesColor`
  footnotesBackgroundColor* = "" ## "" for the table's background
  footnotesPadding* = "4px"
  footnotesPaddingHorizontal* = "5px"
  footnotesBorderBottomStyle* = "none"
  footnotesBorderBottomWidth* = "2px"
  footnotesBorderBottomColor* = "#D3D3D3"
  footnotesBorderLrStyle* = "none"
  footnotesBorderLrWidth* = "2px"
  footnotesBorderLrColor* = "#D3D3D3"
  sourceNotesBackgroundColor* = "" ## "" for the table's background
  sourceNotesPadding* = "4px"
  sourceNotesPaddingHorizontal* = "5px"
  sourceNotesBorderBottomStyle* = "none"
  sourceNotesBorderBottomWidth* = "2px"
  sourceNotesBorderBottomColor* = "#D3D3D3"
  sourceNotesBorderLrStyle* = "none"
  sourceNotesBorderLrWidth* = "2px"
  sourceNotesBorderLrColor* = "#D3D3D3"
  extraCss* = ""             ## more CSS, scoped to the table when it starts with ` ` or `.`
  tableAlign* = "center"     ## or "left", "right": where the table sits in its container
  tableNoDataMessage* = "No data to display" ## shown in the body of a table with no rows
  tableAdditionalCss* = ""   ## more CSS, as `optCss` (both add)
  tableFontColorLight* = "#FFFFFF" ## text on dark cells (`dataColor`, dark headings)
  columnLabelsHidden* = false
  columnLabelsUnitsPattern* = "{1}, {2}" ## label and units, when `colsUnits` gives no pattern
  rowGroupDefaultLabel* = "" ## a heading for the rows outside any group ("" for none)
  rowGroupAsColumn* = false  ## group labels as the first column of the stub
  stubIndentLength* = "1em"  ## the indent of one level (`tabStubIndent`)
  stubSeparate* = true       ## a rule between the stub and the body
  stubRowGroupFontSize* = "100%"
  stubRowGroupFontWeight* = "initial"
  stubRowGroupTextTransform* = "inherit"
  stubRowGroupBorderStyle* = "solid"
  stubRowGroupBorderWidth* = "2px"
  stubRowGroupBorderColor* = "#D3D3D3"
  footnotesMultiline* = true ## one footnote per line; false: all on one line
  footnotesSep* = " "        ## between footnotes on one line
  sourceNotesMultiline* = true
  sourceNotesSep* = " "
  rowStripingIncludeStub* = false
  rowStripingIncludeTableBody* = true
```

Table-wide looks, like gt's `tab_options()`. Change any subset with
`tabOptions(rowStriping = true, tableFontSize = "14px")`.

### Tabella (type) · [#core-Tabella](https://pietroppeter.github.io/tabelline/api/#core-Tabella)

```nim
Tabella = object
  data*: TableData
  boxhead*: seq[ColInfo]
  title*, subtitle*: Text
  caption*: Text
  stubhead*: Text
  rownameCol*, groupnameCol*: string
  stubCols*: seq[string]     ## the stub's other columns, left of `rownameCol`
  groupLabels*: OrderedTable[string, Text] ## group id -> label, in display order
  rowGroups*: seq[string]    ## group id of each row ("" when ungrouped)
  rowOrder*: seq[int]        ## rows in display order (empty: as in the data)
  spanners*: seq[Spanner]
  formats*: seq[FormatRule]
  substitutions*: seq[FormatRule]
  styles*: seq[StyleRule]
  transforms*: seq[TransformRule]
  footnotes*: seq[Footnote]
  sourceNotes*: seq[Text]
  summaries*: seq[SummaryRule]
  merges*: seq[MergeRule]
  hiddenRows*: seq[int]      ## rows not shown (`rowsHide`)
  indents*: Table[int, int]  ## row -> indent level of its stub cell, 1 to 5
  decimalAligned*: seq[string] ## columns aligned on the decimal mark
  decimalMarks*: seq[string] ## the mark for each of them
  options*: TabOptions
  locale*: string
  id*: string
```

A display table: the data and everything said about how to show it.

### colInfo (func) · [#core-colInfo](https://pietroppeter.github.io/tabelline/api/#core-colInfo)

```nim
func colInfo(t: Tabella; name: string): ColInfo
```

### visibleData (func) · [#core-visibleData](https://pietroppeter.github.io/tabelline/api/#core-visibleData)

```nim
func visibleData(t: Tabella): seq[ColInfo]
```

The data columns shown in the body, in display order (not the stub, groups or hidden ones).

### hasSummaries (func) · [#core-hasSummaries](https://pietroppeter.github.io/tabelline/api/#core-hasSummaries)

```nim
func hasSummaries(t: Tabella): bool
```

### hasStub (func) · [#core-hasStub](https://pietroppeter.github.io/tabelline/api/#core-hasStub)

```nim
func hasStub(t: Tabella): bool
```

A stub is shown for the row names, and for the labels of summary rows (as in gt, a table
with summary rows and no row names gets an empty stub).

### hasRowNames (func) · [#core-hasRowNames](https://pietroppeter.github.io/tabelline/api/#core-hasRowNames)

```nim
func hasRowNames(t: Tabella): bool
```

### hasGroups (func) · [#core-hasGroups](https://pietroppeter.github.io/tabelline/api/#core-hasGroups)

```nim
func hasGroups(t: Tabella): bool
```

### stubColumns (func) · [#core-stubColumns](https://pietroppeter.github.io/tabelline/api/#core-stubColumns)

```nim
func stubColumns(t: Tabella): seq[string]
```

The columns of the stub, the highest level first: `tabella(data, rownameCol = ["mfr",
"model"])` gives `@["mfr", "model"]`.

Example (spec table-parts):

```nim
let d = tableData:
  mfr: ["Ferrari", "Ferrari", "Ford", "Ford", "Fiat"]
  model: ["Roma", "Portofino", "GT", "Mustang", "500"]
  hp: [612, 600, 647, 450, 69]
let t = tabella(d, rownameCol = ["mfr", "model"]):
  tabStubhead "car"
  tabStyle style.text(weight = "bold"), loc.stub(cols = "mfr")
echo t
echo "stub: ", stubColumns(t).join(", "), "; cells over two rows: ", t.toHtml.count("rowspan=\"2\"")
```

```text
┌─────────┬───────────┬─────┐
│ car     │           │  hp │
╞═════════╪═══════════╪═════╡
│ Ferrari │ Roma      │ 612 │
│         │ Portofino │ 600 │
│ Ford    │ GT        │ 647 │
│         │ Mustang   │ 450 │
│ Fiat    │ 500       │  69 │
└─────────┴───────────┴─────┘
stub: mfr, model; cells over two rows: 2
```

### groupAsColumn (func) · [#core-groupAsColumn](https://pietroppeter.github.io/tabelline/api/#core-groupAsColumn)

```nim
func groupAsColumn(t: Tabella): bool
```

The group labels are a column of the stub (`rowGroupAsColumn`), not a row above each group.

### stubWidth (func) · [#core-stubWidth](https://pietroppeter.github.io/tabelline/api/#core-stubWidth)

```nim
func stubWidth(t: Tabella): int
```

How many columns the stub takes: the group labels (as a column), the higher levels, the
row names (or the summary labels).

### PatternRef (type) · [#core-PatternRef](https://pietroppeter.github.io/tabelline/api/#core-PatternRef)

```nim
PatternRef = object
  column*: int               ## from 0
  field*: string             ## "" for the whole value
```

One `{...}` of a merge pattern: `{2}` is column 2, `{2.lo}` the field `lo` of the record in
column 2, and `{lo}` the field `lo` of column 1.

### patternRefs (func) · [#core-patternRefs](https://pietroppeter.github.io/tabelline/api/#core-patternRefs)

```nim
func patternRefs(pattern: string): seq[(string, PatternRef)]
```

The `{...}` of `pattern`, with the text inside the braces; a `{` with no `}` is text.

## Locales (`tabelline/localize`)

Locales: the conventions of a language and region, from Unicode CLDR (`locales.nim`, `currencies.nim`, written by `tools/cldr.nim`).

### Locale (type) · [#localize-Locale](https://pietroppeter.github.io/tabelline/api/#localize-Locale)

```nim
Locale = object
  tag*: string               ## the tag found in CLDR ("de-CH"; "en" for an unknown tag)
  decimal*, group*, percentSign*: string
  percentPattern*, currencyPattern*, accountingPattern*: string ## CLDR patterns: "#,##0 %"
  months*, monthsAbbr*: array[12, string] ## names in a date: "1 gennaio"
  monthsAlone*, monthsAloneAbbr*: array[12, string] ## names on their own: "gennaio 2026"
  days*, daysAbbr*: array[7, string] ## Sunday first
  quarters*, quartersAbbr*: array[4, string]
  am*, pm*, eraBC*, eraAD*: string
  dateFormats*, timeFormats*: array[4, string] ## full, long, medium, short
  dateTime*: string          ## "{1}, {0}": the date, then the time
  skeletons*: seq[(string, string)] ## "yMMMd" -> "d MMM y"
```

### dateSkeletons (const) · [#localize-dateSkeletons](https://pietroppeter.github.io/tabelline/api/#localize-dateSkeletons)

```nim
dateSkeletons = ["yMd", "yMEd", "yMMM", "yMMMM", "yMMMd", "yMMMEd", "GyMd",
                 "GyMMMd", "GyMMMEd", "yM", "Md", "MEd", "MMMd", "MMMEd",
                 "MMMMd", "GyMMM", "yQQQ", "yQQQQ", "Gy", "y", "M", "MMM", "d",
                 "Ed"]
```

The flexible date styles of gt: each is a CLDR skeleton, written in each locale's own order.

### timeSkeletons (const) · [#localize-timeSkeletons](https://pietroppeter.github.io/tabelline/api/#localize-timeSkeletons)

```nim
timeSkeletons = ["Hms", "Hm", "H", "hms", "hm", "h", "ms"]
```

The flexible time styles of gt that need no time zone.

### normalizeTag (func) · [#localize-normalizeTag](https://pietroppeter.github.io/tabelline/api/#localize-normalizeTag)

```nim
func normalizeTag(tag: string): string
```

"de_CH", "DE-ch" and "de-CH" are the same locale.

### hasLocale (func) · [#localize-hasLocale](https://pietroppeter.github.io/tabelline/api/#localize-hasLocale)

```nim
func hasLocale(tag: string): bool
```

Whether CLDR has data for this tag (after `normalizeTag`).

### getLocale (func) · [#localize-getLocale](https://pietroppeter.github.io/tabelline/api/#localize-getLocale)

```nim
func getLocale(tag: string): Locale
```

The conventions of a locale: `getLocale("it").months[0]` is "gennaio". An unknown region
falls back to its language ("it-XX" is "it"), an unknown language to "en".

Example (spec formatting):

```nim
let d = tableData:
  n: [1234.5, 0.25]
let p = tableData:
  share: [0.123, 0.5]
let italian = tabella(d, locale = "it"):
  fmtNumber "n", decimals = 2
echo italian
let swiss = tabella(d, locale = "de_CH"):
  fmtNumber "n", decimals = 2
echo swiss
let french = tabella(p, locale = "fr"):
  fmtPercent "share"
echo french
echo getLocale("pt-XX").tag, " ", getLocale("it").months[10], " ", getLocale("ja").daysAbbr[0]
```

```text
┌──────────┐
│        n │
╞══════════╡
│ 1.234,50 │
│     0,25 │
└──────────┘
┌──────────┐
│        n │
╞══════════╡
│ 1'234.50 │
│     0.25 │
└──────────┘
┌────────┐
│  share │
╞════════╡
│ 12,3 % │
│ 50,0 % │
└────────┘
pt novembre 日
```

### skeleton (func) · [#localize-skeleton](https://pietroppeter.github.io/tabelline/api/#localize-skeleton)

```nim
func skeleton(l: Locale; name: string): string
```

The pattern of a flexible style in this locale ("" when it is not one).

### currencyInfo (func) · [#localize-currencyInfo](https://pietroppeter.github.io/tabelline/api/#localize-currencyInfo)

```nim
func currencyInfo(code: string): tuple[name, symbol: string, digits: int]
```

The English name, the symbol and the decimals of an ISO 4217 code:
`currencyInfo("JPY")` is ("Japanese Yen", "¥", 0). An unknown code is its own symbol.

Example (spec formatting):

```nim
let d = tableData:
  amount: [1234.5, -3.25]
let accounting = tabella(d):
  fmtCurrency "amount", currency = "CAD", accounting = true
echo accounting
let euro = tabella(d, locale = "it"):
  fmtCurrency "amount", currency = "EUR"
echo euro
let dinar = tabella(d):
  fmtCurrency "amount", currency = "BHD", placement = "right"
echo dinar
echo formatCurrency(1500, "JPY"), " ", currencyInfo("CHF")
```

```text
┌─────────────┐
│      amount │
╞═════════════╡
│ CA$1,234.50 │
│   (CA$3.25) │
└─────────────┘
┌────────────┐
│     amount │
╞════════════╡
│ 1.234,50 € │
│    −3,25 € │
└────────────┘
┌───────────────┐
│        amount │
╞═══════════════╡
│ 1,234.500 BHD │
│    −3.250 BHD │
└───────────────┘
¥1,500 (name: "Swiss Franc", symbol: "CHF", digits: 2)
```

### isCurrency (func) · [#localize-isCurrency](https://pietroppeter.github.io/tabelline/api/#localize-isCurrency)

```nim
func isCurrency(code: string): bool
```

Whether CLDR knows this ISO 4217 code.

### splitPattern (func) · [#localize-splitPattern](https://pietroppeter.github.io/tabelline/api/#localize-splitPattern)

```nim
func splitPattern(pattern: string): tuple[prefix, suffix: string]
```

The text before and after the number in a CLDR number pattern (its positive part):
"#,##0.00 ¤" is ("", " ¤"), "¤#,##0.00" is ("¤", "").

### negativePattern (func) · [#localize-negativePattern](https://pietroppeter.github.io/tabelline/api/#localize-negativePattern)

```nim
func negativePattern(pattern: string): tuple[prefix, suffix: string]
```

The text around a negative number: the pattern's negative part, or "" (a minus sign is added).

### withCurrency (func) · [#localize-withCurrency](https://pietroppeter.github.io/tabelline/api/#localize-withCurrency)

```nim
func withCurrency(number, symbol, pattern: string): string
```

The number and the symbol, placed and spaced as the pattern says.

### formatPattern (func) · [#localize-formatPattern](https://pietroppeter.github.io/tabelline/api/#localize-formatPattern)

```nim
func formatPattern(l: Locale; pattern: string; year = 0; month = 0; day = 0;
                   weekday = -1; hour = -1; minute = 0; second = 0): string
```

Writes a date or a time with a CLDR pattern: `formatPattern(getLocale("it"), "d MMMM y",
2026, 11, 7)` is "7 novembre 2026". `weekday` is 0 for Sunday. Text between quotes is kept.

## Formats (`tabelline/formats`)

Formatting values: plain functions that turn numbers into text (`formatNumber`, `formatPercent`, ..., usable on their own, like Great Tables' `vals`), and the `fmt*` verbs that attach them to columns and rows of a table.

### Marks (type) · [#formats-Marks](https://pietroppeter.github.io/tabelline/api/#formats-Marks)

```nim
Marks = tuple[sep, dec: string]
```

### localeMarks (func) · [#formats-localeMarks](https://pietroppeter.github.io/tabelline/api/#formats-localeMarks)

```nim
func localeMarks(locale: string): Marks
```

Digit group and decimal marks for a locale, from CLDR: `localeMarks("it")` is (".", ","),
`localeMarks("de-CH")` is ("'", "."), `localeMarks("fr")` is (" ", ",") with a narrow
no-break space. An unknown locale, or "", is "en".

### escapeHtml (func) · [#formats-escapeHtml](https://pietroppeter.github.io/tabelline/api/#formats-escapeHtml)

```nim
func escapeHtml(s: string): string
```

### sigfigDecimals (func) · [#formats-sigfigDecimals](https://pietroppeter.github.io/tabelline/api/#formats-sigfigDecimals)

```nim
func sigfigDecimals(x: float; nSigfig: int): int
```

How many decimals show `nSigfig` significant figures of `x`: 3 for 0.01234 and 3 figures,
0 for 12345 (which shows as 12,300: the figures after the third are rounded to zeros).

### formatNumber (func) · [#formats-formatNumber](https://pietroppeter.github.io/tabelline/api/#formats-formatNumber)

```nim
func formatNumber(x: float; decimals = 2; useSeps = true;
                  dropTrailingZeros = false; sepMark = ","; decMark = ".";
                  forceSign = false; nSigfig = 0; accounting = false;
                  pattern = "{x}"; locale = ""): string
```

`formatNumber(1234.5678)` is "1,234.57"; `formatNumber(1234.5, 1, sepMark = ".", decMark = ",")`
is "1.234,5". `nSigfig` shows that many significant figures instead of `decimals` (gt's
`n_sigfig`): `formatNumber(0.012345, nSigfig = 3)` is "0.0123". `accounting` writes a
negative number in parentheses, "(12.50)"; `pattern` puts the number in a text, "{x} kg";
`locale` takes its marks ("it": "1.234,57"), as `fmtNumber` does.

Example (spec table-parts):

```nim
let middle = aggregate(proc (vs: seq[Value]): Value = vs[vs.len div 2])
let t = tabella(planets(), rownameCol = "planet"):
  colsHide ["type", "mass", "density", "gravity", "day_length", "distance", "orbital_period", "mean_temp", "rings"]
  fmtInteger "diameter"
  grandSummaryRows:
    planets: agg.count
    largest: agg.max
    "middle one": middle
  grandSummaryRows:
    mean: agg.mean
    fmt = (x: float) => formatNumber(x, decimals = 1)
echo t
```

```text
┌────────────┬──────────┬───────┐
│            │ diameter │ moons │
╞════════════╪══════════╪═══════╡
│ Mercury    │    4,879 │     0 │
│ Venus      │   12,104 │     0 │
│ Earth      │   12,756 │     1 │
│ Mars       │    6,792 │     2 │
│ Jupiter    │  142,984 │    95 │
│ Saturn     │  120,536 │   146 │
│ Uranus     │   51,118 │    28 │
│ Neptune    │   49,528 │    16 │
╞════════════╪══════════╪═══════╡
│ planets    │        8 │     8 │
│ largest    │  142,984 │   146 │
│ middle one │  142,984 │    95 │
│ mean       │ 50,087.1 │  36.0 │
└────────────┴──────────┴───────┘
```

### formatCompact (func) · [#formats-formatCompact](https://pietroppeter.github.io/tabelline/api/#formats-formatCompact)

```nim
func formatCompact(x: float; decimals = 1; decMark = "."; nSigfig = 0;
                   pattern = "{x}"; locale = ""): string
```

Large numbers with a suffix: 1234567 is "1.2M"; with `nSigfig = 3`, "1.23M".

Example (spec formatting):

```nim
let d = tableData:
  population: ["[0,1e+06)", "[1e+06,1e+07)", "[1e+07,1e+08)"]
  countries: [52, 61, 83]
let t = tabella(d):
  fmtBins "population", fmt = proc (x: float): string = formatCompact(x, 0)
echo t
```

```text
┌────────────┬───────────┐
│ population │ countries │
╞════════════╪═══════════╡
│ 0–1M       │        52 │
│ 1M–10M     │        61 │
│ 10M–100M   │        83 │
└────────────┴───────────┘
```

### toSuperscript (func) · [#formats-toSuperscript](https://pietroppeter.github.io/tabelline/api/#formats-toSuperscript)

```nim
func toSuperscript(s: string): string
```

`toSuperscript("-2")` is "⁻²" (`^s` when a character has no superscript).

tabelline's own (not in gt)

### toSubscript (func) · [#formats-toSubscript](https://pietroppeter.github.io/tabelline/api/#formats-toSubscript)

```nim
func toSubscript(s: string): string
```

`toSubscript("2")` is "₂" (`_s` when a character has no subscript).

tabelline's own (not in gt)

### formatScientific (func) · [#formats-formatScientific](https://pietroppeter.github.io/tabelline/api/#formats-formatScientific)

```nim
func formatScientific(x: float; decimals = 2; decMark = "."; ctx = rcText;
                      expStyle = "x10n"; pattern = "{x}"; locale = ""): string
```

`formatScientific(5.97e24)` is "5.97 × 10²⁴"; `expStyle` "e" is "5.97e24" and "E"
"5.97E24", as gt's `exp_style`; `locale` takes its decimal mark ("de": "5,97 × 10²⁴").

### formatPercent (func) · [#formats-formatPercent](https://pietroppeter.github.io/tabelline/api/#formats-formatPercent)

```nim
func formatPercent(x: float; decimals = 1; scaleValues = true; decMark = ".";
                   sepMark = ","; pattern = "#,##0%"; percentSign = "%";
                   accounting = false; locale = ""): string
```

`formatPercent(0.123)` is "12.3%"; `pattern` is a locale's (`getLocale("fr").percentPattern`
is "#,##0 %", with a no-break space), which `locale = "fr"` takes, with its marks.
`accounting` writes "(12.3%)" for −0.123.

### currencySymbol (func) · [#formats-currencySymbol](https://pietroppeter.github.io/tabelline/api/#formats-currencySymbol)

```nim
func currencySymbol(code: string): string
```

The symbol of an ISO 4217 code, from CLDR (English): "EUR" is "€", "CHF" is "CHF", "CAD"
is "CA$". An unknown code is its own symbol.

### formatCurrency (func) · [#formats-formatCurrency](https://pietroppeter.github.io/tabelline/api/#formats-formatCurrency)

```nim
func formatCurrency(x: float; currency = "USD"; decimals = -1; sepMark = ",";
                    decMark = "."; placement = ""; pattern = "¤#,##0.00";
                    accounting = false; useSubunits = true; locale = ""): string
```

`formatCurrency(49.95, "EUR")` is "€49.95". `decimals = -1` takes the currency's (0 for JPY,
3 for BHD, 2 for most); `useSubunits = false` drops them. The symbol goes where `pattern`
puts it (a locale's `currencyPattern`: "#,##0.00 ¤" in Italian, which `locale = "it"`
takes, with its marks), or `placement` "left" or "right". `accounting` writes a negative
amount in parentheses.

Example (spec formatting):

```nim
let d = tableData:
  amount: [1234.5, -3.25]
let accounting = tabella(d):
  fmtCurrency "amount", currency = "CAD", accounting = true
echo accounting
let euro = tabella(d, locale = "it"):
  fmtCurrency "amount", currency = "EUR"
echo euro
let dinar = tabella(d):
  fmtCurrency "amount", currency = "BHD", placement = "right"
echo dinar
echo formatCurrency(1500, "JPY"), " ", currencyInfo("CHF")
```

```text
┌─────────────┐
│      amount │
╞═════════════╡
│ CA$1,234.50 │
│   (CA$3.25) │
└─────────────┘
┌────────────┐
│     amount │
╞════════════╡
│ 1.234,50 € │
│    −3,25 € │
└────────────┘
┌───────────────┐
│        amount │
╞═══════════════╡
│ 1,234.500 BHD │
│    −3.250 BHD │
└───────────────┘
¥1,500 (name: "Swiss Franc", symbol: "CHF", digits: 2)
```

### formatRoman (func) · [#formats-formatRoman](https://pietroppeter.github.io/tabelline/api/#formats-formatRoman)

```nim
func formatRoman(n: int; upper = true): string
```

`formatRoman(2026)` is "MMXXVI".

### dateStyles (const) · [#formats-dateStyles](https://pietroppeter.github.io/tabelline/api/#formats-dateStyles)

```nim
dateStyles = [("iso", "y-MM-dd"), ("wday_month_day_year", "EEEE, MMMM d, y"),
              ("wd_m_day_year", "EEE, MMM d, y"),
              ("wday_day_month_year", "EEEE d MMMM y"),
              ("month_day_year", "MMMM d, y"), ("m_day_year", "MMM d, y"),
              ("day_m_year", "d MMM y"), ("day_month_year", "d MMMM y"),
              ("day_month", "d MMMM"), ("day_m", "d MMM"), ("year", "y"),
              ("month", "LLLL"), ("day", "dd"), ("year.mn.day", "y/MM/dd"),
              ("y.mn.day", "yy/MM/dd"), ("year_week", "Y-\'W\'ww"),
              ("year_quarter", "y-\'Q\'Q"), ("year_month", "LLLL y"),
              ("dd/mm/yyyy", "dd/MM/y"), ("mm/dd/yyyy", "MM/dd/y")]
```

gt's fixed date styles, as CLDR patterns, with names in the locale's language. The flexible
ones (`dateSkeletons`: "yMMMd", "yMMMEd", ...) also follow the locale's order.

### formatDate (proc) · [#formats-formatDate](https://pietroppeter.github.io/tabelline/api/#formats-formatDate)

```nim
proc formatDate(s: string; dateStyle = "iso"; locale = ""): string
```

An ISO date ("2015-01-15", or the date part of a datetime) in one of `dateStyles`, a
flexible style of `dateSkeletons` ("yMMMd"), or a std/times pattern (English names), in the
language of `locale`: `formatDate("2015-01-15", "day_month_year", "it")` is "15 gennaio 2015".
Text that is not a date is returned as is.

Example (spec formatting):

```nim
let d = tableData:
  day: ["2026-11-07", "2015-01-15"]
let german = tabella(d, locale = "de"):
  fmtDate "day", dateStyle = "yMMMEd"
echo german
for loc in ["en", "it", "ja", "ru"]:
  echo loc, ": ", formatDate("2026-11-07", "wday_day_month_year", loc), " · ",
    formatDate("2026-11-07", "yMMMd", loc), " · ", formatTime("14:35", "hm", loc)
```

```text
┌────────────────────┐
│ day                │
╞════════════════════╡
│ Sa., 7. Nov. 2026  │
│ Do., 15. Jan. 2015 │
└────────────────────┘
en: Saturday 7 November 2026 · Nov 7, 2026 · 2:35 PM
it: sabato 7 novembre 2026 · 7 nov 2026 · 2:35 PM
ja: 土曜日 7 11月 2026 · 2026年11月7日 · 午後2:35
ru: суббота 7 ноября 2026 · 7 нояб. 2026 г. · 2:35 PM
```

### formatInteger (func) · [#formats-formatInteger](https://pietroppeter.github.io/tabelline/api/#formats-formatInteger)

```nim
func formatInteger(x: float; useSeps = true; sepMark = ","; accounting = false;
                   pattern = "{x}"; locale = ""): string
```

`formatInteger(1234.6)` is "1,235"; `locale = "it"`, "1.235".

### formatEngineering (func) · [#formats-formatEngineering](https://pietroppeter.github.io/tabelline/api/#formats-formatEngineering)

```nim
func formatEngineering(x: float; decimals = 2; decMark = "."; ctx = rcText): string
```

Scientific notation with exponents in steps of three: `formatEngineering(12345)` is
"12.35 × 10³".

### formatNumberSi (func) · [#formats-formatNumberSi](https://pietroppeter.github.io/tabelline/api/#formats-formatNumberSi)

```nim
func formatNumberSi(x: float; unit = ""; decimals = 2; inclSpace = true;
                    decMark = "."): string
```

A number with an SI prefix: `formatNumberSi(12345, "g")` is "12.35 kg".

### formatPartsper (func) · [#formats-formatPartsper](https://pietroppeter.github.io/tabelline/api/#formats-formatPartsper)

```nim
func formatPartsper(x: float; toUnits = "per-mille"; decimals = 2;
                    scaleValues = true; inclSpace = "auto"; decMark = ".";
                    sepMark = ","): string
```

Fractions as parts per thousand ("per-mille", ‰), ten thousand ("per-myriad", ‱), hundred
thousand ("pcm"), million ("ppm"), billion ("ppb"), trillion ("ppt") or quadrillion ("ppq").
`inclSpace = "auto"` puts a space before the letters and none before ‰ and ‱.

### formatBytes (func) · [#formats-formatBytes](https://pietroppeter.github.io/tabelline/api/#formats-formatBytes)

```nim
func formatBytes(x: float; standard = "decimal"; decimals = 1; inclSpace = true;
                 decMark = "."): string
```

Sizes in bytes: `formatBytes(1500)` is "1.5 kB", `formatBytes(1536, "binary")` is "1.5 KiB".

### formatIndex (func) · [#formats-formatIndex](https://pietroppeter.github.io/tabelline/api/#formats-formatIndex)

```nim
func formatIndex(n: int; upper = true; indexAlgo = "repeat"): string
```

Letters for 1, 2, 3, ...: "A", "B", ... "Z", then "AA", "BB" (`indexAlgo = "repeat"`) or
"AA", "AB" (`"excel"`).

### formatSpelledNum (func) · [#formats-formatSpelledNum](https://pietroppeter.github.io/tabelline/api/#formats-formatSpelledNum)

```nim
func formatSpelledNum(n: int): string
```

Numbers from zero to one hundred in English words: `formatSpelledNum(42)` is "forty-two";
other numbers stay as digits.

### timeStyles (const) · [#formats-timeStyles](https://pietroppeter.github.io/tabelline/api/#formats-timeStyles)

```nim
timeStyles = ["iso", "iso-short", "h_m_s_p", "h_m_p", "h_p", "h_m", "h_m_s"]
```

Named time styles: 14:35:00, 14:35, 2:35:00 PM, 2:35 PM, 2 PM, 14:35, 14:35:00. The
flexible ones (`timeSkeletons`: "Hm", "hm", ...) follow the locale.

### formatTime (func) · [#formats-formatTime](https://pietroppeter.github.io/tabelline/api/#formats-formatTime)

```nim
func formatTime(s: string; timeStyle = "iso"; locale = ""): string
```

A time ("14:35", "14:35:07", or the time of an ISO datetime) in one of `timeStyles` or
`timeSkeletons`, with the locale's AM and PM: `formatTime("14:35", "hm", "it")` is "2:35 PM".
Text that is not a time is returned as is.

Example (spec formatting):

```nim
let d = tableData:
  launch: ["1969-07-16T13:32:00", "2026-11-07 09:05", "soon"]
let t = tabella(d):
  fmtDatetime "launch", dateStyle = "day_m_year", timeStyle = "h_m_p"
echo t
echo formatTime("14:35:07", "iso-short"), " ", formatTime("14:35", "h_p")
```

```text
┌─────────────────────┐
│ launch              │
╞═════════════════════╡
│ 16 Jul 1969 1:32 PM │
│ 7 Nov 2026 9:05 AM  │
│ soon                │
└─────────────────────┘
14:35 2 PM
```

### strftimeToCldr (func) · [#formats-strftimeToCldr](https://pietroppeter.github.io/tabelline/api/#formats-strftimeToCldr)

```nim
func strftimeToCldr(f: string): string
```

A strftime format (`"%Y-%m-%d %H:%M"`, as Python's and Great Tables' `format_str`) as a CLDR
pattern: %Y %y %m %d %e %B %b %A %a %H %I %M %S %p and %%; other text is kept as it is.

### formatDatetime (proc) · [#formats-formatDatetime](https://pietroppeter.github.io/tabelline/api/#formats-formatDatetime)

```nim
proc formatDatetime(s: string; dateStyle = "iso"; timeStyle = "iso"; sep = " ";
                    locale = ""; formatStr = ""): string
```

An ISO datetime ("2026-11-07T14:35:00" or "2026-11-07 14:35") as a date and a time, in the
date and time styles; a date without a time shows only the date. `formatStr` writes it with
a strftime format instead, as Great Tables' `format_str`: `"%d %B %Y, %H:%M"` is
"07 November 2026, 14:35", in the locale's language.

### formatDuration (func) · [#formats-formatDuration](https://pietroppeter.github.io/tabelline/api/#formats-formatDuration)

```nim
func formatDuration(x: float; inputUnits = "seconds";
                    outputUnits: openArray[string] = [];
                    durationStyle = "narrow"; trimZeroUnits = true;
                    maxOutputUnits = 0): string
```

A length of time in weeks, days, hours, minutes and seconds: `formatDuration(7503)` is
"2h 5m 3s"; `durationStyle` "wide" (2 hours 5 minutes 3 seconds), "colon-sep" (02:05:03)
or "iso" (PT2H5M3S). The smallest output unit is rounded.

Example (spec formatting):

```nim
let d = tableData:
  secs: [7503.0, 90061.0, 45.0]
let narrow = tabella(d):
  fmtDuration "secs"
echo narrow
let colons = tabella(d):
  fmtDuration "secs", durationStyle = "colon-sep"
echo colons
echo formatDuration(1.5, inputUnits = "days", durationStyle = "wide")
```

```text
┌─────────────┐
│        secs │
╞═════════════╡
│    2h 5m 3s │
│ 1d 1h 1m 1s │
│         45s │
└─────────────┘
┌──────────┐
│     secs │
╞══════════╡
│ 02:05:03 │
│ 25:01:01 │
│ 00:00:45 │
└──────────┘
1 day 12 hours
```

### tfStyles (const) · [#formats-tfStyles](https://pietroppeter.github.io/tabelline/api/#formats-tfStyles)

```nim
tfStyles = [("true-false", "true", "false"), ("yes-no", "yes", "no"),
            ("up-down", "up", "down"), ("check-mark", "✓", "✗"),
            ("circles", "●", "○"), ("squares", "■", "□"),
            ("diamonds", "◆", "◇"), ("arrows", "↑", "↓"),
            ("triangles", "▲", "▼"), ("triangles-lr", "▶", "◀")]
```

Named pairs of texts for booleans, as gt's `tf_style`.

### formatTf (func) · [#formats-formatTf](https://pietroppeter.github.io/tabelline/api/#formats-formatTf)

```nim
func formatTf(b: bool; tfStyle = "check-mark"): string
```

A boolean in one of `tfStyles`: `formatTf(true, "yes-no")` is "yes".

### formatFlag (func) · [#formats-formatFlag](https://pietroppeter.github.io/tabelline/api/#formats-formatFlag)

```nim
func formatFlag(codes: string; sep = " "): string
```

Country codes (ISO 3166-1, two or three letters, comma or space separated) as flag emoji:
`formatFlag("IT")` and `formatFlag("ITA")` are "🇮🇹". Anything else is left as it is.

### inlineMarkdown (func) · [#formats-inlineMarkdown](https://pietroppeter.github.io/tabelline/api/#formats-inlineMarkdown)

```nim
func inlineMarkdown(s: string): string
```

Inline Markdown: `**bold**` and `__bold__`, `*italic*` and `_italic_`, `~~struck~~`,
`` `code` ``, `[text](url)` and `<https://...>`, `~sub~`, `^sup^`, HTML entities (`&mdash;`),
and `<br>`, two spaces before a newline or a backslash before it for a line break.
With no dependency (nimib's Markdown is not needed here); `md()` adds paragraphs and lists.

### mdToHtml (func) · [#formats-mdToHtml](https://pietroppeter.github.io/tabelline/api/#formats-mdToHtml)

```nim
func mdToHtml(s: string): string
```

Markdown with paragraphs (a blank line between them) and lists (`- item`, `1. item`), each
line inline Markdown. One paragraph is its inline HTML, with no `<p>` around it, so a label
stays a label.

### textToHtml (func) · [#formats-textToHtml](https://pietroppeter.github.io/tabelline/api/#formats-textToHtml)

```nim
func textToHtml(t: Text): string
```

### decodeEntities (func) · [#formats-decodeEntities](https://pietroppeter.github.io/tabelline/api/#formats-decodeEntities)

```nim
func decodeEntities(s: string): string
```

The text of HTML entities: `&mdash;` is "—", `&#8212;` and `&#x2014;` too (for text and
Markdown output); an entity it does not know is left as it is.

### textToPlain (func) · [#formats-textToPlain](https://pietroppeter.github.io/tabelline/api/#formats-textToPlain)

```nim
func textToPlain(t: Text): string
```

### fmt (proc) · [#formats-fmt](https://pietroppeter.github.io/tabelline/api/#formats-fmt)

```nim
proc fmt(t: sink Tabella; columns: ColSel; fn: FormatFn; rows = allRows()): Tabella
proc fmt(t: sink Tabella; columns: ColSel; fn: proc (v: Value): string;
         rows = allRows()): Tabella
```

The general formatter: `fn(value, ctx)` gives the text of each (non-missing) cell.

gt: `fmt()` · Great Tables: `GT.fmt()`

### fmtNumber (proc) · [#formats-fmtNumber](https://pietroppeter.github.io/tabelline/api/#formats-fmtNumber)

```nim
proc fmtNumber(t: sink Tabella; columns: ColSel = numeric(); rows = allRows();
               decimals = 2; nSigfig = 0; dropTrailingZeros = false;
               useSeps = true; accounting = false; scaleBy = 1.0;
               compact = false; pattern = "{x}"; forceSign = false; locale = "";
               sepMark = ""; decMark = ""): Tabella
```

Numbers with a fixed number of decimals and digit grouping: `fmtNumber("mass", decimals = 1)`.
`nSigfig = 3` shows three significant figures instead (gt's `n_sigfig`, also with
`compact`); `accounting` writes negative numbers in parentheses.

gt: `fmt_number()` · Great Tables: `GT.fmt_number()`

Example (spec formatting):

```nim
let d = tableData:
  x: [1.5, 2.25, nil]
let t = tabella(d):
  fmtNumber "x", decimals = 1
  fmtNumber "x", decimals = 3, rows = [0]
echo t
```

```text
┌───────┐
│     x │
╞═══════╡
│ 1.500 │
│   2.2 │
│       │
└───────┘
```

### fmtInteger (proc) · [#formats-fmtInteger](https://pietroppeter.github.io/tabelline/api/#formats-fmtInteger)

```nim
proc fmtInteger(t: sink Tabella; columns: ColSel = numeric(); rows = allRows();
                useSeps = true; accounting = false; scaleBy = 1.0;
                pattern = "{x}"; forceSign = false; locale = ""; sepMark = ""): Tabella
```

gt: `fmt_integer()` · Great Tables: `GT.fmt_integer()`

Example (spec table-parts):

```nim
let budget = tableData:
  item: ["Hardware", "Laptops", "Screens", "Travel"]
  eur: [5200, 4000, 1200, 900]
let t = tabella(budget, rownameCol = "item"):
  tabStubIndent [1, 2], "increase"
  fmtInteger "eur"
echo t
```

```text
┌───────────┬───────┐
│           │   eur │
╞═══════════╪═══════╡
│ Hardware  │ 5,200 │
│   Laptops │ 4,000 │
│   Screens │ 1,200 │
│ Travel    │   900 │
└───────────┴───────┘
```

### fmtPercent (proc) · [#formats-fmtPercent](https://pietroppeter.github.io/tabelline/api/#formats-fmtPercent)

```nim
proc fmtPercent(t: sink Tabella; columns: ColSel; rows = allRows();
                decimals = 1; scaleValues = true; accounting = false;
                locale = ""): Tabella
```

Fractions as percentages: 0.123 is "12.3%" (`scaleValues = false` for values already in %),
"12,3 %" in French; `accounting` writes "(12.3%)" for −0.123.

gt: `fmt_percent()` · Great Tables: `GT.fmt_percent()`

Example (spec formatting):

```nim
let d = tableData:
  n: [1234.5, 0.25]
let p = tableData:
  share: [0.123, 0.5]
let italian = tabella(d, locale = "it"):
  fmtNumber "n", decimals = 2
echo italian
let swiss = tabella(d, locale = "de_CH"):
  fmtNumber "n", decimals = 2
echo swiss
let french = tabella(p, locale = "fr"):
  fmtPercent "share"
echo french
echo getLocale("pt-XX").tag, " ", getLocale("it").months[10], " ", getLocale("ja").daysAbbr[0]
```

```text
┌──────────┐
│        n │
╞══════════╡
│ 1.234,50 │
│     0,25 │
└──────────┘
┌──────────┐
│        n │
╞══════════╡
│ 1'234.50 │
│     0.25 │
└──────────┘
┌────────┐
│  share │
╞════════╡
│ 12,3 % │
│ 50,0 % │
└────────┘
pt novembre 日
```

### fmtCurrency (proc) · [#formats-fmtCurrency](https://pietroppeter.github.io/tabelline/api/#formats-fmtCurrency)

```nim
proc fmtCurrency(t: sink Tabella; columns: ColSel; rows = allRows();
                 currency = "USD"; decimals = -1; placement = "";
                 accounting = false; useSubunits = true; locale = ""): Tabella
```

Numbers as amounts of a currency (any ISO 4217 code), with its symbol and its decimals, in the
locale's way: "€49.95" in English, "49,95 €" in Italian. `placement` "left" or "right"
puts the symbol there whatever the locale; `accounting` writes negative amounts in parentheses.

gt: `fmt_currency()` · Great Tables: `GT.fmt_currency()`

Example (spec formatting):

```nim
let d = tableData:
  amount: [1234.5, -3.25]
let accounting = tabella(d):
  fmtCurrency "amount", currency = "CAD", accounting = true
echo accounting
let euro = tabella(d, locale = "it"):
  fmtCurrency "amount", currency = "EUR"
echo euro
let dinar = tabella(d):
  fmtCurrency "amount", currency = "BHD", placement = "right"
echo dinar
echo formatCurrency(1500, "JPY"), " ", currencyInfo("CHF")
```

```text
┌─────────────┐
│      amount │
╞═════════════╡
│ CA$1,234.50 │
│   (CA$3.25) │
└─────────────┘
┌────────────┐
│     amount │
╞════════════╡
│ 1.234,50 € │
│    −3,25 € │
└────────────┘
┌───────────────┐
│        amount │
╞═══════════════╡
│ 1,234.500 BHD │
│    −3.250 BHD │
└───────────────┘
¥1,500 (name: "Swiss Franc", symbol: "CHF", digits: 2)
```

### fmtScientific (proc) · [#formats-fmtScientific](https://pietroppeter.github.io/tabelline/api/#formats-fmtScientific)

```nim
proc fmtScientific(t: sink Tabella; columns: ColSel; rows = allRows();
                   decimals = 2; expStyle = "x10n"; locale = ""): Tabella
```

Scientific notation: 5.97e24 is "5.97 × 10²⁴"; `expStyle` "e" or "E" writes "5.97e24".

gt: `fmt_scientific()` · Great Tables: `GT.fmt_scientific()`

Example (spec formatting):

```nim
let d = tableData:
  n: [1234567.891, -0.5, 0.0123]
let number = tabella(d):
  fmtNumber "n", decimals = 2
echo number
let compact = tabella(d):
  fmtNumber "n", compact = true
echo compact
let percent = tabella(d):
  fmtPercent "n", decimals = 1
echo percent
let currency = tabella(d):
  fmtCurrency "n", currency = "EUR"
echo currency
let scientific = tabella(d):
  fmtScientific "n", decimals = 1
echo scientific
```

```text
┌──────────────┐
│            n │
╞══════════════╡
│ 1,234,567.89 │
│        −0.50 │
│         0.01 │
└──────────────┘
┌───────┐
│     n │
╞═══════╡
│ 1.23M │
│  −0.5 │
│  0.01 │
└───────┘
┌────────────────┐
│              n │
╞════════════════╡
│ 123,456,789.1% │
│         −50.0% │
│           1.2% │
└────────────────┘
┌───────────────┐
│             n │
╞═══════════════╡
│ €1,234,567.89 │
│        −€0.50 │
│         €0.01 │
└───────────────┘
┌─────────────┐
│           n │
╞═════════════╡
│   1.2 × 10⁶ │
│ −5.0 × 10⁻¹ │
│  1.2 × 10⁻² │
└─────────────┘
```

### fmtRoman (proc) · [#formats-fmtRoman](https://pietroppeter.github.io/tabelline/api/#formats-fmtRoman)

```nim
proc fmtRoman(t: sink Tabella; columns: ColSel; rows = allRows(); upper = true): Tabella
```

gt: `fmt_roman()` · Great Tables: `GT.fmt_roman()`

### fmtDate (proc) · [#formats-fmtDate](https://pietroppeter.github.io/tabelline/api/#formats-fmtDate)

```nim
proc fmtDate(t: sink Tabella; columns: ColSel; rows = allRows();
             dateStyle = "iso"; locale = ""): Tabella
```

ISO date strings in a `dateStyles` style ("month_day_year", ...), a flexible style
("yMMMd"), or a std/times pattern, in the locale's language.

gt: `fmt_date()` · Great Tables: `GT.fmt_date()`

Example (spec formatting):

```nim
let d = tableData:
  day: ["2026-11-07", "2015-01-15"]
  ok: [true, false]
  stars: [3, 1]
let t = tabella(d):
  fmtDate "day", dateStyle = "day_month_year"
  fmtTf "ok", trueText = "yes", falseText = "no"
  fmt "stars", proc (v: Value): string = "*".repeat(v.i)
echo t
```

```text
┌─────────────────┬─────┬───────┐
│ day             │ ok  │ stars │
╞═════════════════╪═════╪═══════╡
│ 7 November 2026 │ yes │   *** │
│ 15 January 2015 │ no  │     * │
└─────────────────┴─────┴───────┘
```

### fmtMarkdown (proc) · [#formats-fmtMarkdown](https://pietroppeter.github.io/tabelline/api/#formats-fmtMarkdown)

```nim
proc fmtMarkdown(t: sink Tabella; columns: ColSel; rows = allRows()): Tabella
```

Cell text as Markdown (inline: emphasis, code, links).

gt: `fmt_markdown()` · Great Tables: `GT.fmt_markdown()`

### subMissing (proc) · [#formats-subMissing](https://pietroppeter.github.io/tabelline/api/#formats-subMissing)

```nim
proc subMissing(t: sink Tabella; columns: ColSel = everything();
                rows = allRows(); missingText: Text = toText("—")): Tabella
```

Shows missing values as `missingText` (by default they are blank): a text, or Markdown,
`md("**STABLE**")`, as gt's `missing_text = md(...)`.

gt: `sub_missing()` · Great Tables: `GT.sub_missing()`

Example (spec formatting):

```nim
let d = tableData:
  n: [0, nil, 3]
let t = tabella(d):
  subMissing()
  subZero zeroText = "none"
echo t
```

```text
┌──────┐
│    n │
╞══════╡
│ none │
│    — │
│    3 │
└──────┘
```

### subZero (proc) · [#formats-subZero](https://pietroppeter.github.io/tabelline/api/#formats-subZero)

```nim
proc subZero(t: sink Tabella; columns: ColSel = numeric(); rows = allRows();
             zeroText = "nil"): Tabella
```

Shows zeros as `zeroText`.

gt: `sub_zero()` · Great Tables: `GT.sub_zero()`

Example (spec formatting):

```nim
let d = tableData:
  n: [0, nil, 3]
let t = tabella(d):
  subMissing()
  subZero zeroText = "none"
echo t
```

```text
┌──────┐
│    n │
╞══════╡
│ none │
│    — │
│    3 │
└──────┘
```

### fmtEngineering (proc) · [#formats-fmtEngineering](https://pietroppeter.github.io/tabelline/api/#formats-fmtEngineering)

```nim
proc fmtEngineering(t: sink Tabella; columns: ColSel = numeric();
                    rows = allRows(); decimals = 2; locale = ""): Tabella
```

Scientific notation with exponents in steps of three: 12345 is "12.35 × 10³".

gt: `fmt_engineering()` · Great Tables: `GT.fmt_engineering()`

Example (spec formatting):

```nim
let d = tableData:
  x: [12345.0, 0.000123, 1.5]
let engineering = tabella(d):
  fmtEngineering "x"
echo engineering
let si = tabella(d):
  fmtNumberSi "x", unit = "g"
echo si
```

```text
┌───────────────┐
│             x │
╞═══════════════╡
│   12.35 × 10³ │
│ 123.00 × 10⁻⁶ │
│          1.50 │
└───────────────┘
┌───────────┐
│         x │
╞═══════════╡
│  12.35 kg │
│ 123.00 µg │
│    1.50 g │
└───────────┘
```

### fmtNumberSi (proc) · [#formats-fmtNumberSi](https://pietroppeter.github.io/tabelline/api/#formats-fmtNumberSi)

```nim
proc fmtNumberSi(t: sink Tabella; columns: ColSel = numeric(); rows = allRows();
                 unit = ""; decimals = 2; inclSpace = true; locale = ""): Tabella
```

Numbers with SI prefixes and a unit: 12345 with `unit = "g"` is "12.35 kg".

gt: `fmt_number_si()`

Example (spec formatting):

```nim
let d = tableData:
  x: [12345.0, 0.000123, 1.5]
let engineering = tabella(d):
  fmtEngineering "x"
echo engineering
let si = tabella(d):
  fmtNumberSi "x", unit = "g"
echo si
```

```text
┌───────────────┐
│             x │
╞═══════════════╡
│   12.35 × 10³ │
│ 123.00 × 10⁻⁶ │
│          1.50 │
└───────────────┘
┌───────────┐
│         x │
╞═══════════╡
│  12.35 kg │
│ 123.00 µg │
│    1.50 g │
└───────────┘
```

### fmtPartsper (proc) · [#formats-fmtPartsper](https://pietroppeter.github.io/tabelline/api/#formats-fmtPartsper)

```nim
proc fmtPartsper(t: sink Tabella; columns: ColSel = numeric(); rows = allRows();
                 toUnits = "per-mille"; decimals = 2; scaleValues = true;
                 inclSpace = "auto"; locale = ""): Tabella
```

Fractions as parts per thousand (‰), ten thousand (‱), million (ppm), ... see `formatPartsper`.

gt: `fmt_partsper()` · Great Tables: `GT.fmt_partsper()`

Example (spec formatting):

```nim
let d = tableData:
  co2: [0.000421, 0.000280]
let ppm = tabella(d):
  fmtPartsper "co2", toUnits = "ppm", decimals = 0
echo ppm
let perMille = tabella(d):
  fmtPartsper "co2", decimals = 3
echo perMille
```

```text
┌─────────┐
│     co2 │
╞═════════╡
│ 421 ppm │
│ 280 ppm │
└─────────┘
┌────────┐
│    co2 │
╞════════╡
│ 0.421‰ │
│ 0.280‰ │
└────────┘
```

### fmtBytes (proc) · [#formats-fmtBytes](https://pietroppeter.github.io/tabelline/api/#formats-fmtBytes)

```nim
proc fmtBytes(t: sink Tabella; columns: ColSel = numeric(); rows = allRows();
              standard = "decimal"; decimals = 1; inclSpace = true; locale = ""): Tabella
```

Sizes in bytes: kB, MB, GB (`standard = "decimal"`) or KiB, MiB, GiB (`"binary"`).

gt: `fmt_bytes()` · Great Tables: `GT.fmt_bytes()`

Example (spec formatting):

```nim
let d = tableData:
  size: [512, 1500, 1536, 3_200_000_000]
let t = tabella(d):
  fmtBytes "size"
  fmtBytes "size", rows = [2], standard = "binary"
echo t
```

```text
┌─────────┐
│    size │
╞═════════╡
│   512 B │
│  1.5 kB │
│ 1.5 KiB │
│  3.2 GB │
└─────────┘
```

### fmtIndex (proc) · [#formats-fmtIndex](https://pietroppeter.github.io/tabelline/api/#formats-fmtIndex)

```nim
proc fmtIndex(t: sink Tabella; columns: ColSel = numeric(); rows = allRows();
              upper = true; indexAlgo = "repeat"): Tabella
```

Whole numbers as letters: 1 is "A", 27 is "AA" (see `formatIndex`).

gt: `fmt_index()`

Example (spec formatting):

```nim
let d = tableData:
  n: [1, 3, 27, 42]
let index = tabella(d):
  fmtIndex "n", upper = false
echo index
let spelled = tabella(d):
  fmtSpelledNum "n"
echo spelled
```

```text
┌────┐
│  n │
╞════╡
│  a │
│  c │
│ aa │
│ pp │
└────┘
┌──────────────┐
│            n │
╞══════════════╡
│          one │
│        three │
│ twenty-seven │
│    forty-two │
└──────────────┘
```

### fmtSpelledNum (proc) · [#formats-fmtSpelledNum](https://pietroppeter.github.io/tabelline/api/#formats-fmtSpelledNum)

```nim
proc fmtSpelledNum(t: sink Tabella; columns: ColSel = numeric();
                   rows = allRows()): Tabella
```

Whole numbers from zero to one hundred in English words.

gt: `fmt_spelled_num()`

Example (spec formatting):

```nim
let d = tableData:
  n: [1, 3, 27, 42]
let index = tabella(d):
  fmtIndex "n", upper = false
echo index
let spelled = tabella(d):
  fmtSpelledNum "n"
echo spelled
```

```text
┌────┐
│  n │
╞════╡
│  a │
│  c │
│ aa │
│ pp │
└────┘
┌──────────────┐
│            n │
╞══════════════╡
│          one │
│        three │
│ twenty-seven │
│    forty-two │
└──────────────┘
```

### fmtTime (proc) · [#formats-fmtTime](https://pietroppeter.github.io/tabelline/api/#formats-fmtTime)

```nim
proc fmtTime(t: sink Tabella; columns: ColSel; rows = allRows();
             timeStyle = "iso"; locale = ""): Tabella
```

Times ("14:35:00", or the time of a datetime) in one of `timeStyles` or `timeSkeletons`.

gt: `fmt_time()` · Great Tables: `GT.fmt_time()`

### fmtDatetime (proc) · [#formats-fmtDatetime](https://pietroppeter.github.io/tabelline/api/#formats-fmtDatetime)

```nim
proc fmtDatetime(t: sink Tabella; columns: ColSel; rows = allRows();
                 dateStyle = "iso"; timeStyle = "iso"; sep = " ";
                 formatStr = ""; locale = ""): Tabella
```

ISO datetimes as a date and a time, each in its style, or with a strftime `formatStr`
(`"%Y/%m/%d %H:%M"`), as Great Tables' `format_str`.

gt: `fmt_datetime()` · Great Tables: `GT.fmt_datetime()`

Example (spec formatting):

```nim
let d = tableData:
  launch: ["1969-07-16T13:32:00", "2026-11-07 09:05", "soon"]
let t = tabella(d):
  fmtDatetime "launch", dateStyle = "day_m_year", timeStyle = "h_m_p"
echo t
echo formatTime("14:35:07", "iso-short"), " ", formatTime("14:35", "h_p")
```

```text
┌─────────────────────┐
│ launch              │
╞═════════════════════╡
│ 16 Jul 1969 1:32 PM │
│ 7 Nov 2026 9:05 AM  │
│ soon                │
└─────────────────────┘
14:35 2 PM
```

### fmtDuration (proc) · [#formats-fmtDuration](https://pietroppeter.github.io/tabelline/api/#formats-fmtDuration)

```nim
proc fmtDuration(t: sink Tabella; columns: ColSel = numeric(); rows = allRows();
                 inputUnits = "seconds"; outputUnits: openArray[string] = [];
                 durationStyle = "narrow"; trimZeroUnits = true;
                 maxOutputUnits = 0): Tabella
```

Numbers as lengths of time: 7503 seconds is "2h 5m 3s" (see `formatDuration`).

gt: `fmt_duration()` · Great Tables: `GT.fmt_duration()`

Example (spec formatting):

```nim
let d = tableData:
  secs: [7503.0, 90061.0, 45.0]
let narrow = tabella(d):
  fmtDuration "secs"
echo narrow
let colons = tabella(d):
  fmtDuration "secs", durationStyle = "colon-sep"
echo colons
echo formatDuration(1.5, inputUnits = "days", durationStyle = "wide")
```

```text
┌─────────────┐
│        secs │
╞═════════════╡
│    2h 5m 3s │
│ 1d 1h 1m 1s │
│         45s │
└─────────────┘
┌──────────┐
│     secs │
╞══════════╡
│ 02:05:03 │
│ 25:01:01 │
│ 00:00:45 │
└──────────┘
1 day 12 hours
```

### fmtUrl (proc) · [#formats-fmtUrl](https://pietroppeter.github.io/tabelline/api/#formats-fmtUrl)

```nim
proc fmtUrl(t: sink Tabella; columns: ColSel; rows = allRows(); label = "";
            asButton = false; color = ""; target = ""; showUnderline = true): Tabella
```

Addresses as links: the address is the text, unless `label` is given or the cell is a
Markdown link `[label](address)`; `asButton` draws them as small buttons.

gt: `fmt_url()`

Example (spec formatting):

```nim
let d = tableData:
  site: ["https://nim-lang.org", "[nimib](https://github.com/pietroppeter/nimib)"]
let t = tabella(d):
  fmtUrl "site"
echo t
echo "<a href=\"https://github.com/pietroppeter/nimib\">nimib</a>" in t.toHtml
```

```text
┌──────────────────────┐
│ site                 │
╞══════════════════════╡
│ https://nim-lang.org │
│ nimib                │
└──────────────────────┘
true
```

### fmtEmail (proc) · [#formats-fmtEmail](https://pietroppeter.github.io/tabelline/api/#formats-fmtEmail)

```nim
proc fmtEmail(t: sink Tabella; columns: ColSel; rows = allRows(); label = "";
              asButton = false; color = ""; target = ""; showUnderline = true): Tabella
```

Email addresses as `mailto:` links, as `fmtUrl` does for web addresses.

gt: `fmt_email()`

### countryName (func) · [#formats-countryName](https://pietroppeter.github.io/tabelline/api/#formats-countryName)

```nim
func countryName(code: string): string
```

The English name of a country or territory by its two- or three-letter code (ISO 3166-1),
from Unicode CLDR: `countryName("IT")` and `countryName("ITA")` are "Italy". Other text
is returned as it is.

### circleFlag (func) · [#formats-circleFlag](https://pietroppeter.github.io/tabelline/api/#formats-circleFlag)

```nim
func circleFlag(code: string; height = "1em"): string
```

The round flag of a two- or three-letter country code, as inline SVG (HatScripts'
circle-flags, MIT, which Great Tables draws too); "" when there is none.

### fmtFlag (proc) · [#formats-fmtFlag](https://pietroppeter.github.io/tabelline/api/#formats-fmtFlag)

```nim
proc fmtFlag(t: sink Tabella; columns: ColSel; rows = allRows(); sep = " ";
             useTitle = true; round = false; height = "1em"): Tabella
```

Two-letter (or three-letter) country codes as flags, one or several (a list, or separated by
commas). The flags are emoji, which load nothing but are drawn by the reader's system (as
two letters on Windows); `round = true` draws Great Tables' round flags instead, as inline
SVG of `height`. With `useTitle` the country's name is the HTML title, shown on hover.

gt: `fmt_flag()` · Great Tables: `GT.fmt_flag()`

Example (spec formatting):

```nim
let d = tableData:
  country: ["IT", "JPN", "FR,DE"]
let t = tabella(d):
  fmtFlag "country"
echo t
```

```text
┌─────────┐
│ country │
╞═════════╡
│ 🇮🇹      │
│ 🇯🇵      │
│ 🇫🇷 🇩🇪   │
└─────────┘
```

### subSmallVals (proc) · [#formats-subSmallVals](https://pietroppeter.github.io/tabelline/api/#formats-subSmallVals)

```nim
proc subSmallVals(t: sink Tabella; columns: ColSel = numeric();
                  rows = allRows(); threshold = 0.01; smallPattern = "<{x}";
                  sign = "+"): Tabella
```

Shows numbers closer to zero than `threshold` (but not zero) as `smallPattern`, with the
threshold for `{x}`: "<0.01". `sign = "-"` does the same for negative numbers ("<−0.01").

gt: `sub_small_vals()` · Great Tables: `GT.sub_small_vals()`

Example (spec formatting):

```nim
let d = tableData:
  x: [0.004, 2.5, 3e13, -99.0]
let t = tabella(d):
  fmtNumber "x"
  subSmallVals()
  subLargeVals()
  subValues values = [-99], replacement = "n/a"
echo t
```

```text
┌───────┐
│     x │
╞═══════╡
│ <0.01 │
│  2.50 │
│  >=1T │
│   n/a │
└───────┘
```

### subLargeVals (proc) · [#formats-subLargeVals](https://pietroppeter.github.io/tabelline/api/#formats-subLargeVals)

```nim
proc subLargeVals(t: sink Tabella; columns: ColSel = numeric();
                  rows = allRows(); threshold = 1000000000000.0;
                  largePattern = ">={x}"; sign = "+"): Tabella
```

Shows numbers at or beyond `threshold` as `largePattern`: ">=1T". `sign = "-"` does the
same for numbers at or below minus the threshold.

gt: `sub_large_vals()` · Great Tables: `GT.sub_large_vals()`

Example (spec formatting):

```nim
let d = tableData:
  x: [0.004, 2.5, 3e13, -99.0]
let t = tabella(d):
  fmtNumber "x"
  subSmallVals()
  subLargeVals()
  subValues values = [-99], replacement = "n/a"
echo t
```

```text
┌───────┐
│     x │
╞═══════╡
│ <0.01 │
│  2.50 │
│  >=1T │
│   n/a │
└───────┘
```

### subValues (proc) · [#formats-subValues](https://pietroppeter.github.io/tabelline/api/#formats-subValues)

```nim
proc subValues(t: sink Tabella; columns: ColSel = everything();
               rows = allRows(); fn: proc (v: Value): bool; replacement: string): Tabella
proc subValues[T](t: sink Tabella; columns: ColSel = everything();
                  rows = allRows(); values: openArray[T]; replacement: string): Tabella
```

Shows the values for which `fn` holds as `replacement`.

gt: `sub_values()` · Great Tables: `GT.sub_values()`

Example (spec formatting):

```nim
let d = tableData:
  x: [0.004, 2.5, 3e13, -99.0]
let t = tabella(d):
  fmtNumber "x"
  subSmallVals()
  subLargeVals()
  subValues values = [-99], replacement = "n/a"
echo t
```

```text
┌───────┐
│     x │
╞═══════╡
│ <0.01 │
│  2.50 │
│  >=1T │
│   n/a │
└───────┘
```

### fmtTf (proc) · [#formats-fmtTf](https://pietroppeter.github.io/tabelline/api/#formats-fmtTf)

```nim
proc fmtTf(t: sink Tabella; columns: ColSel; rows = allRows();
           tfStyle = "check-mark"; trueText = ""; falseText = ""; naText = "";
           colors: openArray[string] = []; html = false): Tabella
```

Booleans as two texts: a named `tfStyle` ("true-false", "yes-no", "check-mark", "circles",
"arrows", ... see `tfStyles`) or your own `trueText` and `falseText`; `naText` for missing
values; `colors` (for true, false) colour them in HTML; with `html = true` the texts are
HTML (an SVG symbol, say) and are not escaped.

gt: `fmt_tf()` · Great Tables: `GT.fmt_tf()`

Example (spec formatting):

```nim
let d = tableData:
  day: ["2026-11-07", "2015-01-15"]
  ok: [true, false]
  stars: [3, 1]
let t = tabella(d):
  fmtDate "day", dateStyle = "day_month_year"
  fmtTf "ok", trueText = "yes", falseText = "no"
  fmt "stars", proc (v: Value): string = "*".repeat(v.i)
echo t
```

```text
┌─────────────────┬─────┬───────┐
│ day             │ ok  │ stars │
╞═════════════════╪═════╪═══════╡
│ 7 November 2026 │ yes │   *** │
│ 15 January 2015 │ no  │     * │
└─────────────────┴─────┴───────┘
```

### formatFraction (func) · [#formats-formatFraction](https://pietroppeter.github.io/tabelline/api/#formats-formatFraction)

```nim
func formatFraction(x: float; accuracy = "low"; denominator = 0;
                    simplify = true; layout = "inline"; useSeps = true;
                    sepMark = ","; ctx = rcText): string
```

A number as a mixed fraction: `formatFraction(2.25)` is "2 1/4", `formatFraction(0.333)`
is "1/3". `accuracy` is "low" (denominators up to 9), "med" (99) or "high" (999); a
`denominator` fixes it ("2/16"), reduced when `simplify`. `layout = "diagonal"` shows
"2¼"-style fractions (`<sup>` and `<sub>` in HTML).

### formatBins (proc) · [#formats-formatBins](https://pietroppeter.github.io/tabelline/api/#formats-formatBins)

```nim
proc formatBins(s: string; sep = "--"; fmt: proc (x: float): string = nil): string
```

A bin written as an interval, `"[10,20)"` or `"(0,5]"`, as a range: "10–20". `sep` goes
between the two ends (`--` is an en dash); `fmt` formats each end.

### formatCountry (func) · [#formats-formatCountry](https://pietroppeter.github.io/tabelline/api/#formats-formatCountry)

```nim
func formatCountry(codes: string; sep = ", "): string
```

Country codes (comma or space separated) as names: `formatCountry("IT, FR")` is
"Italy, France".

### fmtFraction (proc) · [#formats-fmtFraction](https://pietroppeter.github.io/tabelline/api/#formats-fmtFraction)

```nim
proc fmtFraction(t: sink Tabella; columns: ColSel = numeric(); rows = allRows();
                 accuracy = "low"; denominator = 0; simplify = true;
                 layout = "inline"; useSeps = true; pattern = "{x}"; locale = ""): Tabella
```

Numbers as mixed fractions: 2.25 is "2 1/4" (see `formatFraction`).

gt: `fmt_fraction()`

Example (spec formatting):

```nim
let d = tableData:
  x: [0.25, 1.5, 2.333, 0.999, -0.125]
let t = tabella(d):
  colsAdd "diagonal", d["x"].values
  colsAdd "sixteenths", d["x"].values
  fmtFraction "x"
  fmtFraction "diagonal", layout = "diagonal"
  fmtFraction "sixteenths", denominator = 16
echo t
```

```text
┌───────┬──────────┬────────────┐
│     x │ diagonal │ sixteenths │
╞═══════╪══════════╪════════════╡
│   1/4 │      ¹⁄₄ │        1/4 │
│ 1 1/2 │     1¹⁄₂ │      1 1/2 │
│ 2 1/3 │     2¹⁄₃ │     2 5/16 │
│     1 │        1 │          1 │
│  −1/8 │     −¹⁄₈ │       −1/8 │
└───────┴──────────┴────────────┘
```

### fmtBins (proc) · [#formats-fmtBins](https://pietroppeter.github.io/tabelline/api/#formats-fmtBins)

```nim
proc fmtBins(t: sink Tabella; columns: ColSel; rows = allRows(); sep = "--";
             fmt: proc (x: float): string = nil): Tabella
```

Intervals such as "[10,20)" as ranges, "10–20"; `fmt` formats both ends:
`fmtBins("size", fmt = x => formatNumber(x, 0))`.

gt: `fmt_bins()`

Example (spec formatting):

```nim
let d = tableData:
  population: ["[0,1e+06)", "[1e+06,1e+07)", "[1e+07,1e+08)"]
  countries: [52, 61, 83]
let t = tabella(d):
  fmtBins "population", fmt = proc (x: float): string = formatCompact(x, 0)
echo t
```

```text
┌────────────┬───────────┐
│ population │ countries │
╞════════════╪═══════════╡
│ 0–1M       │        52 │
│ 1M–10M     │        61 │
│ 10M–100M   │        83 │
└────────────┴───────────┘
```

### fmtPassthrough (proc) · [#formats-fmtPassthrough](https://pietroppeter.github.io/tabelline/api/#formats-fmtPassthrough)

```nim
proc fmtPassthrough(t: sink Tabella; columns: ColSel = everything();
                    rows = allRows(); escape = true; pattern = "{x}"): Tabella
```

Values shown as they are, in a `pattern`; with `escape = false` a value is HTML.

gt: `fmt_passthrough()`

Example (spec formatting):

```nim
let d = tableData:
  item: ["a", "b", "c"]
  count: [3, 2500000, 12]
  ratio: [0.5, 0.0000123, 1.25]
  price_eur: [3.5, 10.0, 99.99]
let t = tabella(d):
  fmtAuto()
  fmtPassthrough "item", pattern = "item {x}"
echo t
```

```text
┌────────┬───────────┬─────────────┬───────────┐
│ item   │     count │       ratio │ price_eur │
╞════════╪═══════════╪═════════════╪═══════════╡
│ item a │         3 │         0.5 │     €3.50 │
│ item b │ 2.5 × 10⁶ │ 1.23 × 10⁻⁵ │    €10.00 │
│ item c │        12 │        1.25 │    €99.99 │
└────────┴───────────┴─────────────┴───────────┘
```

### fmtCountry (proc) · [#formats-fmtCountry](https://pietroppeter.github.io/tabelline/api/#formats-fmtCountry)

```nim
proc fmtCountry(t: sink Tabella; columns: ColSel; rows = allRows();
                pattern = "{x}"; sep = ", "): Tabella
```

Two- or three-letter country codes as English names, from CLDR: "IT" is "Italy".

gt: `fmt_country()`

Example (spec formatting):

```nim
let d = tableData:
  codes: ["IT", "jpn", "FR, DE", "XX"]
let t = tabella(d):
  colsAdd "names", d["codes"].values
  fmtCountry "names"
echo t
```

```text
┌────────┬─────────────────┐
│ codes  │ names           │
╞════════╪═════════════════╡
│ IT     │ Italy           │
│ jpn    │ Japan           │
│ FR, DE │ France, Germany │
│ XX     │ XX              │
└────────┴─────────────────┘
```

### fmtAuto (proc) · [#formats-fmtAuto](https://pietroppeter.github.io/tabelline/api/#formats-fmtAuto)

```nim
proc fmtAuto(t: sink Tabella; columns: ColSel = everything(); rows = allRows();
             scope: openArray[string] = ["numbers", "currency"];
             lgNumPref = "sci"; locale = ""): Tabella
```

A format for each column, from its values: numbers with as many decimals as they need (up
to 3), very small or large ones in scientific notation (`lgNumPref = "suf"`: large ones
with a suffix, "12.3M"), and a currency when the column's name ends with an ISO 4217 code
("price_eur").

gt: `fmt_auto()`

Example (spec formatting):

```nim
let d = tableData:
  item: ["a", "b", "c"]
  count: [3, 2500000, 12]
  ratio: [0.5, 0.0000123, 1.25]
  price_eur: [3.5, 10.0, 99.99]
let t = tabella(d):
  fmtAuto()
  fmtPassthrough "item", pattern = "item {x}"
echo t
```

```text
┌────────┬───────────┬─────────────┬───────────┐
│ item   │     count │       ratio │ price_eur │
╞════════╪═══════════╪═════════════╪═══════════╡
│ item a │         3 │         0.5 │     €3.50 │
│ item b │ 2.5 × 10⁶ │ 1.23 × 10⁻⁵ │    €10.00 │
│ item c │        12 │        1.25 │    €99.99 │
└────────┴───────────┴─────────────┴───────────┘
```

## Units (`tabelline/units`)

Units and chemical formulas written as text, in gt's units notation: `"kg/m^3"`, `"m s^-2"`, `"m /s"` (a unit after a solidus is a power −1), `"T_eff"`, `":mu:g"`, `"degC"`, `"%H2O%"`.

### formatChem (func) · [#units-formatChem](https://pietroppeter.github.io/tabelline/api/#units-formatChem)

```nim
func formatChem(s: string; ctx = rcText): string
```

A chemical formula or reaction, in gt's notation: `formatChem("CuSO4 * 5H2O")` is "CuSO₄⋅5 H₂O",
`formatChem("2H2 + O2 -> 2H2O")` is "2 H₂ + O₂ → 2 H₂O".

Example (spec formatting):

```nim
let d = tableData:
  name: ["water", "copper sulfate", "sulfate", "carbon-14"]
  formula: ["H2O", "CuSO4 * 5H2O", "SO4^2-", "^14C"]
let t = tabella(d, rownameCol = "name"):
  fmtChem "formula"
echo t
echo formatChem("2H2 + O2 -> 2H2O")
```

```text
┌────────────────┬─────────────┐
│                │ formula     │
╞════════════════╪═════════════╡
│ water          │ H₂O         │
│ copper sulfate │ CuSO₄⋅5 H₂O │
│ sulfate        │ SO₄²⁻       │
│ carbon-14      │ ¹⁴C         │
└────────────────┴─────────────┘
2 H₂ + O₂ → 2 H₂O
```

### formatUnits (func) · [#units-formatUnits](https://pietroppeter.github.io/tabelline/api/#units-formatUnits)

```nim
func formatUnits(s: string; ctx = rcText): string
```

Units in gt's notation: `formatUnits("kg/m^3")` is "kg/m³", `formatUnits("m /s")` is
"m s⁻¹", `formatUnits("T_eff")` is "Tₑff" in text and `T<sub>eff</sub>` in HTML. A part
between `%` signs is a chemical formula: `"g %CO2%"`.

### withUnits (func) · [#units-withUnits](https://pietroppeter.github.io/tabelline/api/#units-withUnits)

```nim
func withUnits(s: string; ctx: RenderContext;
               plain: proc (s: string): string
```

A label with units between `{{` and `}}`: the units are formatted, the rest goes through
`plain`.

### fmtUnits (proc) · [#units-fmtUnits](https://pietroppeter.github.io/tabelline/api/#units-fmtUnits)

```nim
proc fmtUnits(t: sink Tabella; columns: ColSel; rows = allRows()): Tabella
```

Cells written in gt's units notation, shown as units: `"m s^-2"` is "m s⁻²".

gt: `fmt_units()` · Great Tables: `GT.fmt_units()`

Example (spec formatting):

```nim
let d = tableData:
  quantity: ["speed of sound", "gravity", "air density"]
  value: [343.0, 9.81, 1.204]
  units: ["m /s", "m s^-2", "kg m^-3"]
let quantities = tabella(d, rownameCol = "quantity"):
  fmtUnits "units"
  colsLabel:
    value: "at {{20 degC}}"
echo quantities
let gravity = tabella(planets(), rownameCol = "planet"):
  colsHide everything()
  colsUnhide ["density", "gravity"]
  colsUnits:
    density: "kg m^-3"
    gravity: "m s^-2"
    unitsPattern = "{1} ({2})"
echo gravity
```

```text
┌────────────────┬──────────┬────────┐
│                │ at 20 °C │ units  │
╞════════════════╪══════════╪════════╡
│ speed of sound │    343.0 │ m s⁻¹  │
│ gravity        │     9.81 │ m s⁻²  │
│ air density    │    1.204 │ kg m⁻³ │
└────────────────┴──────────┴────────┘
┌─────────┬──────────────────┬─────────────────┐
│         │ density (kg m⁻³) │ gravity (m s⁻²) │
╞═════════╪══════════════════╪═════════════════╡
│ Mercury │             5429 │             3.7 │
│ Venus   │             5243 │             8.9 │
│ Earth   │             5514 │             9.8 │
│ Mars    │             3934 │             3.7 │
│ Jupiter │             1326 │            23.1 │
│ Saturn  │              687 │             9.0 │
│ Uranus  │             1270 │             8.7 │
│ Neptune │             1638 │            11.0 │
└─────────┴──────────────────┴─────────────────┘
```

### fmtChem (proc) · [#units-fmtChem](https://pietroppeter.github.io/tabelline/api/#units-fmtChem)

```nim
proc fmtChem(t: sink Tabella; columns: ColSel; rows = allRows()): Tabella
```

Cells written as chemical formulas or reactions: `"H2SO4"` is "H₂SO₄".

gt: `fmt_chem()`

Example (spec formatting):

```nim
let d = tableData:
  name: ["water", "copper sulfate", "sulfate", "carbon-14"]
  formula: ["H2O", "CuSO4 * 5H2O", "SO4^2-", "^14C"]
let t = tabella(d, rownameCol = "name"):
  fmtChem "formula"
echo t
echo formatChem("2H2 + O2 -> 2H2O")
```

```text
┌────────────────┬─────────────┐
│                │ formula     │
╞════════════════╪═════════════╡
│ water          │ H₂O         │
│ copper sulfate │ CuSO₄⋅5 H₂O │
│ sulfate        │ SO₄²⁻       │
│ carbon-14      │ ¹⁴C         │
└────────────────┴─────────────┘
2 H₂ + O₂ → 2 H₂O
```

### colsUnits (proc) · [#units-colsUnits](https://pietroppeter.github.io/tabelline/api/#units-colsUnits)

```nim
proc colsUnits(t: sink Tabella; units: openArray[(string, string)];
               unitsPattern = ""): Tabella
```

Units for column labels, in gt's notation: `colsUnits({"density": "kg/m^3"})` shows the
label "density, kg/m³". `unitsPattern` places them: `{1}` is the label, `{2}` the units ("": the option
`columnLabelsUnitsPattern`, "{1}, {2}").
Inside `tabella(data): body`, also as a block, one pair per line (see `tabella`):
`colsUnits:` then `density: "kg/m^3"`.

gt: `cols_units()`

Example (spec formatting):

```nim
let d = tableData:
  quantity: ["speed of sound", "gravity", "air density"]
  value: [343.0, 9.81, 1.204]
  units: ["m /s", "m s^-2", "kg m^-3"]
let quantities = tabella(d, rownameCol = "quantity"):
  fmtUnits "units"
  colsLabel:
    value: "at {{20 degC}}"
echo quantities
let gravity = tabella(planets(), rownameCol = "planet"):
  colsHide everything()
  colsUnhide ["density", "gravity"]
  colsUnits:
    density: "kg m^-3"
    gravity: "m s^-2"
    unitsPattern = "{1} ({2})"
echo gravity
```

```text
┌────────────────┬──────────┬────────┐
│                │ at 20 °C │ units  │
╞════════════════╪══════════╪════════╡
│ speed of sound │    343.0 │ m s⁻¹  │
│ gravity        │     9.81 │ m s⁻²  │
│ air density    │    1.204 │ kg m⁻³ │
└────────────────┴──────────┴────────┘
┌─────────┬──────────────────┬─────────────────┐
│         │ density (kg m⁻³) │ gravity (m s⁻²) │
╞═════════╪══════════════════╪═════════════════╡
│ Mercury │             5429 │             3.7 │
│ Venus   │             5243 │             8.9 │
│ Earth   │             5514 │             9.8 │
│ Mars    │             3934 │             3.7 │
│ Jupiter │             1326 │            23.1 │
│ Saturn  │              687 │             9.0 │
│ Uranus  │             1270 │             8.7 │
│ Neptune │             1638 │            11.0 │
└─────────┴──────────────────┴─────────────────┘
```

## The verbs (`tabelline/verbs`)

The verbs that build a table spec, named after gt and Great Tables in camelCase: `tab*` add parts (header, spanners, notes, styles, options), `cols*` change columns, `dataColor` and `opt*` change the looks.

### initTabella (proc) · [#verbs-initTabella](https://pietroppeter.github.io/tabelline/api/#verbs-initTabella)

```nim
proc initTabella(data: TableData; rownameCol = ""; groupnameCol = ""; id = "";
                 locale = ""; autoAlign = true): Tabella
proc initTabella(data: TableData; rownameCol: openArray[string];
                 groupnameCol = ""; id = ""; locale = ""; autoAlign = true;
                 rowGroupAsColumn = false): Tabella
proc initTabella(data: TableData; rownameCol: string; groupnameCol: string;
                 rowGroupAsColumn: bool; id = ""; locale = ""; autoAlign = true): Tabella
proc initTabella[T: object | tuple](rows: openArray[T]; rownameCol = "";
                                    groupnameCol = ""; id = ""; locale = ""): Tabella
proc initTabella[T: object | tuple](rows: openArray[T];
                                    rownameCol: openArray[string];
                                    groupnameCol = ""; id = ""; locale = "";
                                    rowGroupAsColumn = false): Tabella
proc initTabella(t: sink Tabella): Tabella
```

A display table for `data`. `rownameCol` makes a column the stub (row labels),
`groupnameCol` groups the rows by a column, in order of first appearance.

### tabHeader (proc) · [#verbs-tabHeader](https://pietroppeter.github.io/tabelline/api/#verbs-tabHeader)

```nim
proc tabHeader(t: sink Tabella; title: Text; subtitle: Text = toText("")): Tabella
```

gt: `tab_header()` · Great Tables: `GT.tab_header()`

Example (spec rendering):

```nim
let t = tabella(tavolaPitagorica(3), rownameCol = "×"):
  tabHeader "Tabellina"
  tabFootnote "by heart", loc.title()
echo t
```

```text
   Tabellina^1
┌───┬───┬───┬───┐
│   │ 1 │ 2 │ 3 │
╞═══╪═══╪═══╪═══╡
│ 1 │ 1 │ 2 │ 3 │
│ 2 │ 2 │ 4 │ 6 │
│ 3 │ 3 │ 6 │ 9 │
└───┴───┴───┴───┘
1 by heart
```

### tabStubhead (proc) · [#verbs-tabStubhead](https://pietroppeter.github.io/tabelline/api/#verbs-tabStubhead)

```nim
proc tabStubhead(t: sink Tabella; label: Text): Tabella
```

gt: `tab_stubhead()` · Great Tables: `GT.tab_stubhead()`

Example (spec table-parts):

```nim
let t = tabella(tavolaPitagorica(3), rownameCol = "×"):
  tabHeader "Times table", "from 1 to 3"
  tabStubhead "×"
  tabSourceNote md("Learned **by heart**")
echo t
```

```text
   Times table
   from 1 to 3
┌───┬───┬───┬───┐
│ × │ 1 │ 2 │ 3 │
╞═══╪═══╪═══╪═══╡
│ 1 │ 1 │ 2 │ 3 │
│ 2 │ 2 │ 4 │ 6 │
│ 3 │ 3 │ 6 │ 9 │
└───┴───┴───┴───┘
Learned by heart
```

### tabSpanner (proc) · [#verbs-tabSpanner](https://pietroppeter.github.io/tabelline/api/#verbs-tabSpanner)

```nim
proc tabSpanner(t: sink Tabella; label: Text; columns: ColSel; level = 1;
                gather = true): Tabella
```

A label over `columns`. Higher `level`s sit above lower ones. With `gather` (the default, as
in gt) the columns are moved next to the first of them, in the order given, so the label
spans them all; with `gather = false` they stay where they are.

gt: `tab_spanner()` · Great Tables: `GT.tab_spanner()`

Example (spec table-parts):

```nim
let t = tabella(planets(), rownameCol = "planet"):
  colsHide ["type", "density", "gravity", "day_length", "orbital_period", "mean_temp", "rings"]
  rowsHide 2 .. 7
  tabSpanner "size", ["mass", "diameter", "moons"]
echo t
```

```text
┌─────────┬──────┬──────────┬───────┬──────────┐
│         │          size           │          │
│         │ mass │ diameter │ moons │ distance │
╞═════════╪══════╪══════════╪═══════╪══════════╡
│ Mercury │ 0.33 │     4879 │     0 │     57.9 │
│ Venus   │ 4.87 │    12104 │     0 │    108.2 │
└─────────┴──────┴──────────┴───────┴──────────┘
```

### tabSpannerDelim (proc) · [#verbs-tabSpannerDelim](https://pietroppeter.github.io/tabelline/api/#verbs-tabSpannerDelim)

```nim
proc tabSpannerDelim(t: sink Tabella; delim = ".";
                     columns: ColSel = everything(); split = "last"; limit = -1;
                     reverse = false): Tabella
```

Spanners and labels from column names: `"size.mass"` gets the label "mass" under a spanner
"size". Names with more parts get more levels; next to each other, the same parts make one
spanner. `limit` caps the splits, counted from the `split` side ("last" or "first");
`reverse` reads the parts the other way round.

gt: `tab_spanner_delim()` · Great Tables: `GT.tab_spanner_delim()`

Example (spec table-parts):

```nim
let d = tableData:
  planet: ["Earth", "Mars"]
  size.diameter: [12756, 6792]
  size.mass: [5.97, 0.642]
  orbit.period.days: [365.2, 687.0]
  orbit.period.years: [1.0, 1.88]
  orbit.distance: [149.6, 228.0]
let t = tabella(d, rownameCol = "planet"):
  tabSpannerDelim()
echo t
```

```text
┌───────┬──────────┬───────┬───────┬───────┬──────────┐
│       │                  │          orbit           │
│       │       size       │    period     │          │
│       │ diameter │  mass │  days │ years │ distance │
╞═══════╪══════════╪═══════╪═══════╪═══════╪══════════╡
│ Earth │    12756 │  5.97 │ 365.2 │   1.0 │    149.6 │
│ Mars  │     6792 │ 0.642 │ 687.0 │  1.88 │    228.0 │
└───────┴──────────┴───────┴───────┴───────┴──────────┘
```

### tabCaption (proc) · [#verbs-tabCaption](https://pietroppeter.github.io/tabelline/api/#verbs-tabCaption)

```nim
proc tabCaption(t: sink Tabella; caption: Text): Tabella
```

A caption for the table (an HTML `<caption>`), for screen readers and for figures.

gt: `tab_caption()`

Example (spec table-parts):

```nim
let t = tabella(tavolaPitagorica(2)):
  tabCaption "Table 1: the times table of 2"
echo "<caption class=\"tb_caption\">Table 1: the times table of 2</caption>" in t.toHtml
echo t
```

```text
true
Table 1: the times table of 2
┌───┬───┬───┐
│ × │ 1 │ 2 │
╞═══╪═══╪═══╡
│ 1 │ 1 │ 2 │
│ 2 │ 2 │ 4 │
└───┴───┴───┘
```

### tabSourceNote (proc) · [#verbs-tabSourceNote](https://pietroppeter.github.io/tabelline/api/#verbs-tabSourceNote)

```nim
proc tabSourceNote(t: sink Tabella; note: Text): Tabella
```

gt: `tab_source_note()` · Great Tables: `GT.tab_source_note()`

Example (spec table-parts):

```nim
let t = tabella(tavolaPitagorica(3), rownameCol = "×"):
  tabHeader "Times table", "from 1 to 3"
  tabStubhead "×"
  tabSourceNote md("Learned **by heart**")
echo t
```

```text
   Times table
   from 1 to 3
┌───┬───┬───┬───┐
│ × │ 1 │ 2 │ 3 │
╞═══╪═══╪═══╪═══╡
│ 1 │ 1 │ 2 │ 3 │
│ 2 │ 2 │ 4 │ 6 │
│ 3 │ 3 │ 6 │ 9 │
└───┴───┴───┴───┘
Learned by heart
```

### tabRowGroup (proc) · [#verbs-tabRowGroup](https://pietroppeter.github.io/tabelline/api/#verbs-tabRowGroup)

```nim
proc tabRowGroup(t: sink Tabella; label: Text;
                 rows: RowSel = RowSel(kind: rsIndices); id = ""): Tabella
```

Puts `rows` in a group (made when it is new). Groups show in the order they are made, and
rows in no group come first. With the `id` of a group already there (one made by
`groupnameCol` is named by its value), `label` is its new label: `tabRowGroup(md("[gt](...)"),
id = "gt")` makes a link of it, as gt's `tab_row_group(label = md(...))`.

gt: `tab_row_group()`

Example (spec table-parts):

```nim
let t = tabella(planets(), rownameCol = "planet"):
  colsHide ["type", "mass", "diameter", "density", "gravity", "day_length", "orbital_period", "mean_temp", "rings"]
  tabRowGroup "Giants", where(it["type"] != "Terrestrial")
echo t
```

```text
┌─────────┬──────────┬───────┐
│         │ distance │ moons │
╞═════════╪══════════╪═══════╡
│ Mercury │     57.9 │     0 │
│ Venus   │    108.2 │     0 │
│ Earth   │    149.6 │     1 │
│ Mars    │    228.0 │     2 │
├─────────┼──────────┼───────┤
│ Giants                     │
├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤
│ Jupiter │    778.5 │    95 │
│ Saturn  │   1432.0 │   146 │
│ Uranus  │   2867.0 │    28 │
│ Neptune │   4515.0 │    16 │
└─────────┴──────────┴───────┘
```

### tabStub (proc) · [#verbs-tabStub](https://pietroppeter.github.io/tabelline/api/#verbs-tabStub)

```nim
proc tabStub(t: sink Tabella; rownameCol = ""; groupnameCol = ""): Tabella
proc tabStub(t: sink Tabella; rownameCol: openArray[string]; groupnameCol = ""): Tabella
```

Chooses the stub (and the row groups) of a table already made, as Great Tables'
`tab_stub(rowname_col, groupname_col)`: the same as `tabella(data, rownameCol = ...,
groupnameCol = ...)`. Verbs called before it keep what they did to other columns.

Great Tables: `GT.tab_stub()`

Example (spec table-parts):

```nim
let t = tabella(planets()):
  colsHide ["mass", "diameter", "density", "gravity", "day_length", "distance", "orbital_period", "mean_temp", "moons"]
  tabStub "planet", groupnameCol = "type"
  tabRowGroup md"*Gas* giants", id = "Gas giant"
echo t
```

```text
┌─────────┬───────┐
│         │ rings │
╞═════════╪═══════╡
│ Terrestrial     │
├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤
│ Mercury │ false │
│ Venus   │ false │
│ Earth   │ false │
│ Mars    │ false │
├─────────┼───────┤
│ Gas giants      │
├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤
│ Jupiter │ true  │
│ Saturn  │ true  │
├─────────┼───────┤
│ Ice giant       │
├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤
│ Uranus  │ true  │
│ Neptune │ true  │
└─────────┴───────┘
```

### rmHeader (proc) · [#verbs-rmHeader](https://pietroppeter.github.io/tabelline/api/#verbs-rmHeader)

```nim
proc rmHeader(t: sink Tabella): Tabella
```

Removes the title and the subtitle.

gt: `rm_header()`

Example (spec table-parts):

```nim
let base = tabella(tavolaPitagorica(2), rownameCol = "×"):
  tabHeader "Times", "of two"
  tabSourceNote "One."
  tabSourceNote "Two."
let less = tabella(base):
  rmHeader()
  rmSourceNotes [0]
echo less
```

```text
┌───┬───┬───┐
│   │ 1 │ 2 │
╞═══╪═══╪═══╡
│ 1 │ 1 │ 2 │
│ 2 │ 2 │ 4 │
└───┴───┴───┘
Two.
```

### rmStubhead (proc) · [#verbs-rmStubhead](https://pietroppeter.github.io/tabelline/api/#verbs-rmStubhead)

```nim
proc rmStubhead(t: sink Tabella): Tabella
```

gt: `rm_stubhead()`

### rmCaption (proc) · [#verbs-rmCaption](https://pietroppeter.github.io/tabelline/api/#verbs-rmCaption)

```nim
proc rmCaption(t: sink Tabella): Tabella
```

gt: `rm_caption()`

### rmSpanners (proc) · [#verbs-rmSpanners](https://pietroppeter.github.io/tabelline/api/#verbs-rmSpanners)

```nim
proc rmSpanners(t: sink Tabella; spanners: openArray[string] = [];
                levels: openArray[int] = []): Tabella
```

Removes the spanners with these labels, or at these levels; with neither, every spanner.

gt: `rm_spanners()`

### rmFootnotes (proc) · [#verbs-rmFootnotes](https://pietroppeter.github.io/tabelline/api/#verbs-rmFootnotes)

```nim
proc rmFootnotes(t: sink Tabella; footnotes: openArray[int] = []): Tabella
```

Removes the footnotes at these indices (0-based, in the order they were added), or all.

gt: `rm_footnotes()`

### rmSourceNotes (proc) · [#verbs-rmSourceNotes](https://pietroppeter.github.io/tabelline/api/#verbs-rmSourceNotes)

```nim
proc rmSourceNotes(t: sink Tabella; sourceNotes: openArray[int] = []): Tabella
```

Removes the source notes at these indices (0-based), or all.

gt: `rm_source_notes()`

Example (spec table-parts):

```nim
let base = tabella(tavolaPitagorica(2), rownameCol = "×"):
  tabHeader "Times", "of two"
  tabSourceNote "One."
  tabSourceNote "Two."
let less = tabella(base):
  rmHeader()
  rmSourceNotes [0]
echo less
```

```text
┌───┬───┬───┐
│   │ 1 │ 2 │
╞═══╪═══╪═══╡
│ 1 │ 1 │ 2 │
│ 2 │ 2 │ 4 │
└───┴───┴───┘
Two.
```

### title (func) · [#verbs-title](https://pietroppeter.github.io/tabelline/api/#verbs-title)

```nim
func title(_: LocNs): Loc
```

Great Tables: `loc.title()`

Example (spec rendering):

```nim
let t = tabella(tavolaPitagorica(3), rownameCol = "×"):
  tabHeader "Tabellina"
  tabFootnote "by heart", loc.title()
echo t
```

```text
   Tabellina^1
┌───┬───┬───┬───┐
│   │ 1 │ 2 │ 3 │
╞═══╪═══╪═══╪═══╡
│ 1 │ 1 │ 2 │ 3 │
│ 2 │ 2 │ 4 │ 6 │
│ 3 │ 3 │ 6 │ 9 │
└───┴───┴───┴───┘
1 by heart
```

### subtitle (func) · [#verbs-subtitle](https://pietroppeter.github.io/tabelline/api/#verbs-subtitle)

```nim
func subtitle(_: LocNs): Loc
```

Great Tables: `loc.subtitle()`

### stubhead (func) · [#verbs-stubhead](https://pietroppeter.github.io/tabelline/api/#verbs-stubhead)

```nim
func stubhead(_: LocNs): Loc
```

Great Tables: `loc.stubhead()`

Example (spec formatting):

```nim
let t = tabella(planets(), rownameCol = "planet"):
  tabStubhead "planet"
  colsHide ["type", "mass", "diameter", "density", "gravity", "day_length", "distance", "orbital_period", "mean_temp", "moons"]
  textTransform toUpperAscii, loc.stub()
  fmtTf "rings", tfStyle = "yes-no"
  textCaseMatch:
    yes: "rings!"
    default = ""
    locations = loc.body("rings")
  textReplace "planet", "Planet", loc.stubhead()
echo t
```

```text
┌─────────┬────────┐
│ Planet  │ rings  │
╞═════════╪════════╡
│ MERCURY │ no     │
│ VENUS   │ no     │
│ EARTH   │ no     │
│ MARS    │ no     │
│ JUPITER │ rings! │
│ SATURN  │ rings! │
│ URANUS  │ rings! │
│ NEPTUNE │ rings! │
└─────────┴────────┘
```

### columnLabels (func) · [#verbs-columnLabels](https://pietroppeter.github.io/tabelline/api/#verbs-columnLabels)

```nim
func columnLabels(_: LocNs; cols: ColSel = everything()): Loc
```

Great Tables: `loc.column_labels()`

Example (spec table-parts):

```nim
let t = tabella(planets(), rownameCol = "planet"):
  colsHide ["type", "mass", "diameter", "density", "gravity", "day_length", "distance", "orbital_period", "rings"]
  tabFootnote "Hotter than Mercury.", loc.body(cols = "mean_temp", rows = where(it.planet == "Venus"))
  tabFootnote "As of 2024.", loc.columnLabels("moons")
echo t
```

```text
┌─────────┬───────────┬─────────┐
│         │ mean_temp │ moons^1 │
╞═════════╪═══════════╪═════════╡
│ Mercury │       167 │       0 │
│ Venus   │     464^2 │       0 │
│ Earth   │        15 │       1 │
│ Mars    │       -65 │       2 │
│ Jupiter │      -110 │      95 │
│ Saturn  │      -140 │     146 │
│ Uranus  │      -195 │      28 │
│ Neptune │      -200 │      16 │
└─────────┴───────────┴─────────┘
1 As of 2024.
2 Hotter than Mercury.
```

### spanners (func) · [#verbs-spanners](https://pietroppeter.github.io/tabelline/api/#verbs-spanners)

```nim
func spanners(_: LocNs; labels: varargs[string]): Loc
```

### stub (func) · [#verbs-stub](https://pietroppeter.github.io/tabelline/api/#verbs-stub)

```nim
func stub(_: LocNs; rows = allRows(); cols: ColSel = everything();
          labels: openArray[string] = []): Loc
```

The stub's cells of `rows`; with `labels`, the rows whose stub reads one of them
(`loc.stub(labels = ["banana"])`), together with the `rows` given (`rows = [0], labels =
["banana"]`), as Great Tables' `loc.stub(rows = [0, "banana"])`.

Great Tables: `loc.stub()`

Example (spec styling):

```nim
let t = tabella(tavolaPitagorica(2), rownameCol = "×"):
  tabFootnote "A note with no mark."
  tabFootnote "Two twos.", loc.body(cols = "2", rows = [1])
  tabFootnote "The first row.", loc.stub(rows = [0])
  optFootnoteMarks "standard"
  optFootnoteSpec "^", "("
  optFootnoteOrder "marks_last"
echo t
```

```text
┌─────┬───┬─────┐
│     │ 1 │   2 │
╞═════╪═══╪═════╡
│ 1^* │ 1 │   2 │
│ 2   │ 2 │ 4^† │
└─────┴───┴─────┘
A note with no mark.
(*) The first row.
(†) Two twos.
```

### rowGroups (func) · [#verbs-rowGroups](https://pietroppeter.github.io/tabelline/api/#verbs-rowGroups)

```nim
func rowGroups(_: LocNs; groups: varargs[string]): Loc
func rowGroups(_: LocNs; rows: RowSel): Loc
```

The groups of these rows: `loc.rowGroups(rows = where(it.mass > 100))`, as Great Tables'
`loc.row_groups(rows = ...)`.

Great Tables: `loc.row_groups()`

Example (spec styling):

```nim
let d = tableData:
  name: ["Io", "Europa", "Titan"]
  planet: ["Jupiter", "Jupiter", ""]
  radius: [1821.6, 1560.8, 2574.7]
let t = tabella(d, rownameCol = "name", groupnameCol = "planet"):
  colsUnits:
    radius: "km"
  tabFootnote "Galilean moons.", loc.rowGroups()
  tabSourceNote "NASA"
  tabSourceNote "JPL"
  tabOptions:
    columnLabelsUnitsPattern = "{1} ({2})"
    rowGroupDefaultLabel = "Other moons"
    sourceNotesMultiline = false
    sourceNotesSep = " · "
echo t
let empty = tabella(d):
  rowsHide [0, 1, 2]
  tabOptions(tableNoDataMessage = "No moons")
echo empty
```

```text
┌────────┬─────────────┐
│        │ radius (km) │
╞════════╪═════════════╡
│ Other moons          │
├┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┄┄┄┄┤
│ Titan  │      2574.7 │
├────────┼─────────────┤
│ Jupiter^1            │
├┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┄┄┄┄┤
│ Io     │      1821.6 │
│ Europa │      1560.8 │
└────────┴─────────────┘
1 Galilean moons.
NASA · JPL
┌──────┬────────┬────────┐
│ name │ planet │ radius │
╞══════╪════════╪════════╡
│ No moons               │
└──────┴────────┴────────┘
```

### body (func) · [#verbs-body](https://pietroppeter.github.io/tabelline/api/#verbs-body)

```nim
func body(_: LocNs; cols: ColSel = everything(); rows = allRows()): Loc
func body(_: LocNs; cols: ColSel = everything(); rows = allRows();
          mask: proc (v: Value; col: Column): bool): Loc
func body(_: LocNs; cols: ColSel = everything(); rows = allRows();
          mask: proc (v: Value): bool): Loc
```

The data cells of `cols` and `rows`.

Great Tables: `loc.body()`

Example (spec nim-sugar):

```nim
let t = tabella(tavolaPitagorica(4), rownameCol = "×"):
  tabHeader "Squares"
  for i in 1 .. 4:
    tabFootnote "a square", loc.body(cols = $i, rows = [i - 1])
echo t
```

```text
           Squares
┌───┬─────┬─────┬─────┬──────┐
│   │   1 │   2 │   3 │    4 │
╞═══╪═════╪═════╪═════╪══════╡
│ 1 │ 1^1 │   2 │   3 │    4 │
│ 2 │   2 │ 4^1 │   6 │    8 │
│ 3 │   3 │   6 │ 9^1 │   12 │
│ 4 │   4 │   8 │  12 │ 16^1 │
└───┴─────┴─────┴─────┴──────┘
1 a square
```

### sourceNotes (func) · [#verbs-sourceNotes](https://pietroppeter.github.io/tabelline/api/#verbs-sourceNotes)

```nim
func sourceNotes(_: LocNs): Loc
```

Great Tables: `loc.source_notes()`

### header (func) · [#verbs-header](https://pietroppeter.github.io/tabelline/api/#verbs-header)

```nim
func header(_: LocNs): Loc
```

The title and the subtitle together.

Great Tables: `loc.header()`

### columnHeader (func) · [#verbs-columnHeader](https://pietroppeter.github.io/tabelline/api/#verbs-columnHeader)

```nim
func columnHeader(_: LocNs): Loc
```

The stub head, the spanners and the column labels together.

Great Tables: `loc.column_header()`

### footer (func) · [#verbs-footer](https://pietroppeter.github.io/tabelline/api/#verbs-footer)

```nim
func footer(_: LocNs): Loc
```

The footnotes and the source notes together.

Great Tables: `loc.footer()`

### spannerLabels (func) · [#verbs-spannerLabels](https://pietroppeter.github.io/tabelline/api/#verbs-spannerLabels)

```nim
func spannerLabels(_: LocNs; labels: varargs[string]): Loc
```

The same as `loc.spanners`, by Great Tables' name.

Great Tables: `loc.spanner_labels()`

### footnotes (func) · [#verbs-footnotes](https://pietroppeter.github.io/tabelline/api/#verbs-footnotes)

```nim
func footnotes(_: LocNs): Loc
```

### summary (func) · [#verbs-summary](https://pietroppeter.github.io/tabelline/api/#verbs-summary)

```nim
func summary(_: LocNs; groups: openArray[string] = [];
             columns: ColSel = everything(); rows: openArray[string] = []): Loc
```

The cells of the summary rows of `groups` (all, by default), in `columns`, for the rows
labelled `rows` (all, by default).

### summaryStub (func) · [#verbs-summaryStub](https://pietroppeter.github.io/tabelline/api/#verbs-summaryStub)

```nim
func summaryStub(_: LocNs; groups: openArray[string] = [];
                 rows: openArray[string] = []): Loc
```

The labels of the summary rows, in the stub.

### grandSummary (func) · [#verbs-grandSummary](https://pietroppeter.github.io/tabelline/api/#verbs-grandSummary)

```nim
func grandSummary(_: LocNs; columns: ColSel = everything();
                  rows: openArray[string] = []): Loc
```

The cells of the grand summary rows.

Great Tables: `loc.grand_summary()`

### grandSummaryStub (func) · [#verbs-grandSummaryStub](https://pietroppeter.github.io/tabelline/api/#verbs-grandSummaryStub)

```nim
func grandSummaryStub(_: LocNs; rows: openArray[string] = []): Loc
```

The labels of the grand summary rows, in the stub.

Great Tables: `loc.grand_summary_stub()`

### resolve (proc) · [#verbs-resolve](https://pietroppeter.github.io/tabelline/api/#verbs-resolve)

```nim
proc resolve(l: Loc; t: Tabella): Target
```

### tabStyle (proc) · [#verbs-tabStyle](https://pietroppeter.github.io/tabelline/api/#verbs-tabStyle)

```nim
proc tabStyle(t: sink Tabella; style: CellStyle; locations: varargs[Loc]): Tabella
proc tabStyle(t: sink Tabella; fn: proc (r: Row): CellStyle;
              locations: varargs[Loc]): Tabella
```

Styles the cells at `locations`: `tabStyle(style.fill("#FFF3B0"), loc.body(rows = [2]))`. A
value may come from another column of each row: `style.fill(fromColumn("colour"))`.

Example (spec table-parts):

```nim
let d = tableData:
  mfr: ["Ferrari", "Ferrari", "Ford", "Ford", "Fiat"]
  model: ["Roma", "Portofino", "GT", "Mustang", "500"]
  hp: [612, 600, 647, 450, 69]
let t = tabella(d, rownameCol = ["mfr", "model"]):
  tabStubhead "car"
  tabStyle style.text(weight = "bold"), loc.stub(cols = "mfr")
echo t
echo "stub: ", stubColumns(t).join(", "), "; cells over two rows: ", t.toHtml.count("rowspan=\"2\"")
```

```text
┌─────────┬───────────┬─────┐
│ car     │           │  hp │
╞═════════╪═══════════╪═════╡
│ Ferrari │ Roma      │ 612 │
│         │ Portofino │ 600 │
│ Ford    │ GT        │ 647 │
│         │ Mustang   │ 450 │
│ Fiat    │ 500       │  69 │
└─────────┴───────────┴─────┘
stub: mfr, model; cells over two rows: 2
```

### tabFootnote (proc) · [#verbs-tabFootnote](https://pietroppeter.github.io/tabelline/api/#verbs-tabFootnote)

```nim
proc tabFootnote(t: sink Tabella; note: Text; locations: varargs[Loc]): Tabella
```

A note in the footer, marked at each of `locations` (no location: a plain footnote, no mark).

Example (spec rendering):

```nim
let t = tabella(tavolaPitagorica(3), rownameCol = "×"):
  tabHeader "Tabellina"
  tabFootnote "by heart", loc.title()
echo t
```

```text
   Tabellina^1
┌───┬───┬───┬───┐
│   │ 1 │ 2 │ 3 │
╞═══╪═══╪═══╪═══╡
│ 1 │ 1 │ 2 │ 3 │
│ 2 │ 2 │ 4 │ 6 │
│ 3 │ 3 │ 6 │ 9 │
└───┴───┴───┴───┘
1 by heart
```

### textTransform (proc) · [#verbs-textTransform](https://pietroppeter.github.io/tabelline/api/#verbs-textTransform)

```nim
proc textTransform(t: sink Tabella; fn: proc (s: string): string;
                   locations: varargs[Loc]): Tabella
```

Changes the shown text at `locations` (by default the body) with a proc: for cells the proc
gets the formatted text when the table is rendered (HTML in HTML), for labels and notes their
text now. `textTransform(toUpperAscii, loc.stub())`.

gt: `text_transform()` · Great Tables: `GT.text_transform()`

Example (spec formatting):

```nim
let t = tabella(planets(), rownameCol = "planet"):
  tabStubhead "planet"
  colsHide ["type", "mass", "diameter", "density", "gravity", "day_length", "distance", "orbital_period", "mean_temp", "moons"]
  textTransform toUpperAscii, loc.stub()
  fmtTf "rings", tfStyle = "yes-no"
  textCaseMatch:
    yes: "rings!"
    default = ""
    locations = loc.body("rings")
  textReplace "planet", "Planet", loc.stubhead()
echo t
```

```text
┌─────────┬────────┐
│ Planet  │ rings  │
╞═════════╪════════╡
│ MERCURY │ no     │
│ VENUS   │ no     │
│ EARTH   │ no     │
│ MARS    │ no     │
│ JUPITER │ rings! │
│ SATURN  │ rings! │
│ URANUS  │ rings! │
│ NEPTUNE │ rings! │
└─────────┴────────┘
```

### textReplace (proc) · [#verbs-textReplace](https://pietroppeter.github.io/tabelline/api/#verbs-textReplace)

```nim
proc textReplace(t: sink Tabella; pattern, replacement: string;
                 locations: varargs[Loc]): Tabella
```

Replaces every `pattern` (plain text, not a regex) with `replacement`.

gt: `text_replace()` · Great Tables: `GT.text_replace()`

Example (spec formatting):

```nim
let t = tabella(planets(), rownameCol = "planet"):
  tabStubhead "planet"
  colsHide ["type", "mass", "diameter", "density", "gravity", "day_length", "distance", "orbital_period", "mean_temp", "moons"]
  textTransform toUpperAscii, loc.stub()
  fmtTf "rings", tfStyle = "yes-no"
  textCaseMatch:
    yes: "rings!"
    default = ""
    locations = loc.body("rings")
  textReplace "planet", "Planet", loc.stubhead()
echo t
```

```text
┌─────────┬────────┐
│ Planet  │ rings  │
╞═════════╪════════╡
│ MERCURY │ no     │
│ VENUS   │ no     │
│ EARTH   │ no     │
│ MARS    │ no     │
│ JUPITER │ rings! │
│ SATURN  │ rings! │
│ URANUS  │ rings! │
│ NEPTUNE │ rings! │
└─────────┴────────┘
```

### textCaseMatch (proc) · [#verbs-textCaseMatch](https://pietroppeter.github.io/tabelline/api/#verbs-textCaseMatch)

```nim
proc textCaseMatch(t: sink Tabella; cases: openArray[(string, string)];
                   default = ""; replace = "all"; locations: varargs[Loc]): Tabella
```

Changes texts by cases, `{"old": "new"}`: with `replace = "all"` a text equal to a case
becomes its new text (and any other `default`, when given); with `"partial"` each case is
replaced inside the text.
Inside `tabella(data): body`, also as a block, one pair per line (see `tabella`):
`textCaseMatch:` then `"Gas giant": "giant"` and `locations = loc.body("type")`.

gt: `text_case_match()` · Great Tables: `GT.text_case_match()`

Example (spec formatting):

```nim
let t = tabella(planets(), rownameCol = "planet"):
  tabStubhead "planet"
  colsHide ["type", "mass", "diameter", "density", "gravity", "day_length", "distance", "orbital_period", "mean_temp", "moons"]
  textTransform toUpperAscii, loc.stub()
  fmtTf "rings", tfStyle = "yes-no"
  textCaseMatch:
    yes: "rings!"
    default = ""
    locations = loc.body("rings")
  textReplace "planet", "Planet", loc.stubhead()
echo t
```

```text
┌─────────┬────────┐
│ Planet  │ rings  │
╞═════════╪════════╡
│ MERCURY │ no     │
│ VENUS   │ no     │
│ EARTH   │ no     │
│ MARS    │ no     │
│ JUPITER │ rings! │
│ SATURN  │ rings! │
│ URANUS  │ rings! │
│ NEPTUNE │ rings! │
└─────────┴────────┘
```

### colsLabel (proc) · [#verbs-colsLabel](https://pietroppeter.github.io/tabelline/api/#verbs-colsLabel)

```nim
proc colsLabel(t: sink Tabella; column: string; label: Text): Tabella
proc colsLabel(t: sink Tabella; labels: openArray[(string, string)]): Tabella
proc colsLabel(t: sink Tabella; labels: openArray[(string, Text)]): Tabella
```

`colsLabel({"mass": "Mass", "diameter": "Diameter"})`.
Inside `tabella(data): body`, also as a block, one pair per line (see `tabella`):
`colsLabel:` then `mass: "Mass"` and `diameter: "Diameter"`.

gt: `cols_label()` · Great Tables: `GT.cols_label()`

Example (spec table-parts):

```nim
let t = tabella(planets(), rownameCol = "planet"):
  colsHide ["type", "density", "gravity", "day_length", "mean_temp", "rings", "moons"]
  colsLabel:
    orbital_period: "year"
  tabSpanner "Size", ["mass", "diameter"]
  tabSpanner "Orbit", ["distance", "orbital_period"]
echo t
```

```text
┌─────────┬────────┬──────────┬──────────┬─────────┐
│         │       Size        │       Orbit        │
│         │   mass │ diameter │ distance │    year │
╞═════════╪════════╪══════════╪══════════╪═════════╡
│ Mercury │   0.33 │     4879 │     57.9 │    88.0 │
│ Venus   │   4.87 │    12104 │    108.2 │   224.7 │
│ Earth   │   5.97 │    12756 │    149.6 │   365.2 │
│ Mars    │  0.642 │     6792 │    228.0 │   687.0 │
│ Jupiter │ 1898.0 │   142984 │    778.5 │  4331.0 │
│ Saturn  │  568.0 │   120536 │   1432.0 │ 10747.0 │
│ Uranus  │   86.8 │    51118 │   2867.0 │ 30589.0 │
│ Neptune │  102.0 │    49528 │   4515.0 │ 59800.0 │
└─────────┴────────┴──────────┴──────────┴─────────┘
```

### colsAlign (proc) · [#verbs-colsAlign](https://pietroppeter.github.io/tabelline/api/#verbs-colsAlign)

```nim
proc colsAlign(t: sink Tabella; align: Align; columns: ColSel = everything()): Tabella
```

gt: `cols_align()` · Great Tables: `GT.cols_align()`

### colsWidth (proc) · [#verbs-colsWidth](https://pietroppeter.github.io/tabelline/api/#verbs-colsWidth)

```nim
proc colsWidth(t: sink Tabella; widths: openArray[(string, string)]): Tabella
```

CSS widths: `colsWidth({"name": "120px", "notes": "30%"})`.
Inside `tabella(data): body`, also as a block, one pair per line (see `tabella`):
`colsWidth:` then `name: "120px"` and `notes: "30%"`.

gt: `cols_width()` · Great Tables: `GT.cols_width()`

### colsHide (proc) · [#verbs-colsHide](https://pietroppeter.github.io/tabelline/api/#verbs-colsHide)

```nim
proc colsHide(t: sink Tabella; columns: ColSel): Tabella
```

gt: `cols_hide()` · Great Tables: `GT.cols_hide()`

Example (spec table-parts):

```nim
let preview = tabellaPreview(planets(), topN = 2, bottomN = 1):
  colsHide ["mass", "diameter", "density", "gravity", "day_length", "distance", "orbital_period", "mean_temp"]
echo preview
```

```text
┌──────┬─────────┬─────────────┬───────┬───────┐
│      │ planet  │ type        │ moons │ rings │
╞══════╪═════════╪═════════════╪═══════╪═══════╡
│ 1    │ Mercury │ Terrestrial │     0 │ false │
│ 2    │ Venus   │ Terrestrial │     0 │ false │
│ 3..7 │         │             │       │       │
│ 8    │ Neptune │ Ice giant   │    16 │ true  │
└──────┴─────────┴─────────────┴───────┴───────┘
```

### colsUnhide (proc) · [#verbs-colsUnhide](https://pietroppeter.github.io/tabelline/api/#verbs-colsUnhide)

```nim
proc colsUnhide(t: sink Tabella; columns: ColSel): Tabella
```

gt: `cols_unhide()` · Great Tables: `GT.cols_unhide()`

Example (spec formatting):

```nim
let d = tableData:
  quantity: ["speed of sound", "gravity", "air density"]
  value: [343.0, 9.81, 1.204]
  units: ["m /s", "m s^-2", "kg m^-3"]
let quantities = tabella(d, rownameCol = "quantity"):
  fmtUnits "units"
  colsLabel:
    value: "at {{20 degC}}"
echo quantities
let gravity = tabella(planets(), rownameCol = "planet"):
  colsHide everything()
  colsUnhide ["density", "gravity"]
  colsUnits:
    density: "kg m^-3"
    gravity: "m s^-2"
    unitsPattern = "{1} ({2})"
echo gravity
```

```text
┌────────────────┬──────────┬────────┐
│                │ at 20 °C │ units  │
╞════════════════╪══════════╪════════╡
│ speed of sound │    343.0 │ m s⁻¹  │
│ gravity        │     9.81 │ m s⁻²  │
│ air density    │    1.204 │ kg m⁻³ │
└────────────────┴──────────┴────────┘
┌─────────┬──────────────────┬─────────────────┐
│         │ density (kg m⁻³) │ gravity (m s⁻²) │
╞═════════╪══════════════════╪═════════════════╡
│ Mercury │             5429 │             3.7 │
│ Venus   │             5243 │             8.9 │
│ Earth   │             5514 │             9.8 │
│ Mars    │             3934 │             3.7 │
│ Jupiter │             1326 │            23.1 │
│ Saturn  │              687 │             9.0 │
│ Uranus  │             1270 │             8.7 │
│ Neptune │             1638 │            11.0 │
└─────────┴──────────────────┴─────────────────┘
```

### colsMove (proc) · [#verbs-colsMove](https://pietroppeter.github.io/tabelline/api/#verbs-colsMove)

```nim
proc colsMove(t: sink Tabella; columns: ColSel; after: string): Tabella
```

Moves `columns` (in their given order) right after the column `after`.

gt: `cols_move()` · Great Tables: `GT.cols_move()`

### colsLabelWith (proc) · [#verbs-colsLabelWith](https://pietroppeter.github.io/tabelline/api/#verbs-colsLabelWith)

```nim
proc colsLabelWith(t: sink Tabella; columns: ColSel;
                   fn: proc (s: string): string): Tabella
proc colsLabelWith(t: sink Tabella; fn: proc (s: string): string): Tabella
```

Relabels columns with a proc over their labels: `colsLabelWith(everything(), capitalizeAscii)`.

gt: `cols_label_with()` · Great Tables: `GT.cols_label_with()`

Example (spec table-parts):

```nim
let t = tabella(tavolaPitagorica(2), rownameCol = "×"):
  colsLabelWith proc (s: string): string = "×" & s
echo t
```

```text
┌───┬────┬────┐
│   │ ×1 │ ×2 │
╞═══╪════╪════╡
│ 1 │  1 │  2 │
│ 2 │  2 │  4 │
└───┴────┴────┘
```

### colsMoveToEnd (proc) · [#verbs-colsMoveToEnd](https://pietroppeter.github.io/tabelline/api/#verbs-colsMoveToEnd)

```nim
proc colsMoveToEnd(t: sink Tabella; columns: ColSel): Tabella
```

gt: `cols_move_to_end()` · Great Tables: `GT.cols_move_to_end()`

Example (spec table-parts):

```nim
let d = tableData:
  a: [1]
  b: [2]
  c: [3]
  d: [4]
let t = tabella(d):
  colsMoveToEnd "a"
  colsReorder ["d", "b"]
echo t
```

```text
┌───┬───┬───┬───┐
│ d │ c │ b │ a │
╞═══╪═══╪═══╪═══╡
│ 4 │ 3 │ 2 │ 1 │
└───┴───┴───┴───┘
```

### colsReorder (proc) · [#verbs-colsReorder](https://pietroppeter.github.io/tabelline/api/#verbs-colsReorder)

```nim
proc colsReorder(t: sink Tabella; columns: ColSel): Tabella
```

Puts `columns` in the given order, in the places they hold: the other columns stay put.

Great Tables: `GT.cols_reorder()`

Example (spec table-parts):

```nim
let d = tableData:
  a: [1]
  b: [2]
  c: [3]
  d: [4]
let t = tabella(d):
  colsMoveToEnd "a"
  colsReorder ["d", "b"]
echo t
```

```text
┌───┬───┬───┬───┐
│ d │ c │ b │ a │
╞═══╪═══╪═══╪═══╡
│ 4 │ 3 │ 2 │ 1 │
└───┴───┴───┴───┘
```

### colsMoveToStart (proc) · [#verbs-colsMoveToStart](https://pietroppeter.github.io/tabelline/api/#verbs-colsMoveToStart)

```nim
proc colsMoveToStart(t: sink Tabella; columns: ColSel): Tabella
```

gt: `cols_move_to_start()` · Great Tables: `GT.cols_move_to_start()`

### rowOrder (proc) · [#verbs-rowOrder](https://pietroppeter.github.io/tabelline/api/#verbs-rowOrder)

```nim
proc rowOrder(t: sink Tabella; columns: ColSel; reverse = false): Tabella
```

Shows the rows sorted by `columns` (the first decides, the next break ties), within their
groups; `reverse` sorts from high to low. Missing values go last.

gt: `row_order()`

Example (spec table-parts):

```nim
let t = tabella(planets(), rownameCol = "planet", groupnameCol = "type"):
  colsHide ["mass", "diameter", "density", "gravity", "day_length", "distance", "orbital_period", "mean_temp", "rings"]
  rowOrder "moons", reverse = true
  rowGroupOrder ["Ice giant", "Gas giant"]
echo t
```

```text
┌─────────┬───────┐
│         │ moons │
╞═════════╪═══════╡
│ Ice giant       │
├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤
│ Uranus  │    28 │
│ Neptune │    16 │
├─────────┼───────┤
│ Gas giant       │
├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤
│ Saturn  │   146 │
│ Jupiter │    95 │
├─────────┼───────┤
│ Terrestrial     │
├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤
│ Mars    │     2 │
│ Earth   │     1 │
│ Mercury │     0 │
│ Venus   │     0 │
└─────────┴───────┘
```

### rowGroupOrder (proc) · [#verbs-rowGroupOrder](https://pietroppeter.github.io/tabelline/api/#verbs-rowGroupOrder)

```nim
proc rowGroupOrder(t: sink Tabella; groups: openArray[string]): Tabella
```

Shows the row groups in this order; groups not listed follow, as they were.

gt: `row_group_order()`

Example (spec table-parts):

```nim
let t = tabella(planets(), rownameCol = "planet", groupnameCol = "type"):
  colsHide ["mass", "diameter", "density", "gravity", "day_length", "distance", "orbital_period", "mean_temp", "rings"]
  rowOrder "moons", reverse = true
  rowGroupOrder ["Ice giant", "Gas giant"]
echo t
```

```text
┌─────────┬───────┐
│         │ moons │
╞═════════╪═══════╡
│ Ice giant       │
├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤
│ Uranus  │    28 │
│ Neptune │    16 │
├─────────┼───────┤
│ Gas giant       │
├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤
│ Saturn  │   146 │
│ Jupiter │    95 │
├─────────┼───────┤
│ Terrestrial     │
├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤
│ Mars    │     2 │
│ Earth   │     1 │
│ Mercury │     0 │
│ Venus   │     0 │
└─────────┴───────┘
```

### agg (const) · [#verbs-agg](https://pietroppeter.github.io/tabelline/api/#verbs-agg)

```nim
agg = ()
```

### sum (func) · [#verbs-sum](https://pietroppeter.github.io/tabelline/api/#verbs-sum)

```nim
func sum(_: AggNs): Aggregate
```

The sum of the numbers (an int when they are all ints).

### mean (func) · [#verbs-mean](https://pietroppeter.github.io/tabelline/api/#verbs-mean)

```nim
func mean(_: AggNs): Aggregate
```

The mean of the numbers.

Example (spec formatting):

```nim
let d = tableData:
  city: ["Oslo", "Rome"]
  trend: ["1 4 2 8 5", "3, NA, 6, 2"]
  change: [4.2, -1.5]
let t = tabella(d, rownameCol = "city"):
  fmtNanoplot "trend", referenceLine = "mean"
  fmtNanoplot "change", plotType = "bar"
echo t
echo t.toHtml.count("class=\"tb_nanoplot\""), " ", nanoplotLabel(1234), " ", nanoplotLabel(0.25)
```

```text
┌──────┬───────────┬───────────────────┐
│      │ trend     │            change │
╞══════╪═══════════╪═══════════════════╡
│ Oslo │ ▁▄▂█▅ 1–8 │    │███████ 4.20  │
│ Rome │ ▃ █▁ 2–6  │ ███│        −1.50 │
└──────┴───────────┴───────────────────┘
4 1.23K 0.25
```

### median (func) · [#verbs-median](https://pietroppeter.github.io/tabelline/api/#verbs-median)

```nim
func median(_: AggNs): Aggregate
```

The median of the numbers (the mean of the two middle ones when they are even).

### std (func) · [#verbs-std](https://pietroppeter.github.io/tabelline/api/#verbs-std)

```nim
func std(_: AggNs): Aggregate
```

The standard deviation of the numbers, of a sample (divided by n - 1, as R's `sd` and
Polars' `std`).

### min (func) · [#verbs-min](https://pietroppeter.github.io/tabelline/api/#verbs-min)

```nim
func min(_: AggNs): Aggregate
```

The smallest value (of numbers, or of texts).

### max (func) · [#verbs-max](https://pietroppeter.github.io/tabelline/api/#verbs-max)

```nim
func max(_: AggNs): Aggregate
```

The largest value (of numbers, or of texts).

### count (func) · [#verbs-count](https://pietroppeter.github.io/tabelline/api/#verbs-count)

```nim
func count(_: AggNs): Aggregate
```

How many values are not missing. Shown as an integer, whatever the column's format.

Example (spec formatting):

```nim
let d = tableData:
  item: ["a", "b", "c"]
  count: [3, 2500000, 12]
  ratio: [0.5, 0.0000123, 1.25]
  price_eur: [3.5, 10.0, 99.99]
let t = tabella(d):
  fmtAuto()
  fmtPassthrough "item", pattern = "item {x}"
echo t
```

```text
┌────────┬───────────┬─────────────┬───────────┐
│ item   │     count │       ratio │ price_eur │
╞════════╪═══════════╪═════════════╪═══════════╡
│ item a │         3 │         0.5 │     €3.50 │
│ item b │ 2.5 × 10⁶ │ 1.23 × 10⁻⁵ │    €10.00 │
│ item c │        12 │        1.25 │    €99.99 │
└────────┴───────────┴─────────────┴───────────┘
```

### aggregate (proc) · [#verbs-aggregate](https://pietroppeter.github.io/tabelline/api/#verbs-aggregate)

```nim
proc aggregate[P: proc](fn: P; name = ""): Aggregate
```

An aggregate of your own, from a proc of the non-missing values to one value:
`aggregate(proc (vs: seq[Value]): Value = toValue(vs.len * 2))`, or a value that converts to
one (`proc (vs: seq[Value]): float`).

Example (spec table-parts):

```nim
let middle = aggregate(proc (vs: seq[Value]): Value = vs[vs.len div 2])
let t = tabella(planets(), rownameCol = "planet"):
  colsHide ["type", "mass", "density", "gravity", "day_length", "distance", "orbital_period", "mean_temp", "rings"]
  fmtInteger "diameter"
  grandSummaryRows:
    planets: agg.count
    largest: agg.max
    "middle one": middle
  grandSummaryRows:
    mean: agg.mean
    fmt = (x: float) => formatNumber(x, decimals = 1)
echo t
```

```text
┌────────────┬──────────┬───────┐
│            │ diameter │ moons │
╞════════════╪══════════╪═══════╡
│ Mercury    │    4,879 │     0 │
│ Venus      │   12,104 │     0 │
│ Earth      │   12,756 │     1 │
│ Mars       │    6,792 │     2 │
│ Jupiter    │  142,984 │    95 │
│ Saturn     │  120,536 │   146 │
│ Uranus     │   51,118 │    28 │
│ Neptune    │   49,528 │    16 │
╞════════════╪══════════╪═══════╡
│ planets    │        8 │     8 │
│ largest    │  142,984 │   146 │
│ middle one │  142,984 │    95 │
│ mean       │ 50,087.1 │  36.0 │
└────────────┴──────────┴───────┘
```

### toFormatFn (proc) · [#verbs-toFormatFn](https://pietroppeter.github.io/tabelline/api/#verbs-toFormatFn)

```nim
proc toFormatFn[P: proc](fn: P): FormatFn
```

A format from a proc of a float (`(x: float) => formatNumber(x, 1)`), of a value
(`(v: Value) => $v`), both giving plain text, or a `FormatFn` as it is.

### summaryRows (proc) · [#verbs-summaryRows](https://pietroppeter.github.io/tabelline/api/#verbs-summaryRows)

```nim
proc summaryRows(t: sink Tabella; fns: openArray[(string, Aggregate)];
                 groups: openArray[string] = []; columns: ColSel = numeric();
                 side = sBottom; missingText = "—"): Tabella
proc summaryRows[P: proc](t: sink Tabella; fns: openArray[(string, Aggregate)];
                          fmt: P; groups: openArray[string] = [];
                          columns: ColSel = numeric(); side = sBottom;
                          missingText = "—"): Tabella
```

Adds rows that sum up each row group (or the `groups` listed), one for each aggregate in
`fns`, labelled in the stub: `summaryRows(fns = {"total": agg.sum}, columns = "moons")`.
Inside `tabella(data): body`, also as a block, one pair per line (see `tabella`):
`summaryRows:` then `total: agg.sum`, `columns = "moons"` and `fmtNumber(decimals = 1)`
(a `fmt*` line is `fmt`).
The summary rows go under the group, or above it with `side = sTop`. Each cell is
formatted like its column (its last format), `agg.count` as an integer; a cell with
nothing to sum up, and the columns not in `columns`, show `missingText`.

gt: `summary_rows()` · Great Tables: `GT.summary_rows()`

Example (spec table-parts):

```nim
let t = tabella(planets(), rownameCol = "planet", groupnameCol = "type"):
  colsHide ["mass", "diameter", "density", "gravity", "day_length", "distance", "orbital_period", "mean_temp", "rings"]
  summaryRows:
    total: agg.sum
echo t
```

```text
┌─────────┬───────┐
│         │ moons │
╞═════════╪═══════╡
│ Terrestrial     │
├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤
│ Mercury │     0 │
│ Venus   │     0 │
│ Earth   │     1 │
│ Mars    │     2 │
├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤
│ total   │     3 │
├─────────┼───────┤
│ Gas giant       │
├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤
│ Jupiter │    95 │
│ Saturn  │   146 │
├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤
│ total   │   241 │
├─────────┼───────┤
│ Ice giant       │
├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤
│ Uranus  │    28 │
│ Neptune │    16 │
├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤
│ total   │    44 │
└─────────┴───────┘
```

### grandSummaryRows (proc) · [#verbs-grandSummaryRows](https://pietroppeter.github.io/tabelline/api/#verbs-grandSummaryRows)

```nim
proc grandSummaryRows(t: sink Tabella; fns: openArray[(string, Aggregate)];
                      columns: ColSel = numeric(); side = sBottom;
                      missingText = "—"): Tabella
proc grandSummaryRows[P: proc](t: sink Tabella;
                               fns: openArray[(string, Aggregate)]; fmt: P;
                               columns: ColSel = numeric(); side = sBottom;
                               missingText = "—"): Tabella
```

Adds rows that sum up the whole table, every row of every group, one for each aggregate in
`fns`: at the bottom of the table, or at the top with `side = sTop`. Formatted as
`summaryRows`; a block as in `summaryRows`: `grandSummaryRows:` then `mean: agg.mean`.

gt: `grand_summary_rows()` · Great Tables: `GT.grand_summary_rows()`

Example (spec table-parts):

```nim
let medals = tableData:
  country: ["Norway", "Germany", "Italy"]
  gold: [16, 12, 7]
  silver: [8, 10, 8]
  bronze: [13, 5, 9]
let t = tabella(medals, rownameCol = "country"):
  summaryColumns:
    total: agg.sum
  grandSummaryRows:
    all: agg.sum
echo t
```

```text
┌─────────┬──────┬────────┬────────┬───────┐
│         │ gold │ silver │ bronze │ total │
╞═════════╪══════╪════════╪════════╪═══════╡
│ Norway  │   16 │      8 │     13 │    37 │
│ Germany │   12 │     10 │      5 │    27 │
│ Italy   │    7 │      8 │      9 │    24 │
╞═════════╪══════╪════════╪════════╪═══════╡
│ all     │   35 │     26 │     27 │    88 │
└─────────┴──────┴────────┴────────┴───────┘
```

### dataColor (proc) · [#verbs-dataColor](https://pietroppeter.github.io/tabelline/api/#verbs-dataColor)

```nim
proc dataColor(t: sink Tabella; columns: ColSel = numeric(); rows = allRows();
               palette: seq[string] = palette("blues");
               domain = (0x7FF7FFFFFFFFFFFF'f64, 0x7FF7FFFFFFFFFFFF'f64);
               reverse = false; naColor = "#F0F0F0"; autoColorText = true;
               apply = "fill"): Tabella
```

Colours cells by value, each column on its own: a number column along `palette` from the low
to the high end of `domain` (by default the range of its selected cells), any other column by
category. A `domain` from high to low runs the palette the other way. `apply = "text"`
colours the text instead of the fill. The stub is left out, as in Great Tables;
`palette("great-tables")` is Great Tables' default palette.

gt: `data_color()` · Great Tables: `GT.data_color()`

### tabOptions (macro) · [#verbs-tabOptions](https://pietroppeter.github.io/tabelline/api/#verbs-tabOptions)

```nim
macro tabOptions(t: Tabella; args: varargs[untyped]): Tabella
```

Sets any of `TabOptions`' fields by name, checked when compiling:
`t.tabOptions(rowStriping = true, headingAlign = "left")`.

gt: `tab_options()` · Great Tables: `GT.tab_options()`

Example (spec nim-sugar):

```nim
let t = tabella(planets(), rownameCol = "planet"):
  colsHide ["type", "density", "gravity", "day_length", "distance", "orbital_period", "mean_temp", "rings", "moons"]
  colsLabel:
    mass: "mass, {{10^24 kg}}"
    diameter: "diameter, {{km}}"
  grandSummaryRows:
    mean: agg.mean
    "largest one": agg.max
    fmtNumber(decimals = 0)
  tabOptions:
    rowStriping = true
echo t
echo t.options.rowStriping
```

```text
┌─────────────┬───────────────┬──────────────┐
│             │ mass, 10²⁴ kg │ diameter, km │
╞═════════════╪═══════════════╪══════════════╡
│ Mercury     │          0.33 │         4879 │
│ Venus       │          4.87 │        12104 │
│ Earth       │          5.97 │        12756 │
│ Mars        │         0.642 │         6792 │
│ Jupiter     │        1898.0 │       142984 │
│ Saturn      │         568.0 │       120536 │
│ Uranus      │          86.8 │        51118 │
│ Neptune     │         102.0 │        49528 │
╞═════════════╪═══════════════╪══════════════╡
│ mean        │           333 │       50,087 │
│ largest one │         1,898 │      142,984 │
└─────────────┴───────────────┴──────────────┘
true
```

### optRowStriping (proc) · [#verbs-optRowStriping](https://pietroppeter.github.io/tabelline/api/#verbs-optRowStriping)

```nim
proc optRowStriping(t: sink Tabella; on = true): Tabella
```

gt: `opt_row_striping()` · Great Tables: `GT.opt_row_striping()`

### optAlignTableHeader (proc) · [#verbs-optAlignTableHeader](https://pietroppeter.github.io/tabelline/api/#verbs-optAlignTableHeader)

```nim
proc optAlignTableHeader(t: sink Tabella; align = "left"): Tabella
```

gt: `opt_align_table_header()` · Great Tables: `GT.opt_align_table_header()`

### optAllCaps (proc) · [#verbs-optAllCaps](https://pietroppeter.github.io/tabelline/api/#verbs-optAllCaps)

```nim
proc optAllCaps(t: sink Tabella; on = true; locations: openArray[string] = [
    "column_labels", "stub", "row_group"]): Tabella
```

Small capitals (upper case, smaller and bolder) in the column labels, the stub and the row
group labels, or only in the `locations` named, as gt's `opt_all_caps(locations = ...)`.

gt: `opt_all_caps()` · Great Tables: `GT.opt_all_caps()`

### optTableFont (proc) · [#verbs-optTableFont](https://pietroppeter.github.io/tabelline/api/#verbs-optTableFont)

```nim
proc optTableFont(t: sink Tabella; font: string): Tabella
```

The table's font, as a CSS font stack: `optTableFont(systemFonts("humanist"))`.

gt: `opt_table_font()` · Great Tables: `GT.opt_table_font()`

### fontStackNames (const) · [#verbs-fontStackNames](https://pietroppeter.github.io/tabelline/api/#verbs-fontStackNames)

```nim
fontStackNames = ["system-ui", "transitional", "old-style", "humanist",
                  "geometric-humanist", "classical-humanist", "neo-grotesque",
                  "monospace-slab-serif", "monospace-code", "industrial",
                  "rounded-sans", "slab-serif", "antique", "didone",
                  "handwritten"]
```

The names `systemFonts` knows, in Great Tables' order.

### systemFonts (func) · [#verbs-systemFonts](https://pietroppeter.github.io/tabelline/api/#verbs-systemFonts)

```nim
func systemFonts(name = "system-ui"): string
```

One of Great Tables' fifteen font stacks, fonts that are on most systems, as CSS text:
`systemFonts("old-style")` is "'Iowan Old Style', 'Palatino Linotype', ..., serif". The
names are in `fontStackNames`; another name raises `ValueError`.

gt: `system_fonts()` · Great Tables: `system_fonts()`

### defaultFonts (func) · [#verbs-defaultFonts](https://pietroppeter.github.io/tabelline/api/#verbs-defaultFonts)

```nim
func defaultFonts(): string
```

gt's default font stack, as CSS text (tabelline's default, `tableFontNames`, is close to it).

gt: `default_fonts()`

### CssTheme (type) · [#verbs-CssTheme](https://pietroppeter.github.io/tabelline/api/#verbs-CssTheme)

```nim
CssTheme = object
  ink*, paper*, line*, shade*, primary*, font*: string
```

Where a table takes its colours and font from (`optCssTheme`): for each, the name of a CSS
variable of the page (`"--ink"`) or a CSS value (`"#1C1C1C"`).

### cssTheme (func) · [#verbs-cssTheme](https://pietroppeter.github.io/tabelline/api/#verbs-cssTheme)

```nim
func cssTheme(ink = "--ink"; paper = "--paper"; line = "--line";
              shade = "--shade"; primary = "--primary"; font = "--font"): CssTheme
```

A theme to keep and reuse with `optCssTheme(theme)`. Each argument starting with `--` names
the variable to read; anything else is the CSS value itself.

### optCssTheme (proc) · [#verbs-optCssTheme](https://pietroppeter.github.io/tabelline/api/#verbs-optCssTheme)

```nim
proc optCssTheme(t: sink Tabella; theme: CssTheme): Tabella
proc optCssTheme(t: sink Tabella; ink = "--ink"; paper = "--paper";
                 line = "--line"; shade = "--shade"; primary = "--primary";
                 font = "--font"): Tabella
```

Every colour of the table, and its font, from `theme`: see `optCssTheme()`.

### optVerticalPadding (proc) · [#verbs-optVerticalPadding](https://pietroppeter.github.io/tabelline/api/#verbs-optVerticalPadding)

```nim
proc optVerticalPadding(t: sink Tabella; scale = 1.0): Tabella
```

Scales the vertical padding of the heading, the column labels and the rows (gt: 0 to 3).

gt: `opt_vertical_padding()` · Great Tables: `GT.opt_vertical_padding()`

### optHorizontalPadding (proc) · [#verbs-optHorizontalPadding](https://pietroppeter.github.io/tabelline/api/#verbs-optHorizontalPadding)

```nim
proc optHorizontalPadding(t: sink Tabella; scale = 1.0): Tabella
```

Scales the horizontal padding of the heading, the column labels and the rows (gt: 0 to 3).

gt: `opt_horizontal_padding()` · Great Tables: `GT.opt_horizontal_padding()`

### optTableOutline (proc) · [#verbs-optTableOutline](https://pietroppeter.github.io/tabelline/api/#verbs-optTableOutline)

```nim
proc optTableOutline(t: sink Tabella; style = "solid"; width = "3px";
                     color = "#D3D3D3"): Tabella
```

A line all around the table.

gt: `opt_table_outline()` · Great Tables: `GT.opt_table_outline()`

### optStylize (proc) · [#verbs-optStylize](https://pietroppeter.github.io/tabelline/api/#verbs-optStylize)

```nim
proc optStylize(t: sink Tabella; style = 1; color = "blue";
                addRowStriping = true): Tabella
```

A ready-made look, gt's and Great Tables' `opt_stylize()`: `style` 1 to 6, in one of `color`
"blue", "cyan", "pink", "green", "red", "gray", with stripes unless `addRowStriping = false`.
Styles 2, 4 and 5 draw a light outline around the table; a dark stub gets white text.

gt: `opt_stylize()` · Great Tables: `GT.opt_stylize()`

### optTableLines (proc) · [#verbs-optTableLines](https://pietroppeter.github.io/tabelline/api/#verbs-optTableLines)

```nim
proc optTableLines(t: sink Tabella; extent = "default"): Tabella
```

The table's lines: `"all"` adds vertical lines between cells, `"none"` takes every line away,
`"default"` brings back the defaults.

gt: `opt_table_lines()`

### optFootnoteMarks (proc) · [#verbs-optFootnoteMarks](https://pietroppeter.github.io/tabelline/api/#verbs-optFootnoteMarks)

```nim
proc optFootnoteMarks(t: sink Tabella; marks: FootnoteMarks): Tabella
proc optFootnoteMarks(t: sink Tabella; marks: string): Tabella
proc optFootnoteMarks(t: sink Tabella; marks: openArray[string]): Tabella
```

By gt's names: "numbers", "letters", "LETTERS", "standard" (*, †, ‡, §) or "extended"
(with ‖, ¶).

gt: `opt_footnote_marks()` · Great Tables: `GT.opt_footnote_marks()`

Example (spec styling):

```nim
let t = tabella(tavolaPitagorica(2), rownameCol = "×"):
  tabFootnote "A note with no mark."
  tabFootnote "Two twos.", loc.body(cols = "2", rows = [1])
  tabFootnote "The first row.", loc.stub(rows = [0])
  optFootnoteMarks "standard"
  optFootnoteSpec "^", "("
  optFootnoteOrder "marks_last"
echo t
```

```text
┌─────┬───┬─────┐
│     │ 1 │   2 │
╞═════╪═══╪═════╡
│ 1^* │ 1 │   2 │
│ 2   │ 2 │ 4^† │
└─────┴───┴─────┘
A note with no mark.
(*) The first row.
(†) Two twos.
```

### optFootnoteSpec (proc) · [#verbs-optFootnoteSpec](https://pietroppeter.github.io/tabelline/api/#verbs-optFootnoteSpec)

```nim
proc optFootnoteSpec(t: sink Tabella; specRef = "^"; specFtr = "^"): Tabella
```

How marks look, in the table (`specRef`) and in the footer (`specFtr`): "^" raised, "i"
italic, "b" bold, "(" or "[" around the mark: `optFootnoteSpec("^i", "(")`.

gt: `opt_footnote_spec()`

Example (spec styling):

```nim
let t = tabella(tavolaPitagorica(2), rownameCol = "×"):
  tabFootnote "A note with no mark."
  tabFootnote "Two twos.", loc.body(cols = "2", rows = [1])
  tabFootnote "The first row.", loc.stub(rows = [0])
  optFootnoteMarks "standard"
  optFootnoteSpec "^", "("
  optFootnoteOrder "marks_last"
echo t
```

```text
┌─────┬───┬─────┐
│     │ 1 │   2 │
╞═════╪═══╪═════╡
│ 1^* │ 1 │   2 │
│ 2   │ 2 │ 4^† │
└─────┴───┴─────┘
A note with no mark.
(*) The first row.
(†) Two twos.
```

### optFootnoteOrder (proc) · [#verbs-optFootnoteOrder](https://pietroppeter.github.io/tabelline/api/#verbs-optFootnoteOrder)

```nim
proc optFootnoteOrder(t: sink Tabella; order = "marks_first"): Tabella
```

The order of the footnotes: marked ones first (the default), last ("marks_last"), or as
they were added ("preserve_order", which also numbers the marks in that order).

gt: `opt_footnote_order()`

Example (spec styling):

```nim
let t = tabella(tavolaPitagorica(2), rownameCol = "×"):
  tabFootnote "A note with no mark."
  tabFootnote "Two twos.", loc.body(cols = "2", rows = [1])
  tabFootnote "The first row.", loc.stub(rows = [0])
  optFootnoteMarks "standard"
  optFootnoteSpec "^", "("
  optFootnoteOrder "marks_last"
echo t
```

```text
┌─────┬───┬─────┐
│     │ 1 │   2 │
╞═════╪═══╪═════╡
│ 1^* │ 1 │   2 │
│ 2   │ 2 │ 4^† │
└─────┴───┴─────┘
A note with no mark.
(*) The first row.
(†) Two twos.
```

### optCss (proc) · [#verbs-optCss](https://pietroppeter.github.io/tabelline/api/#verbs-optCss)

```nim
proc optCss(t: sink Tabella; css: string; add = true): Tabella
```

CSS for the table, scoped to it (rules that start with `#` are left as they are); `add = false`
replaces what was given before.

gt: `opt_css()` · Great Tables: `GT.opt_css()`

### colsMerge (proc) · [#verbs-colsMerge](https://pietroppeter.github.io/tabelline/api/#verbs-colsMerge)

```nim
proc colsMerge(t: sink Tabella; columns: openArray[string]; rows = allRows();
               pattern = ""; autohide = true): Tabella
```

Shows the formatted values of `columns` together, in the first one, with `pattern`:
`{1}`, `{2}`, ... are the columns, and a part between `<<` and `>>` is left out when a value
it names is missing: `colsMerge(["city", "country"], pattern = "{1}<< ({2})>>")`. Without a
pattern the values are joined by spaces. The other columns are hidden (unless `autohide =
false`). A pattern reads the fields of a record too: `{2.lo}` is the field `lo` of column
2, and `{lo}` of column 1, formatted as its column is, so a single column of records can be
shown in a pattern: `colsMerge(["span"], pattern = "{lo}–{hi}")`.

gt: `cols_merge()` · Great Tables: `GT.cols_merge()`

Example (spec table-parts):

```nim
let d = tableData:
  sensor: ["north", "south"]
  span: [(lo: 0.82, hi: 1.56), (lo: 9.13, hi: 12.71)]
  unit: ["mm", "cm"]
let t = tabella(d, rownameCol = "sensor"):
  fmtNumber "span", decimals = 1
  colsMerge ["span", "unit"], pattern = "{lo}–{hi}<< {2}>>"
echo t
```

```text
┌───────┬─────────────┐
│       │ span        │
╞═══════╪═════════════╡
│ north │ 0.8–1.6 mm  │
│ south │ 9.1–12.7 cm │
└───────┴─────────────┘
```

### colsMergeUncert (proc) · [#verbs-colsMergeUncert](https://pietroppeter.github.io/tabelline/api/#verbs-colsMergeUncert)

```nim
proc colsMergeUncert(t: sink Tabella; colVal, colUncert: string;
                     rows = allRows(); sep = " ± "; autohide = true): Tabella
```

A value and its uncertainty in one cell: `12.3 ± 0.4` (just the value when the uncertainty
is missing).

gt: `cols_merge_uncert()` · Great Tables: `GT.cols_merge_uncert()`

### colsMergeRange (proc) · [#verbs-colsMergeRange](https://pietroppeter.github.io/tabelline/api/#verbs-colsMergeRange)

```nim
proc colsMergeRange(t: sink Tabella; colBegin, colEnd: string; rows = allRows();
                    sep = "–"; autohide = true): Tabella
```

A range in one cell, with an en dash: `1990–2000` (just the start when the end is missing).

gt: `cols_merge_range()` · Great Tables: `GT.cols_merge_range()`

Example (spec table-parts):

```nim
let d = tableData:
  mission: ["Voyager 1", "Galileo", "Cassini"]
  launch: [1977, 1989, 1997]
  ended: [nil, 2003, 2017]
  target: ["Jupiter, Saturn", "Jupiter", "Saturn"]
  moon: [nil, "Io", "Titan"]
let t = tabella(d, rownameCol = "mission"):
  colsMergeRange "launch", "ended"
  colsMerge ["target", "moon"], pattern = "{1}<< and {2}>>"
echo t
```

```text
┌───────────┬───────────┬──────────────────┐
│           │    launch │ target           │
╞═══════════╪═══════════╪══════════════════╡
│ Voyager 1 │      1977 │ Jupiter, Saturn  │
│ Galileo   │ 1989–2003 │ Jupiter and Io   │
│ Cassini   │ 1997–2017 │ Saturn and Titan │
└───────────┴───────────┴──────────────────┘
```

### colsMergeNPct (proc) · [#verbs-colsMergeNPct](https://pietroppeter.github.io/tabelline/api/#verbs-colsMergeNPct)

```nim
proc colsMergeNPct(t: sink Tabella; colN, colPct: string; rows = allRows();
                   autohide = true): Tabella
```

A count and its percentage in one cell: `12 (4.5%)`; a zero count shows no percentage.
Format the percentage column first (`fmtPercent`).

gt: `cols_merge_n_pct()` · Great Tables: `GT.cols_merge_n_pct()`

### colsAdd (proc) · [#verbs-colsAdd](https://pietroppeter.github.io/tabelline/api/#verbs-colsAdd)

```nim
proc colsAdd(t: sink Tabella; name: string; values: seq[Value]; before = "";
             after = ""): Tabella
proc colsAdd[T](t: sink Tabella; name: string; values: openArray[T];
                before = ""; after = ""): Tabella
proc colsAdd(t: sink Tabella; name: string; fn: proc (r: Row): Value;
             before = ""; after = ""): Tabella
```

Adds a column: at the end, or `before` or `after` another one. `colsAdd("ratio", ratios)`.

gt: `cols_add()`

Example (spec formatting):

```nim
let d = tableData:
  codes: ["IT", "jpn", "FR, DE", "XX"]
let t = tabella(d):
  colsAdd "names", d["codes"].values
  fmtCountry "names"
echo t
```

```text
┌────────┬─────────────────┐
│ codes  │ names           │
╞════════╪═════════════════╡
│ IT     │ Italy           │
│ jpn    │ Japan           │
│ FR, DE │ France, Germany │
│ XX     │ XX              │
└────────┴─────────────────┘
```

### summaryColumns (proc) · [#verbs-summaryColumns](https://pietroppeter.github.io/tabelline/api/#verbs-summaryColumns)

```nim
proc summaryColumns(t: sink Tabella; fns: openArray[(string, Aggregate)];
                    columns: ColSel = numeric(); side = sRight;
                    missingText = "—"): Tabella
proc summaryColumns[P: proc](t: sink Tabella;
                             fns: openArray[(string, Aggregate)]; fmt: P;
                             columns: ColSel = numeric(); side = sRight;
                             missingText = "—"): Tabella
```

Adds a column for each aggregate in `fns`, summing up `columns` across each row:
`summaryColumns(fns = {"total": agg.sum}, columns = ["gold", "silver", "bronze"])`, or as
a block (`summaryColumns:` then `total: agg.sum`, see `tabella`), at the
right of the table (or at the left of the data with `side = sLeft`). The new column is
formatted like the first column it sums up, or by `fmt`; summary rows sum it up like any
other column, so a table of totals gets its grand total.

gt: `summary_columns()`

Example (spec table-parts):

```nim
let medals = tableData:
  country: ["Norway", "Germany", "Italy"]
  gold: [16, 12, 7]
  silver: [8, 10, 8]
  bronze: [13, 5, 9]
let t = tabella(medals, rownameCol = "country"):
  summaryColumns:
    total: agg.sum
  grandSummaryRows:
    all: agg.sum
echo t
```

```text
┌─────────┬──────┬────────┬────────┬───────┐
│         │ gold │ silver │ bronze │ total │
╞═════════╪══════╪════════╪════════╪═══════╡
│ Norway  │   16 │      8 │     13 │    37 │
│ Germany │   12 │     10 │      5 │    27 │
│ Italy   │    7 │      8 │      9 │    24 │
╞═════════╪══════╪════════╪════════╪═══════╡
│ all     │   35 │     26 │     27 │    88 │
└─────────┴──────┴────────┴────────┴───────┘
```

### rowsAdd (proc) · [#verbs-rowsAdd](https://pietroppeter.github.io/tabelline/api/#verbs-rowsAdd)

```nim
proc rowsAdd(t: sink Tabella; rows: TableData; before = -1; after = -1): Tabella
proc rowsAdd[T: object | tuple](t: sink Tabella; rows: openArray[T];
                                before = -1; after = -1): Tabella
```

Adds rows, given as a table of some of the columns (the others are missing): at the end, or
`before` or `after` a row (by its index in the data). A value of `groupnameCol` puts the row
in that group (made when new). `rowsAdd(tableData(planet = ["Pluto"], moons = [5]))`.

gt: `rows_add()`

Example (spec table-parts):

```nim
let t = tabella(planets(), rownameCol = "planet", groupnameCol = "type"):
  colsHide ["mass", "diameter", "density", "gravity", "day_length", "distance", "orbital_period", "mean_temp", "rings"]
  rowsHide where(it["type"] != "Ice giant")
  rowsAdd [(planet: "Pluto", `type`: "Dwarf planet", moons: 5)]
echo t
```

```text
┌─────────┬───────┐
│         │ moons │
╞═════════╪═══════╡
│ Ice giant       │
├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤
│ Uranus  │    28 │
│ Neptune │    16 │
├─────────┼───────┤
│ Dwarf planet    │
├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤
│ Pluto   │     5 │
└─────────┴───────┘
```

### rowsHide (proc) · [#verbs-rowsHide](https://pietroppeter.github.io/tabelline/api/#verbs-rowsHide)

```nim
proc rowsHide(t: sink Tabella; rows: RowSel): Tabella
```

Hides rows: they are not shown, nor summed up by summary rows, but stay in the data.

gt: `rows_hide()`

Example (spec nim-sugar):

```nim
let t = tabella(planets(), rownameCol = "planet"):
  colsHide ["type", "density", "gravity", "day_length", "distance", "orbital_period", "mean_temp", "rings", "diameter"]
  rowsHide where(it.moons < 10)
echo t
```

```text
┌─────────┬────────┬───────┐
│         │   mass │ moons │
╞═════════╪════════╪═══════╡
│ Jupiter │ 1898.0 │    95 │
│ Saturn  │  568.0 │   146 │
│ Uranus  │   86.8 │    28 │
│ Neptune │  102.0 │    16 │
└─────────┴────────┴───────┘
```

### rowsUnhide (proc) · [#verbs-rowsUnhide](https://pietroppeter.github.io/tabelline/api/#verbs-rowsUnhide)

```nim
proc rowsUnhide(t: sink Tabella; rows = allRows()): Tabella
```

Shows hidden rows again (all of them, by default).

gt: `rows_unhide()`

### tabStubIndent (proc) · [#verbs-tabStubIndent](https://pietroppeter.github.io/tabelline/api/#verbs-tabStubIndent)

```nim
proc tabStubIndent(t: sink Tabella; rows: RowSel; indent: int): Tabella
proc tabStubIndent(t: sink Tabella; rows: RowSel; indent = "increase"): Tabella
```

Indents the stub cells of `rows` at a level from 0 (none) to 5.

gt: `tab_stub_indent()`

Example (spec table-parts):

```nim
let budget = tableData:
  item: ["Hardware", "Laptops", "Screens", "Travel"]
  eur: [5200, 4000, 1200, 900]
let t = tabella(budget, rownameCol = "item"):
  tabStubIndent [1, 2], "increase"
  fmtInteger "eur"
echo t
```

```text
┌───────────┬───────┐
│           │   eur │
╞═══════════╪═══════╡
│ Hardware  │ 5,200 │
│   Laptops │ 4,000 │
│   Screens │ 1,200 │
│ Travel    │   900 │
└───────────┴───────┘
```

### colsAlignDecimal (proc) · [#verbs-colsAlignDecimal](https://pietroppeter.github.io/tabelline/api/#verbs-colsAlignDecimal)

```nim
proc colsAlignDecimal(t: sink Tabella; columns: ColSel = numeric();
                      decMark = ""; locale = ""): Tabella
```

Aligns the numbers of `columns` on their decimal mark, by padding each formatted cell on the
right with figure spaces (a number without decimals gets a space for the mark, too). The
columns are aligned right. The mark is `decMark`, or the locale's (`"."` by default).

gt: `cols_align_decimal()` · Great Tables: `GT.cols_align_decimal()`

### colsLabelRotate (proc) · [#verbs-colsLabelRotate](https://pietroppeter.github.io/tabelline/api/#verbs-colsLabelRotate)

```nim
proc colsLabelRotate(t: sink Tabella; columns: ColSel = everything();
                     dir = "sideways-lr"): Tabella
```

Turns the labels of `columns` on their side, for narrow columns: read from the bottom up
(`"sideways-lr"`) or from the top down (`"sideways-rl"`), or slanted at 45 degrees
(`"slanted"`, not from gt: a longer label, such as a month's name, in a narrow column). HTML only: text and Markdown keep
the labels as they are.

Great Tables: `GT.cols_label_rotate()`

### fromColumn (func) · [#verbs-fromColumn](https://pietroppeter.github.io/tabelline/api/#verbs-fromColumn)

```nim
func fromColumn(column: string; naValue = ""): string
```

A style value taken, for each cell, from `column` of the same row:
`tabStyle(style.fill(fromColumn("colour")), loc.body("name"))`. A missing value is
`naValue` ("" leaves that property out). Works in any style for body and stub cells.

gt: `from_column()` · Great Tables: `from_column()`

### tabStyleBody (proc) · [#verbs-tabStyleBody](https://pietroppeter.github.io/tabelline/api/#verbs-tabStyleBody)

```nim
proc tabStyleBody(t: sink Tabella; style: CellStyle;
                  columns: ColSel = everything(); rows = allRows();
                  values: openArray[string] = []; pattern = "";
                  fn: proc (v: Value): bool = nil; targets = "cell"): Tabella
```

Styles the body cells whose value is one of `values` (compared as text, or as numbers),
contains `pattern`, or makes `fn` true; `targets = "row"` styles their whole row, `"column"`
their whole column: `tabStyleBody(style.fill("var(--x-soft)"), values = ["Earth"])`.

gt: `tab_style_body()`

### initTabellaPreview (proc) · [#verbs-initTabellaPreview](https://pietroppeter.github.io/tabelline/api/#verbs-initTabellaPreview)

```nim
proc initTabellaPreview(data: TableData; topN = 5; bottomN = 1;
                        inclRownums = true;
                        moreRows: RowSel = toRowSel(newSeq(Natural(0)))): Tabella
```

A preview of a big table: its first `topN` rows, its last `bottomN` rows and the rows of
`moreRows` (not from gt: indices from 0, a range, a set such as `{12, 40..42}`, or
`where(...)`), in their order, with a shaded row for each run of rows left out ("6..99"), and
the rows numbered from 1 in the stub (`inclRownums`), as gt's `gt_preview()`. A run of one
row is shown, not left out. Written `tabellaPreview(data, topN = 3)`, with a body if you like.

## Building a table (`tabelline/build`)

Building a table for display: the step every renderer shares, after gt's `build_data()`.

### BuiltRow (type) · [#build-BuiltRow](https://pietroppeter.github.io/tabelline/api/#build-BuiltRow)

```nim
BuiltRow = object
  index*: int                ## row in the data
  stub*: string              ## the stub cell, formatted ("" without a stub)
  indent*: int               ## indent level of the stub cell (0 to 5)
  levels*: seq[string]       ## the stub's higher levels (`stubCols`), formatted
  spans*: seq[int]           ## how many rows each level spans: 0 when the one above covers it
  cells*: seq[string]        ## formatted cells of the visible data columns
```

### BuiltSummary (type) · [#build-BuiltSummary](https://pietroppeter.github.io/tabelline/api/#build-BuiltSummary)

```nim
BuiltSummary = object
  label*: string             ## the label in the stub, rendered
  key*: string               ## the location key of its stub cell (`summaryKey`)
  cells*: seq[string]        ## formatted cells of the visible data columns
  values*: seq[Value]        ## the values behind them (missing where a column is not summed)
```

### BuiltGroup (type) · [#build-BuiltGroup](https://pietroppeter.github.io/tabelline/api/#build-BuiltGroup)

```nim
BuiltGroup = object
  id*: string
  label*: string ## rendered label ("" for rows outside any group, unless
                 ## `rowGroupDefaultLabel` names them)
  rows*: seq[BuiltRow]
  summaryTop*, summaryBottom*: seq[BuiltSummary] ## the group's summary rows
```

### Built (type) · [#build-Built](https://pietroppeter.github.io/tabelline/api/#build-Built)

```nim
Built = object
  ctx*: RenderContext
  columns*: seq[ColInfo]     ## visible data columns, in order
  groups*: seq[BuiltGroup]
  grandTop*, grandBottom*: seq[BuiltSummary] ## the grand summary rows
  marks*: Table[string, seq[int]] ## location key -> footnote numbers
  notes*: seq[string]        ## rendered footnotes, by number - 1
  plainNotes*: seq[string]   ## footnotes without a mark
  footer*: seq[(int, string)] ## the footnotes in the order shown: (mark number or 0, text)
  styles*: Table[string, string] ## location key -> CSS
```

### cellKey (func) · [#build-cellKey](https://pietroppeter.github.io/tabelline/api/#build-cellKey)

```nim
func cellKey(row: int; col: string): string
```

### colKey (func) · [#build-colKey](https://pietroppeter.github.io/tabelline/api/#build-colKey)

```nim
func colKey(col: string): string
```

### spannerKey (func) · [#build-spannerKey](https://pietroppeter.github.io/tabelline/api/#build-spannerKey)

```nim
func spannerKey(label: string): string
```

### groupKey (func) · [#build-groupKey](https://pietroppeter.github.io/tabelline/api/#build-groupKey)

```nim
func groupKey(id: string): string
```

### summaryKey (func) · [#build-summaryKey](https://pietroppeter.github.io/tabelline/api/#build-summaryKey)

```nim
func summaryKey(group, label: string; col = ""): string
```

A cell of a group's summary row (the stub cell when `col` is "").

### grandKey (func) · [#build-grandKey](https://pietroppeter.github.io/tabelline/api/#build-grandKey)

```nim
func grandKey(label: string; col = ""): string
```

### renderText (func) · [#build-renderText](https://pietroppeter.github.io/tabelline/api/#build-renderText)

```nim
func renderText(t: Text; ctx: RenderContext): string
```

### renderLabel (func) · [#build-renderLabel](https://pietroppeter.github.io/tabelline/api/#build-renderLabel)

```nim
func renderLabel(t: Text; ctx: RenderContext): string
```

A label (of a column, a spanner, the stubhead): like `renderText`, and units between `{{`
and `}}` are formatted (`"Density, {{kg/m^3}}"`).

### columnLabel (func) · [#build-columnLabel](https://pietroppeter.github.io/tabelline/api/#build-columnLabel)

```nim
func columnLabel(c: ColInfo; ctx: RenderContext; unitsPattern = "{1}, {2}"): string
```

The label of a column, with its units (`colsUnits`), placed by the column's pattern or else
by `unitsPattern` (the option `columnLabelsUnitsPattern`).

### formatValue (proc) · [#build-formatValue](https://pietroppeter.github.io/tabelline/api/#build-formatValue)

```nim
proc formatValue(t: Tabella; row: int; col: string; v: Value; ctx: RenderContext): string
```

`v` as the cell at `row` of `col` would be formatted: the last format that covers the cell.
A missing value is "".

### formatCell (proc) · [#build-formatCell](https://pietroppeter.github.io/tabelline/api/#build-formatCell)

```nim
proc formatCell(t: Tabella; row: int; col: string; ctx: RenderContext): string
```

The shown text of one cell: the last format that covers it, then any substitution.

### markText (func) · [#build-markText](https://pietroppeter.github.io/tabelline/api/#build-markText)

```nim
func markText(n: int; marks: FootnoteMarks; custom: seq[string] = @[]): string
func markText(n: int; o: TabOptions): string
```

The mark of footnote `n` (from 1): numbers, letters, capitals, the four standard symbols
(*, †, ‡, §) or six extended ones (with ‖, ¶), or marks of your own; symbols repeat (**) when
they run out.

### wrapMark (func) · [#build-wrapMark](https://pietroppeter.github.io/tabelline/api/#build-wrapMark)

```nim
func wrapMark(s, spec: string): string
```

`s` inside the brackets that `spec` asks for: "(" gives "(1)", "[" gives "[1]".

### markSpanHtml (func) · [#build-markSpanHtml](https://pietroppeter.github.io/tabelline/api/#build-markSpanHtml)

```nim
func markSpanHtml(s, spec: string): string
```

A mark (or marks) as HTML: raised with "^", italic with "i", bold with "b".

### keysOf (proc) · [#build-keysOf](https://pietroppeter.github.io/tabelline/api/#build-keysOf)

```nim
proc keysOf(t: Tabella; target: Target; columns: seq[ColInfo]): seq[string]
```

The location keys a target covers, as the renderers name them.

### displayOrder (proc) · [#build-displayOrder](https://pietroppeter.github.io/tabelline/api/#build-displayOrder)

```nim
proc displayOrder(t: Tabella): seq[int]
```

The rows of the data in the order they are shown (before grouping), without hidden rows.

### fillPattern (func) · [#build-fillPattern](https://pietroppeter.github.io/tabelline/api/#build-fillPattern)

```nim
func fillPattern(pattern: string;
                 lookup: proc (r: PatternRef): (string, bool)
func fillPattern(pattern: string; texts: seq[string]; missing: seq[bool]): string
```

`pattern` with each `{...}` replaced by `lookup` (its text, and whether the value is
missing); a part in `<<...>>` is dropped when a value it names is missing (as in gt's
`cols_merge`).

### shownCell (proc) · [#build-shownCell](https://pietroppeter.github.io/tabelline/api/#build-shownCell)

```nim
proc shownCell(t: Tabella; row: int; col: string; ctx: RenderContext): string
```

The text of a body cell: merged with other columns (`colsMerge`) or formatted.

### transformCell (proc) · [#build-transformCell](https://pietroppeter.github.io/tabelline/api/#build-transformCell)

```nim
proc transformCell(t: Tabella; row: int; col: string; shown: string): string
```

The shown text of a cell after the text transforms that cover it, in the order given.

### build (proc) · [#build-build](https://pietroppeter.github.io/tabelline/api/#build-build)

```nim
proc build(t: Tabella; ctx: RenderContext): Built
```

### marksHtml (proc) · [#build-marksHtml](https://pietroppeter.github.io/tabelline/api/#build-marksHtml)

```nim
proc marksHtml(b: Built; key: string; o: TabOptions): string
```

### marksText (proc) · [#build-marksText](https://pietroppeter.github.io/tabelline/api/#build-marksText)

```nim
proc marksText(b: Built; key: string; o: TabOptions): string
```

### footMarkHtml (proc) · [#build-footMarkHtml](https://pietroppeter.github.io/tabelline/api/#build-footMarkHtml)

```nim
proc footMarkHtml(n: int; o: TabOptions): string
```

### footMarkText (proc) · [#build-footMarkText](https://pietroppeter.github.io/tabelline/api/#build-footMarkText)

```nim
proc footMarkText(n: int; o: TabOptions): string
```

### spannerLevels (func) · [#build-spannerLevels](https://pietroppeter.github.io/tabelline/api/#build-spannerLevels)

```nim
func spannerLevels(t: Tabella; columns: seq[ColInfo]): int
```

How many rows of spanners sit over the visible columns.

### spannerAt (func) · [#build-spannerAt](https://pietroppeter.github.io/tabelline/api/#build-spannerAt)

```nim
func spannerAt(t: Tabella; col: string; level: int): int
```

The index of the spanner over `col` at `level`, or -1.

## HTML (`tabelline/render_html`)

Rendering to HTML: one `<div>` holding a `<table>`, styled by `tabellaCss`, one stylesheet for every table, with the options the table changes as CSS variables on the `<div>`.

### nanoplotCss (const) · [#render_html-nanoplotCss](https://pietroppeter.github.io/tabelline/api/#render_html-nanoplotCss)

```nim
nanoplotCss = """[i] .tb_nanoplot text { font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, 'DejaVu Sans Mono', monospace; stroke-width: 0.15em; paint-order: stroke; stroke-linejoin: round; cursor: default; }
[i] .tb_nanoplot .vert-line:hover rect { fill: var(--tb-guide); fill-opacity: 40%; stroke: #FFFFFF60; }
[i] .tb_nanoplot .vert-line:hover text, [i] .tb_nanoplot .horizontal-line:hover text, [i] .tb_nanoplot .ref-line:hover text, [i] .tb_nanoplot .boxplot-line:hover text { stroke: white; fill: #212427; }
[i] .tb_nanoplot .ref-line:hover rect { stroke: #FFFFFF60; }
[i] .tb_nanoplot .ref-line:hover line { stroke: #FF0000; }
[i] .tb_nanoplot .y-axis-line:hover rect { fill: #EDEDED; fill-opacity: 60%; stroke: #FFFFFF60; }
[i] .tb_nanoplot .y-axis-line:hover text { stroke: white; stroke-width: 0.20em; fill: #1A1C1F; }
[i] .tb_nanoplot_static .vert-line text, [i] .tb_nanoplot_static .horizontal-line text, [i] .tb_nanoplot_static .ref-line text, [i] .tb_nanoplot_static .boxplot-line text { stroke: white; fill: #212427; }
[i] .tb_nanoplot_static .y-axis-line rect { fill: #EDEDED; fill-opacity: 60%; }
[i] .tb_nanoplot_static .y-axis-line text { stroke: white; stroke-width: 0.20em; fill: #1A1C1F; }
"""
```

### tabellaCss (let) · [#render_html-tabellaCss](https://pietroppeter.github.io/tabelline/api/#render_html-tabellaCss)

```nim
tabellaCss = tabellaCssValue & themeRule()
```

The CSS of every table, the same for all of them: each value is a CSS variable named after
its option (`--tb-table-font-size` for `tableFontSize`), falling back to the default. A
table sets the variables of the options it changes on its `<div>` (`toHtml`); a page can
set one for all its tables (`.tabella { --tb-table-font-size: 14px }`). A table that takes
the page's theme (`optCssTheme()`) gets the class `tb_css_theme`, whose rule here sets the
theme's variables once for all of them.

### tabellaStyle (let) · [#render_html-tabellaStyle](https://pietroppeter.github.io/tabelline/api/#render_html-tabellaStyle)

```nim
tabellaStyle = "<style>\n" & tabellaCss & "</style>"
```

`tabellaCss` in a `<style>` element, as `toHtml` writes it.

### styleVars (proc) · [#render_html-styleVars](https://pietroppeter.github.io/tabelline/api/#render_html-styleVars)

```nim
proc styleVars(o: TabOptions): string
```

The variables of the options `o` changes, for the `style` of the table's `<div>`: changed
from the defaults, or from `optCssTheme()` for a table that takes it (`isThemed`).

### toHtml (proc) · [#render_html-toHtml](https://pietroppeter.github.io/tabelline/api/#render_html-toHtml)

```nim
proc toHtml(t: Tabella; makePage = false; withStyle = true): string
```

The table as an HTML fragment (a `<div>` holding the `<table>`), ready to put in a page.
With `withStyle = true` the fragment starts with `tabellaCss` in a `<style>`, so it works
alone; with `false` it leaves it out, for a page that writes `tabellaCss` once for all its
tables (`nbTable` does). With `makePage = true`, a whole standalone page holding it, titled
after the table, as Great Tables' `as_raw_html(make_page = True)`.

Example (spec table-parts):

```nim
let t = tabella(tavolaPitagorica(2)):
  tabCaption "Table 1: the times table of 2"
echo "<caption class=\"tb_caption\">Table 1: the times table of 2</caption>" in t.toHtml
echo t
```

```text
true
Table 1: the times table of 2
┌───┬───┬───┐
│ × │ 1 │ 2 │
╞═══╪═══╪═══╡
│ 1 │ 1 │ 2 │
│ 2 │ 2 │ 4 │
└───┴───┴───┘
```

### save (proc) · [#render_html-save](https://pietroppeter.github.io/tabelline/api/#render_html-save)

```nim
proc save(t: Tabella; path: string)
```

Writes the table as a standalone HTML page, as gt's `gtsave("x.html")`.

## Text and Markdown (`tabelline/render_text`)

Rendering to plain text (box drawing, for terminals and `echo`) and to Markdown (a GitHub pipe table, for nimib's Markdown backend and READMEs).

### toText (proc) · [#render_text-toText](https://pietroppeter.github.io/tabelline/api/#render_text-toText)

```nim
proc toText(t: Tabella): string
```

The table drawn with box characters, like a dataframe printed at the console, but with the
formats, the stub, the groups and the notes.

### $ (proc) · [#render_text-op24](https://pietroppeter.github.io/tabelline/api/#render_text-op24)

```nim
proc `$`(t: Tabella): string
```

`echo t` draws the table.

### toMarkdown (proc) · [#render_text-toMarkdown](https://pietroppeter.github.io/tabelline/api/#render_text-toMarkdown)

```nim
proc toMarkdown(t: Tabella): string
```

A GitHub-flavoured Markdown table, with the title above and the notes below. Spanners and
group headings, which pipe tables cannot hold, become a line of text.

tabelline's own (not in gt)

## Reading a table back (`tabelline/extract`)

The built table as data: what a reader sees, cell by cell, as gt's `extract_body()`, `extract_cells()` and `extract_summary()` give it.

### extractCells (proc) · [#extract-extractCells](https://pietroppeter.github.io/tabelline/api/#extract-extractCells)

```nim
proc extractCells(t: Tabella; columns: ColSel; rows = allRows(); ctx = rcText): seq[
    string]
```

The shown text of the body cells of `columns` and `rows`, column by column, each in the
order the table shows its rows: `extractCells(t, "mass")`. `ctx = rcHtml` gives HTML.

gt: `extract_cells()`

Example (spec rendering):

```nim
let t = tabella(planets(), rownameCol = "planet", groupnameCol = "type"):
  colsHide ["diameter", "density", "gravity", "day_length", "distance", "orbital_period", "mean_temp", "rings", "moons"]
  fmtNumber "mass", decimals = 1
  summaryRows fns = {"total": agg.sum}
echo extractCells(t, "mass", rows = [0, 1]).join(" | ")
echo tabella(extractSummary(t))
```

```text
0.3 | 4.9
┌─────────────┬───────┬─────────┐
│ group       │ label │ mass    │
╞═════════════╪═══════╪═════════╡
│ Terrestrial │ total │ 11.8    │
│ Gas giant   │ total │ 2,466.0 │
│ Ice giant   │ total │ 188.8   │
└─────────────┴───────┴─────────┘
```

### extractBody (proc) · [#extract-extractBody](https://pietroppeter.github.io/tabelline/api/#extract-extractBody)

```nim
proc extractBody(t: Tabella; ctx = rcText): TableData
```

The body as a table of texts, in the order shown: a column `group` (when the table has row
groups), the stub (`rowname`, when it has one) and every visible column, with the formats,
merges and substitutions applied.

gt: `extract_body()`

### extractSummary (proc) · [#extract-extractSummary](https://pietroppeter.github.io/tabelline/api/#extract-extractSummary)

```nim
proc extractSummary(t: Tabella; ctx = rcText; values = false): TableData
```

The summary rows as a table of texts: `group` ("" for a grand summary row), `label`, and a
cell for each visible column, as shown; with `values = true` the values themselves, as
gt's `extract_summary()` gives them (missing where a column is not summed).

gt: `extract_summary()`

Example (spec rendering):

```nim
let t = tabella(planets(), rownameCol = "planet", groupnameCol = "type"):
  colsHide ["diameter", "density", "gravity", "day_length", "distance", "orbital_period", "mean_temp", "rings", "moons"]
  fmtNumber "mass", decimals = 1
  summaryRows fns = {"total": agg.sum}
echo extractCells(t, "mass", rows = [0, 1]).join(" | ")
echo tabella(extractSummary(t))
```

```text
0.3 | 4.9
┌─────────────┬───────┬─────────┐
│ group       │ label │ mass    │
╞═════════════╪═══════╪═════════╡
│ Terrestrial │ total │ 11.8    │
│ Gas giant   │ total │ 2,466.0 │
│ Ice giant   │ total │ 188.8   │
└─────────────┴───────┴─────────┘
```

## Pictures (`tabelline/pictures`)

Pictures in cells: icons and images, drawn without loading anything remote.

### Icon (type) · [#pictures-Icon](https://pietroppeter.github.io/tabelline/api/#pictures-Icon)

```nim
Icon = object
  name*, style*, label*, path*: string
  width*: int
```

A Font Awesome icon: its name, style ("solid", "regular" or "brands"), label and drawing
(an SVG path on a canvas `width` wide and 512 high).

### findIcon (proc) · [#pictures-findIcon](https://pietroppeter.github.io/tabelline/api/#pictures-findIcon)

```nim
proc findIcon(name: string): (bool, Icon)
```

The icon for a name: a short name ("star", the regular style when there are two), a full
name ("fas fa-star", "fa-solid fa-star") or an older name ("user-large" is "user").

### hasIcon (proc) · [#pictures-hasIcon](https://pietroppeter.github.io/tabelline/api/#pictures-hasIcon)

```nim
proc hasIcon(name: string): bool
```

Whether `name` is a Font Awesome Free icon (see `findIcon`).

Example (spec formatting):

```nim
let d = tableData:
  planet: ["Earth", "Jupiter"]
  kind: ["mountain", "cloud, star"]
let t = tabella(d):
  fmtIcon "kind", fillColors = {"star": "gold"}
echo t
echo t.toHtml.count("class=\"tb_icon\""), " ", icon("star").style, " ", icon("fas fa-star").style, " ", hasIcon("user-large")
```

```text
┌─────────┬─────────────┐
│ planet  │ kind        │
╞═════════╪═════════════╡
│ Earth   │ mountain    │
│ Jupiter │ cloud, star │
└─────────┴─────────────┘
3 regular solid true
```

### icon (proc) · [#pictures-icon](https://pietroppeter.github.io/tabelline/api/#pictures-icon)

```nim
proc icon(name: string): Icon
```

The icon for a name (see `findIcon`); raises `ValueError` for an unknown one.

Example (spec formatting):

```nim
let d = tableData:
  planet: ["Earth", "Jupiter"]
  kind: ["mountain", "cloud, star"]
let t = tabella(d):
  fmtIcon "kind", fillColors = {"star": "gold"}
echo t
echo t.toHtml.count("class=\"tb_icon\""), " ", icon("star").style, " ", icon("fas fa-star").style, " ", hasIcon("user-large")
```

```text
┌─────────┬─────────────┐
│ planet  │ kind        │
╞═════════╪═════════════╡
│ Earth   │ mountain    │
│ Jupiter │ cloud, star │
└─────────┴─────────────┘
3 regular solid true
```

### iconSvg (proc) · [#pictures-iconSvg](https://pietroppeter.github.io/tabelline/api/#pictures-iconSvg)

```nim
proc iconSvg(name: string; height = "1em"; fill = ""; fillAlpha = NaN;
             stroke = ""; strokeWidth = ""; strokeAlpha = NaN; marginLeft = "";
             marginRight = ""; verticalAlign = "-0.125em"; title = "";
             a11y = "semantic"): string
```

An icon as inline SVG, `height` high and as wide as its shape: `iconSvg("star")`. The fill is
the text's colour unless `fill` is given. With `a11y = "semantic"` a screen reader reads its
label (or `title`), with "decorative" it skips it, with "none" nothing is added.

### fmtIcon (proc) · [#pictures-fmtIcon](https://pietroppeter.github.io/tabelline/api/#pictures-fmtIcon)

```nim
proc fmtIcon(t: sink Tabella; columns: ColSel; rows = allRows(); height = "1em";
             sep = " "; strokeColor = ""; strokeWidth = ""; strokeAlpha = NaN;
             fillColor = ""; fillColors: openArray[(string, string)] = [];
             fillAlpha = NaN; marginLeft = ""; marginRight = "";
             a11y = "semantic"): Tabella
```

Names of Font Awesome Free icons as icons: "star", or several, in a list or separated by
commas ("hard-drive, clock"), joined by `sep`. `fillColor` colours them all, `fillColors` by name
(`{"circle-check": "green"}`); by default they take the colour of the text. In text output
the names stay. An unknown name raises `ValueError` here, not when the table is rendered.

gt: `fmt_icon()` · Great Tables: `GT.fmt_icon()`

Example (spec formatting):

```nim
let d = tableData:
  planet: ["Earth", "Jupiter"]
  kind: ["mountain", "cloud, star"]
let t = tabella(d):
  fmtIcon "kind", fillColors = {"star": "gold"}
echo t
echo t.toHtml.count("class=\"tb_icon\""), " ", icon("star").style, " ", icon("fas fa-star").style, " ", hasIcon("user-large")
```

```text
┌─────────┬─────────────┐
│ planet  │ kind        │
╞═════════╪═════════════╡
│ Earth   │ mountain    │
│ Jupiter │ cloud, star │
└─────────┴─────────────┘
3 regular solid true
```

### imageDataUrl (proc) · [#pictures-imageDataUrl](https://pietroppeter.github.io/tabelline/api/#pictures-imageDataUrl)

```nim
proc imageDataUrl(file: string): string
```

A file as a data URL, its type from its extension: `imageDataUrl("moon.png")` is
"data:image/png;base64,...". Raises `ValueError` for a file that is not there.

### fmtImage (proc) · [#pictures-fmtImage](https://pietroppeter.github.io/tabelline/api/#pictures-fmtImage)

```nim
proc fmtImage(t: sink Tabella; columns: ColSel; rows = allRows(); height = "";
              width = ""; sep = " "; path = ""; filePattern = "{x}";
              encode = true; alt = ""): Tabella
```

File names as images: each cell holds one or more names (a list, or separated by commas), found in
`path` and written with `filePattern` ("{x}.png" for a cell "moon"). With `encode` (the
default) a local file is read now and inlined as a data URL, so the page needs nothing else;
an address (`https://...`) is left as it is. Without `height` or `width` an image is 2em
high. `alt` is the text a screen reader reads ("{x}" is the name); by default the name. In
text output the names stay.

gt: `fmt_image()` · Great Tables: `GT.fmt_image()`

Example (spec formatting):

```nim
let dir = getTempDir()
writeFile(dir / "dot.svg", "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2 2'><circle cx='1' cy='1' r='1'/></svg>")
let d = tableData:
  pic: ["dot"]
let t = tabella(d):
  fmtImage "pic", path = dir, filePattern = "{x}.svg"
echo t
echo t.toHtml.contains("<img src=\"data:image/svg+xml;base64,")
```

```text
┌─────┐
│ pic │
╞═════╡
│ dot │
└─────┘
true
```

### localImage (proc) · [#pictures-localImage](https://pietroppeter.github.io/tabelline/api/#pictures-localImage)

```nim
proc localImage(file: string; height = "2em"; alt = ""): Text
```

A local image as `Text`, for a title, a label, a note or a cell of `fmtMarkdown`: the file is
read now and inlined as a data URL, as gt's `local_image()`. `alt` (by default the file's
name) is what a screen reader reads, and what text output shows.

gt: `local_image()`

### webImage (proc) · [#pictures-webImage](https://pietroppeter.github.io/tabelline/api/#pictures-webImage)

```nim
proc webImage(url: string; height = "2em"; alt = ""): Text
```

An image on the web as `Text`, the address left as it is (the page loads it), as gt's
`web_image()`. `alt` is by default the last part of the address.

gt: `web_image()`

Example (spec formatting):

```nim
let t = tabella(planets()):
  colsHide ["density", "gravity", "day_length", "distance", "orbital_period", "mean_temp", "moons", "rings", "diameter", "type"]
  rowsHide [1, 2, 3, 4, 5, 6, 7]
  tabHeader webImage("https://example.org/sun.png", alt = "☉"), "The first planet"
echo t
echo t.toHtml.count("<img src=\"https://example.org/sun.png\"")
```

```text
        ☉
 The first planet
┌─────────┬──────┐
│ planet  │ mass │
╞═════════╪══════╡
│ Mercury │ 0.33 │
└─────────┴──────┘
1
```

## Nanoplots (`tabelline/nanoplots`)

Nanoplots: tiny plots in cells, as inline SVG, after Great Tables' `fmt_nanoplot()` and gt's `cols_nanoplot()` (ported from Great Tables' `_utils_nanoplots.py`, MIT, `licenses/great-tables-MIT.txt`).

### NanoplotOptions (type) · [#nanoplots-NanoplotOptions](https://pietroppeter.github.io/tabelline/api/#nanoplots-NanoplotOptions)

```nim
NanoplotOptions = object
  dataPointRadius*: seq[float] ## one value, or one per point (repeating)
  dataPointStrokeColor*, dataPointFillColor*: seq[string]
  dataPointStrokeWidth*: seq[float]
  dataLineStrokeColor*: string
  dataLineStrokeWidth*: float
  dataLineType*: string
  dataAreaFillColor*: string
  dataBarStrokeColor*, dataBarFillColor*: seq[string] ## one value, or one per bar
  dataBarStrokeWidth*: seq[float]
  dataBarNegativeStrokeColor*, dataBarNegativeFillColor*: string
  dataBarNegativeStrokeWidth*: float
  referenceLineColor*, referenceAreaFillColor*: string
  verticalGuideStrokeColor*: string
  verticalGuideStrokeWidth*: float
  showDataPoints*, showDataLine*, showDataArea*, showReferenceLine*,
  showReferenceArea*, showVerticalGuides*, showYAxisGuide*,
  interactiveDataValues*: bool
  currency*: string
  yValFmtFn*, yAxisFmtFn*, yRefLineFmtFn*: proc (x: float): string
```

The look of a nanoplot, after Great Tables' `nanoplot_options()` (see `nanoplotOptions`).

### at (func) · [#nanoplots-at](https://pietroppeter.github.io/tabelline/api/#nanoplots-at)

```nim
func at[T](s: seq[T]; i: int): T
```

The value of a per-point option for point `i`: the list repeats.

### nanoplotOptions (func) · [#nanoplots-nanoplotOptions](https://pietroppeter.github.io/tabelline/api/#nanoplots-nanoplotOptions)

```nim
func nanoplotOptions(dataPointRadius: SomeNumber | seq[float] | seq[int] = 10.0;
                     dataPointStrokeColor: string | seq[string] = "#FFFFFF";
    dataPointStrokeWidth: SomeNumber | seq[float] | seq[int] = 4.0;
                     dataPointFillColor: string | seq[string] = "#FF0000";
                     dataLineType = "curved"; dataLineStrokeColor = "#4682B4";
                     dataLineStrokeWidth = 8.0; dataAreaFillColor = "#FF0000";
                     dataBarStrokeColor: string | seq[string] = "#3290CC";
    dataBarStrokeWidth: SomeNumber | seq[float] | seq[int] = 4.0;
                     dataBarFillColor: string | seq[string] = "#3FB5FF";
                     dataBarNegativeStrokeColor = "#CC3243";
                     dataBarNegativeStrokeWidth = 4.0;
                     dataBarNegativeFillColor = "#D75A68";
                     referenceLineColor = "#75A8B0";
                     referenceAreaFillColor = "#A6E6F2";
                     verticalGuideStrokeColor = "#911EB4";
                     verticalGuideStrokeWidth = 12.0; showDataPoints = true;
                     showDataLine = true; showDataArea = true;
                     showReferenceLine = true; showReferenceArea = true;
                     showVerticalGuides = true; showYAxisGuide = true;
                     interactiveDataValues = true; currency = "";
                     yValFmtFn: proc (x: float): string = nil;
                     yAxisFmtFn: proc (x: float): string = nil;
                     yRefLineFmtFn: proc (x: float): string = nil): NanoplotOptions
```

gt: `nanoplot_options()` · Great Tables: `nanoplot_options()`

Example (spec formatting):

```nim
let d = tableData:
  week: ["one", "two"]
  steps: [toValue(@[4, 8, 6]), toValue((x: @["2026-11-02", "2026-11-03", "2026-11-09"], y: @[5, 7, 9]))]
let t = tabella(d, rownameCol = "week"):
  fmtNanoplot "steps", options = nanoplotOptions(dataPointFillColor = @["#D64545", "#2E7D32"])
echo t
let x = nanoplotXValues(d["steps", 1])
echo t.toHtml.count("fill=\"#2E7D32\""), " green points; the last is ", (x[2] - x[0]) / 86400, " days after the first"
```

```text
┌─────┬─────────┐
│     │ steps   │
╞═════╪═════════╡
│ one │ ▁█▅ 4–8 │
│ two │ ▁▅█ 5–9 │
└─────┴─────────┘
2 green points; the last is 7.0 days after the first
```

### nanoplotValues (func) · [#nanoplots-nanoplotValues](https://pietroppeter.github.io/tabelline/api/#nanoplots-nanoplotValues)

```nim
func nanoplotValues(v: Value): seq[float]
```

The values of a nanoplot cell: a number, a list of numbers (`@[1, 4, 2]`), a record with the
values in `y` (and their places in `x`, see `nanoplotXValues`), or a text of numbers
separated by spaces, commas or semicolons, maybe in brackets ("[1, 2, NA]"); `NA` (or
`nan`) is a missing value, `NaN`.

### nanoplotXValues (proc) · [#nanoplots-nanoplotXValues](https://pietroppeter.github.io/tabelline/api/#nanoplots-nanoplotXValues)

```nim
proc nanoplotXValues(v: Value): seq[float]
```

The places of the values on the x axis: the field `x` of a record (`(x: @[1, 2, 4], y:
@[3, 5, 4])`, Great Tables' dict of x and y), numbers or ISO dates and times
(`@["2026-01-05", "2026-02-11"]`, placed by time); empty for any other cell, whose values
are evenly spaced.

Example (spec formatting):

```nim
let d = tableData:
  runner: ["Anna", "Bruno"]
  laps: [(x: @[0.0, 1, 2, 5], y: @[62.0, 60, 61, 58]), (x: @[0.0, 3, 4, 5], y: @[65.0, 63, 66, 59])]
  kit: [@["person-running", "stopwatch"], @["person-biking"]]
let t = tabella(d, rownameCol = "runner"):
  fmtNanoplot "laps", autoscale = true
  fmtIcon "kit"
echo t
echo nanoplotXValues(d["laps", 1]), " ", t.toHtml.count("class=\"tb_nanoplot\"")
```

```text
┌───────┬────────────┬───────────────────────────┐
│       │ laps       │ kit                       │
╞═══════╪════════════╪═══════════════════════════╡
│ Anna  │ ▅▃▄▁ 58–62 │ person-running, stopwatch │
│ Bruno │ ▇▅█▂ 59–66 │ person-biking             │
└───────┴────────────┴───────────────────────────┘
@[0.0, 3.0, 4.0, 5.0] 2
```

### plotTypes (const) · [#nanoplots-plotTypes](https://pietroppeter.github.io/tabelline/api/#nanoplots-plotTypes)

```nim
plotTypes = ["line", "bar", "boxplot", "shape"]
```

The kinds of nanoplot: "shape" is tabelline's, not Great Tables'.

### refKeywords (const) · [#nanoplots-refKeywords](https://pietroppeter.github.io/tabelline/api/#nanoplots-refKeywords)

```nim
refKeywords = ["mean", "median", "min", "max", "q1", "q3", "first", "last"]
```

The keywords of a reference line or area: a statistic of the values.

### nanoplotLabel (proc) · [#nanoplots-nanoplotLabel](https://pietroppeter.github.io/tabelline/api/#nanoplots-nanoplotLabel)

```nim
proc nanoplotLabel(x: float; asInteger = false; currency = "";
                   fn: proc (x: float): string = nil): string
```

A value as a nanoplot writes it, short, as Great Tables does: "0", integers below 100 as
they are, 3 significant figures ("2.50", "123"), K, M, B and T from a thousand ("1.23K"),
and "1.2E−3" for the tiny and the huge; with a `currency`, money ("$12.50", "€1.2K").

Example (spec formatting):

```nim
let d = tableData:
  city: ["Oslo", "Rome"]
  trend: ["1 4 2 8 5", "3, NA, 6, 2"]
  change: [4.2, -1.5]
let t = tabella(d, rownameCol = "city"):
  fmtNanoplot "trend", referenceLine = "mean"
  fmtNanoplot "change", plotType = "bar"
echo t
echo t.toHtml.count("class=\"tb_nanoplot\""), " ", nanoplotLabel(1234), " ", nanoplotLabel(0.25)
```

```text
┌──────┬───────────┬───────────────────┐
│      │ trend     │            change │
╞══════╪═══════════╪═══════════════════╡
│ Oslo │ ▁▄▂█▅ 1–8 │    │███████ 4.20  │
│ Rome │ ▃ █▁ 2–6  │ ███│        −1.50 │
└──────┴───────────┴───────────────────┘
4 1.23K 0.25
```

### shapeSide (func) · [#nanoplots-shapeSide](https://pietroppeter.github.io/tabelline/api/#nanoplots-shapeSide)

```nim
func shapeSide(y, x: seq[float]): float
```

The side of the square a shape fills: its width or its height, the larger.

Example (spec formatting):

```nim
let d = tableData:
  field: ["square", "strip"]
  outline: [toValue((x: @[0, 2, 2, 0], y: @[0, 0, 2, 2])), toValue((x: @[0, 4, 4, 0], y: @[0, 0, 1, 1]))]
let t = tabella(d, rownameCol = "field"):
  fmtNanoplot "outline", plotType = "shape", autoscale = true
echo t
echo t.toHtml.count("class=\"tb_shape\""), " shapes; the square is ", shapeSide(@[0.0, 0, 2, 2], @[0.0, 2, 2, 0]), " wide"
```

```text
┌────────┬─────────────────────┐
│        │ outline             │
╞════════╪═════════════════════╡
│ square │ ◆ shape of 4 points │
│ strip  │ ◆ shape of 4 points │
└────────┴─────────────────────┘
2 shapes; the square is 2.0 wide
```

### nanoplotSummary (proc) · [#nanoplots-nanoplotSummary](https://pietroppeter.github.io/tabelline/api/#nanoplots-nanoplotSummary)

```nim
proc nanoplotSummary(y: seq[float]; plotType: string; single = false): string
```

The values in words, for a screen reader: "Line plot of 8 values from 12 to 47, ending at 30".

### nanoplotSvg (proc) · [#nanoplots-nanoplotSvg](https://pietroppeter.github.io/tabelline/api/#nanoplots-nanoplotSvg)

```nim
proc nanoplotSvg(y: seq[float]; plotType = "line"; height = "2em";
                 missingVals = "gap"; referenceLine = "";
                 referenceArea = ("", ""); expandY: seq[float] = @[];
                 all: seq[float] = @[]; single = false;
                 options = nanoplotOptions(); alt = ""; x: seq[float] = @[];
                 expandX: seq[float] = @[]; side = 0.0;
                 referenceX: seq[(float, string)] = @[]; sharedCount = 0): string
```

One nanoplot as inline SVG: a line, bar or box plot of the values `y` (NaN for a missing
one), or with `single` a horizontal bar or line for `y[0]`, on the scale of `all` (the
values of every row: single values and box plots share their scale). "" when there is
nothing to plot. `alt` is read by a screen reader ("{x}" is a summary of the values).
With `x` (as many as `y`) a line plot puts each value at its place on an x axis that also
includes `expandX`; a bar plot and a box plot leave `x` out. A "shape" joins the points
(`x`, `y`) in their order and closes them, at the same scale across and up, in a square

### nanoplotText (proc) · [#nanoplots-nanoplotText](https://pietroppeter.github.io/tabelline/api/#nanoplots-nanoplotText)

```nim
proc nanoplotText(y: seq[float]; plotType = "line"; missingVals = "gap";
                  all: seq[float] = @[]; single = false;
                  expandY: seq[float] = @[]; options = nanoplotOptions()): string
```

A nanoplot in text: a sparkline of the values ("▁▃▅█ 1–9", on the axis of `expandY` too), a
bar of blocks for a single value, left of a zero line when it is negative ("███│ −4", "│█ 2"),
the five numbers of a box plot ("1 ┤2 │3│ 5├ 9").

### fmtNanoplot (proc) · [#nanoplots-fmtNanoplot](https://pietroppeter.github.io/tabelline/api/#nanoplots-fmtNanoplot)

```nim
proc fmtNanoplot(t: sink Tabella; columns: ColSel; rows = allRows();
                 plotType = "line"; plotHeight = "2em"; missingVals = "gap";
                 autoscale = false; referenceLine = "";
                 referenceArea = ("", ""); expandY: seq[float] = @[];
                 options = nanoplotOptions(); alt = "";
                 expandX: seq[float] = @[]; referenceX: seq[string] = @[]): Tabella
```

Nanoplots of the values in each cell (see `nanoplotValues`: a list, a record of `x` and `y`,
or a text of numbers): a line plot ("line"), a bar plot
("bar") or a box plot ("boxplot"). A numeric column gets one horizontal bar or line per row,
from a zero line shared by the rows. `referenceLine` is a number ("10") or a statistic of the
cell's values ("mean", "median", "min", "max", "q1", "q3", "first", "last"), and
`referenceArea` two of them. `missingVals` says what a missing value does: "gap" breaks the
line, "marker" marks it, "zero" counts it as 0, "remove" leaves it out. With `autoscale`

Great Tables: `GT.fmt_nanoplot()`

Example (spec formatting):

```nim
let d = tableData:
  city: ["Oslo", "Rome"]
  trend: ["1 4 2 8 5", "3, NA, 6, 2"]
  change: [4.2, -1.5]
let t = tabella(d, rownameCol = "city"):
  fmtNanoplot "trend", referenceLine = "mean"
  fmtNanoplot "change", plotType = "bar"
echo t
echo t.toHtml.count("class=\"tb_nanoplot\""), " ", nanoplotLabel(1234), " ", nanoplotLabel(0.25)
```

```text
┌──────┬───────────┬───────────────────┐
│      │ trend     │            change │
╞══════╪═══════════╪═══════════════════╡
│ Oslo │ ▁▄▂█▅ 1–8 │    │███████ 4.20  │
│ Rome │ ▃ █▁ 2–6  │ ███│        −1.50 │
└──────┴───────────┴───────────────────┘
4 1.23K 0.25
```

### colsNanoplot (proc) · [#nanoplots-colsNanoplot](https://pietroppeter.github.io/tabelline/api/#nanoplots-colsNanoplot)

```nim
proc colsNanoplot(t: sink Tabella; columns: ColSel; rows = allRows();
                  plotType = "line"; plotHeight = "2em"; missingVals = "gap";
                  autoscale = false; referenceLine = "";
                  referenceArea = ("", ""); expandY: seq[float] = @[];
                  newColName = "nanoplots"; newColLabel = ""; before = "";
                  after = ""; autohide = true; options = nanoplotOptions();
                  alt = ""; xVals: seq[float] = @[];
                  referenceX: seq[string] = @[]): Tabella
```

A new column of nanoplots, one per row, of the values of several `columns` (in their order):
after gt's `cols_nanoplot()`. The columns are hidden (`autohide`); the new one is
`newColName`, labelled `newColLabel` (its name by default), at the end or `before` or
`after` a column. `xVals` (not from gt) places the columns on the x axis, one value each, the
same in every row (the years of `y2006` ... `y2025`): then `referenceX` draws a dashed
vertical line at a place of that axis. The other arguments are those of `fmtNanoplot`.

gt: `cols_nanoplot()`

Example (spec table-parts):

```nim
let t = tabella(tavolaPitagorica(4), rownameCol = "×"):
  colsNanoplot ["1", "2", "3", "4"], newColLabel = "the row", autoscale = true
echo t
```

```text
┌───┬───────────┐
│   │ the row   │
╞═══╪═══════════╡
│ 1 │ ▁▁▂▂ 1–4  │
│ 2 │ ▁▂▃▄ 2–8  │
│ 3 │ ▂▃▅▆ 3–12 │
│ 4 │ ▂▄▆█ 4–16 │
└───┴───────────┘
```

## Everything at once (`tabelline`)

`import tabelline` brings every module above.

Great tables for Nim.

### tabella (macro) · [#tabelline-tabella](https://pietroppeter.github.io/tabelline/api/#tabelline-tabella)

```nim
macro tabella(args: varargs[untyped]): untyped
```

`tabella(data, rownameCol = "name")` is a table for `data` (see `initTabella`), and with a body,
`tabella(data): body` is that table changed by the verbs in `body`, one per line, without
repeating the table: `tabHeader "Title"` stands for `t = t.tabHeader("Title")`.

A verb in `body` may end with an indented block. In a verb whose first argument is a list of
pairs (`colsLabel`, `colsWidth`, `colsUnits`, `textCaseMatch`, `summaryRows`,
`grandSummaryRows`, `summaryColumns`) a line `label: value` is a pair; in any verb a line
`name = value` is a named argument; in a summary verb a line `fmtNumber(decimals = 1)` is
`fmt = (x: float) => formatNumber(x, decimals = 1)`; `tabOptions:` takes `name = value`:

```nim

Example (spec formatting):

```nim
let d = tableData:
  country: ["IT", "JPN", "FR,DE"]
let t = tabella(d):
  fmtFlag "country"
echo t
```

```text
┌─────────┐
│ country │
╞═════════╡
│ 🇮🇹      │
│ 🇯🇵      │
│ 🇫🇷 🇩🇪   │
└─────────┘
```

### tabellaPreview (macro) · [#tabelline-tabellaPreview](https://pietroppeter.github.io/tabelline/api/#tabelline-tabellaPreview)

```nim
macro tabellaPreview(args: varargs[untyped]): untyped
```

`tabellaPreview(data, topN = 5, bottomN = 1)` is a preview of a big table (see
`initTabellaPreview`), and with a body it is changed by the verbs in the body, as in `tabella`:

```nim
let t = tabellaPreview(citta(), topN = 3):
  fmtInteger "population"
```

Example (spec table-parts):

```nim
let preview = tabellaPreview(planets(), topN = 2, bottomN = 1):
  colsHide ["mass", "diameter", "density", "gravity", "day_length", "distance", "orbital_period", "mean_temp"]
echo preview
```

```text
┌──────┬─────────┬─────────────┬───────┬───────┐
│      │ planet  │ type        │ moons │ rings │
╞══════╪═════════╪═════════════╪═══════╪═══════╡
│ 1    │ Mercury │ Terrestrial │     0 │ false │
│ 2    │ Venus   │ Terrestrial │     0 │ false │
│ 3..7 │         │             │       │       │
│ 8    │ Neptune │ Ice giant   │    16 │ true  │
└──────┴─────────┴─────────────┴───────┴───────┘
```

### tableData (macro) · [#tabelline-tableData](https://pietroppeter.github.io/tabelline/api/#tabelline-tableData)

```nim
macro tableData(body: untyped): TableData
```

Columns as `name: [values]` lines, each value converted on its own, so a column can mix
numbers with `nil` (missing). A name can have dots, `size.mass: [...]`, or be quoted.
Values can be any list, such as a `collect`. A `for` (or `if`) adds the columns in its body,
and their names can be computed: `$j: [...]`, or any expression in parentheses.

```nim
let d = tableData:
  planet: ["Mercury", "Venus"]
  moons: [0, nil]
let tavola = tableData:
  `×`: collect(for i in 1 .. 3: i)

Example (spec formatting):

```nim
let d = tableData:
  country: ["IT", "JPN", "FR,DE"]
let t = tabella(d):
  fmtFlag "country"
echo t
```

```text
┌─────────┐
│ country │
╞═════════╡
│ 🇮🇹      │
│ 🇯🇵      │
│ 🇫🇷 🇩🇪   │
└─────────┘
```

## Datasets (`tabelline/datasets`)

`import tabelline/datasets`: small tables for examples.

Small datasets for examples and tests, built into the module (no files to find at run time).

### planetsCsv (const) · [#datasets-planetsCsv](https://pietroppeter.github.io/tabelline/api/#datasets-planetsCsv)

```nim
planetsCsv = """planet,type,mass,diameter,density,gravity,day_length,distance,orbital_period,mean_temp,moons,rings
Mercury,Terrestrial,0.330,4879,5429,3.7,4222.6,57.9,88.0,167,0,false
Venus,Terrestrial,4.87,12104,5243,8.9,2802.0,108.2,224.7,464,0,false
Earth,Terrestrial,5.97,12756,5514,9.8,24.0,149.6,365.2,15,1,false
Mars,Terrestrial,0.642,6792,3934,3.7,24.7,228.0,687.0,-65,2,false
Jupiter,Gas giant,1898,142984,1326,23.1,9.9,778.5,4331,-110,95,true
Saturn,Gas giant,568,120536,687,9.0,10.7,1432.0,10747,-140,146,true
Uranus,Ice giant,86.8,51118,1270,8.7,17.2,2867.0,30589,-195,28,true
Neptune,Ice giant,102,49528,1638,11.0,16.1,4515.0,59800,-200,16,true
"""
```

Units: mass 10^24 kg, diameter km, density kg/m³, gravity m/s², day length hours,
distance from the Sun 10^6 km, orbital period days, mean temperature °C. Known moons as

### exibbleCsv (const) · [#datasets-exibbleCsv](https://pietroppeter.github.io/tabelline/api/#datasets-exibbleCsv)

```nim
exibbleCsv = """num,char,fctr,date,time,datetime,currency,row,group
0.1111,apricot,one,2015-01-15,13:35,2018-01-01 02:22,49.95,row_1,grp_a
2.222,banana,two,2015-02-15,14:40,2018-02-02 14:33,17.95,row_2,grp_a
33.33,coconut,three,2015-03-15,15:45,2018-03-03 03:44,1.39,row_3,grp_a
444.4,durian,four,2015-04-15,16:50,2018-04-04 15:55,65100,row_4,grp_a
5550,,five,2015-05-15,17:55,2018-05-05 04:00,1325.81,row_5,grp_b
,fig,six,2015-06-15,,2018-06-06 16:11,13.255,row_6,grp_b
777000,grapefruit,seven,,19:10,2018-07-07 05:22,,row_7,grp_b
8880000,honeydew,eight,2015-08-15,20:20,,0.44,row_8,grp_b
"""
```

### isoleCsv (const) · [#datasets-isoleCsv](https://pietroppeter.github.io/tabelline/api/#datasets-isoleCsv)

```nim
isoleCsv = "# Islands of the Mediterranean by area: Wikipedia, List of islands in the Mediterranean, read 8 Nov 2026 by isole.nim\nisland,country,area,population,city\nSicily,Italy,25834,5010001,Palermo\nSardinia,Italy,24100,1656000,Cagliari\nCyprus,Cyprus,9251,,Nicosia\nCorsica,France,8681,322000,Ajaccio\nCrete,Greece,8312,622871,Heraklion\nEuboea,Greece,3655,191206,Chalcis\nMallorca,Spain,3640,846000,Palma\nLesbos,Greece,1630,86436,Mytilene\nRhodes,Greece,1398,115490,Rhodes\nChios,Greece,842,51390,Chios\nCephalonia,Greece,781,35801,Argostoli\nMenorca,Spain,694,87000,Mahón\nCorfu,Greece,592,100853,Corfu\nIbiza,Spain,577,111000,Ibiza Town\nDjerba,Tunisia,523,139544,Houmt Souk\nLemnos,Greece,476,16992,Myrina\nSamos,Greece,476,32973,Vathy\nNaxos,Greece,428,17970,Naxos\nZakynthos,Greece,406,40758,Zakynthos\nCres,Croatia,405.78,3079,Cres\nKrk,Croatia,405.78,19383,Krk\nBrač,Croatia,394.57,13956,Supetar\nAndros,Greece,380,9221,Andros\nThasos,Greece,379,13765,Thasos\nLefkada,Greece,303,22076,Lefkada\nKarpathos,Greece,301,6181,Pigadia\nHvar,Croatia,299.66,11077,Hvar\nKos,Greece,290,33388,Kos\nPag,Croatia,284.56,9059,Pag\nGökçeada,Turkey,279,8894,Çınarlı\nKythira,Greece,278,3973,Kythira\nKorčula,Croatia,276.03,15522,Korčula\nIcaria,Greece,255,8423,Agios Kirykos\nMalta,Malta,246,409259,Valletta\nElba,Italy,224,31572,Portoferraio\nSkyros,Greece,209,2994,Skyros\nParos,Greece,196,13715,Parikia\nTinos,Greece,194,8636,Tinos\nSamothrace,Greece,178,2859,Samothrace\nMilos,Greece,160,4977,Plaka\nKea,Greece,129,2446,Ioulis\nAmorgos,Greece,121,1971,Amorgos\nMarmara,Turkey,117,,\nDugi Otok,Croatia,114.44,1655,Sali\nKalymnos,Greece,111,16001,Pothia\nChergui,Tunisia,110,,\nSant\'Antioco,Italy,109,11730,Sant\'Antioco\nIos,Greece,109,2024,Ios\nMljet,Croatia,100.41,1088,Babino Polje\nKythnos,Greece,100,1456,Kythnos\nAstypalaia,Greece,97,1334,Astypalaia\nIthaca,Greece,96,3231,Vathy\nSkopelos,Greece,95.5,4960,Skopelos\nSalamis,Greece,95,39283,Salamina\nRab,Croatia,90.84,9328,Rab\nVis,Croatia,90.26,3445,Vis\nMykonos,Greece,86,10120,Mykonos\nSyros,Greece,84,21505,Ermoupoli\nAegina,Greece,83,13056,Aegina\nFormentera,Spain,83,7461,Sant Francesc Xavier\nPantelleria,Italy,83,7729,Pantelleria\nSantorini,Greece,76,15230,Fira\nLošinj,Croatia,74.68,7587,Mali Lošinj\nSerifos,Greece,73,1420,Serifos\nSifnos,Greece,73,2625,Apollonia\nGharbi,Tunisia,69,,\nGozo,Malta,67,37288,Victoria\nKasos,Greece,66,1084,Fry\nAlonissos,Greece,64,2712,Patitiri\nTilos,Greece,63,780,Megálo Chorió\nPašman,Croatia,63.34,2845,Pašman\nŠolta,Croatia,58.98,1700,Grohote\nSymi,Greece,58,2590,Symi\nLeros,Greece,53,7907,Agia Marina\nSan Pietro,Italy,51,6444,Carloforte\nAsinara,Italy,51,1,Cala d\'Oliva\nHydra,Greece,50,1948,Hydra\nUgljan,Croatia,50.21,6049,Preko\nSkiathos,Greece,48,6088,Skiathos\nLastovo,Croatia,46.87,792,Lastovo\nIschia,Italy,46,60335,Ischia\nAgios Efstratios,Greece,43,270,Agios Efstratios\nNisyros,Greece,41,987,Mandraki\nSikinos,Greece,41,273,Sikinos\nPsara,Greece,40,454,Psara\nAnafi,Greece,38,271,Anafi\nLipari,Italy,37,10763,Lipari\nBozcaada,Turkey,36,2427,Bozcaada\nKimolos,Greece,36,908,Kimolos\nAntiparos,Greece,35,1211,Antiparos\nPatmos,Greece,35,2998,Patmos\nKornat,Croatia,32.30,19,\nFolegandros,Greece,32,765,Folegandros\nFourni,Greece,30,1313,Fourni\nGavdos,Greece,29.6,152,Kastri\nČiovo,Croatia,28.80,5908,Okrug Gornji\nHalki,Greece,28.1,478,Halki\nSalina,Italy,26.8,2300,Malfa\nOlib,Croatia,26.09,140,Olib\nUzunada,Turkey,25.4,,\nPaxi,Greece,25.3,2280,Gaios\nKalamos,Greece,25,496,Kalamos\nKyra Panagia,Greece,25,2,\nGiglio,Italy,23.8,1458,\nCunda (Alibey),Turkey,23.4,,\nPoros,Greece,22.9,3993,Poros\nMolat,Croatia,22.82,197,Molat\nVir,Croatia,22.38,3000,Vir\nSpetses,Greece,22.2,4027,Spetses\nPaşalimanı,Turkey,21.4,,\nSaria,Greece,21.1,45,\nVulcano,Italy,20.9,715,Vulcano\nAvsa,Turkey,20.6,,\nAntikythera,Greece,20.4,68,Potamós\nLampedusa,Italy,20.2,4500,Lampedusa e Linosa\nLa Maddalena,Italy,20.1,11902,La Maddalena\nMeganisi,Greece,20,1040,Katomeri\nFavignana,Italy,19,4383,Favignana\nCapraia,Italy,19,410,Capraia\nElafonisos,Greece,19,1024,Elafonisos\nMurter,Croatia,18.60,4895,Murter\nMakronisos,Greece,18.3,9,\nIrakleia,Greece,17.6,141,Irakleia\nIž,Croatia,17.59,615,Iž Veli\nGyaros,Greece,17.3,0,\nMegalonisos Petalion,Greece,17.2,0,\nPolyaigos,Greece,17.2,2,\nUnije,Croatia,16.92,88,Unije\nLeipsoi,Greece,16,790,Leipsoi\nŠipan,Croatia,15.81,419,Šipanska Luka\nCaprera,Italy,15.7,0,\nCabrera,Spain,15.7,0,\nKeros,Greece,15.2,0,\nŽirje,Croatia,15.06,103,Žirje\nSestrunj,Croatia,15.03,48,Sestrunj\nSilba,Croatia,14.98,292,Silba\nŽut,Croatia,14.82,0,\nPserimos,Greece,14.8,80,Pserimos\nOinousses,Greece,14.4,826,Oinousses\nPeristera,Greece,14.2,30,\nRineia,Greece,13.7,0,\nAgathonisi,Greece,13.6,185,Megálo Chorió\nDonoussa,Greece,13.6,167,Donoussa (Stavros)\nPrvic (Krk),Croatia,13.5,0,\nStromboli,Italy,12.6,572,San Vincenzo\nDokos,Greece,12.5,18,Dokos\nPorquerolles,France,12.5,200,\nSchiza,Greece,12.3,0,\nDrvenik Veliki,Croatia,12.1,168,Drvenik Veliki\nMarettimo,Italy,12,819,Marettimo\nAgistri,Greece,12,1142,Milos (Megalohori)\nDia,Greece,11.8,0,\nGioura,Greece,11.1,0,\nCapri,Italy,10.4,12200,Capri\nMontecristo,Italy,10.4,2,\nPianosa,Italy,10.3,10,\nOthonoi,Greece,10.1,392,Othonoi\nThymaina,Greece,10.1,143,Thymaina\nImrali,Turkey,10,,\nIst,Croatia,9.65,202,\nFilicudi,Italy,9.5,235,\nTherasia,Greece,9.3,319,\nKastellorizo,Greece,9.1,492,\nLevitha,Greece,9.1,0,\nSapientza,Greece,9.1,2,\nKara Ada,Turkey,9,,\nPremuda,Croatia,8.7,58,\nUstica,Italy,8.7,1302,\nPlavnik,Croatia,8.6,0,\nMaun,Croatia,8.5,0,\nŠćedro,Croatia,8.4,0,\nZlarin,Croatia,8.1,276,\nSchoinousa,Greece,8.1,227,\nAntimilos,Greece,8,0,\nSyrna,Greece,7.9,0,\nDespotiko,Greece,7.8,0,\nAmmouliani,Greece,7.7,541,\nPonza,Italy,7.5,3107,\nAlimia,Greece,7.4,0,\nLa Galite,,7.3,,0\nKaprije,Croatia,7.1,143,\nPort-Cros,France,7,30,\nArkoi,Greece,6.7,44,\nSveti Grgur,Croatia,6.4,0,\nSkantzoura,Greece,6.2,0,\nBiševo,Croatia,5.9,15,\nKastos,Greece,5.9,80,\nTavolara,Italy,5.9,0,\nLevanzo,Italy,5.8,208,\nPano Koufonisi,Greece,5.8,399,\nSazan Island,Albania,5.7,0,\nVeliki Brijun,Croatia,5.7,0,\nIlovik,Croatia,5.5,85,\nPetalas,Greece,5.5,0,\n"
```

island, country, area (km²), population, city (the largest). Wikipedia, "List of islands in
the Mediterranean", read 8 Nov 2026.

### cittaCsv (const) · [#datasets-cittaCsv](https://pietroppeter.github.io/tabelline/api/#datasets-cittaCsv)

```nim
cittaCsv = "# EU cities by population within city limits: Wikipedia, read 8 Nov 2026 by citta.nim\ncity,state,population,counted\nBerlin,GER,3913644,2025-12-31\nMadrid,ESP,3506730,2025-01-01\nRome,ITA,2745062,2026-01-01\nParis,FRA,2047602,2026-01-01\nVienna,AUT,2044366,2026-04-01\nHamburg,GER,1869786,2026-03-31\nWarsaw,POL,1866729,2025-12-31\nBarcelona,ESP,1731649,2025-01-01\nBucharest,ROU,1709458,2025-01-01\nBudapest,HUN,1675777,2026-01-01\nMunich,GER,1505036,2025-12-31\nPrague,CZE,1405551,2026-03-31\nMilan,ITA,1362863,2026-01-01\nSofia,BUL,1303813,2025-12-31\nCologne,GER,1025523,2025-12-31\nStockholm,SWE,1000962,2026-06-30\nAmsterdam,NLD,945870,2026-06-30\nNaples,ITA,905050,2026-01-01\nMarseille,FRA,890707,2024-01-01\nTurin,ITA,855654,2026-01-01\nValencia,ESP,840792,2025-01-01\nKraków,POL,816614,2025-12-31\nZagreb,CRO,777359,2024-12-31\nFrankfurt,GER,756021,2024-12-31\nHelsinki,FIN,699637,2026-07-01\nZaragoza,ESP,693091,2025-01-01\nSeville,ESP,689423,2025-01-01\nRotterdam,NLD,673966,2026-06-30\nWrocław,POL,672601,2025-12-31\nCopenhagen,DEN,671714,2026-01-01\nLisbon,POR,658236,2025-12-31\nAthens,GRC,643450,2024-01-01\nŁódź,POL,639890,2025-12-31\nPalermo,ITA,626273,2026-01-01\nDüsseldorf,GER,619444,2025-12-31\nVilnius,LTU,619405,2026-07-01\nGothenburg,SWE,614165,2026-06-30\nStuttgart,GER,612663,2024-12-31\nLeipzig,GER,611850,2024-12-31\nDortmund,GER,600880,2025-12-31\nMálaga,ESP,599063,2025-01-01\nDublin,IRL,592713,2022-04-03\nRiga,LVA,588911,2026-01-01\nBremen,GER,586271,2024-12-31\nEssen,GER,573618,2025-12-31\nAntwerp,BEL,572365,2026-07-01\nThe Hague,NLD,569293,2026-06-30\nGenoa,ITA,566247,2026-01-01\nDresden,GER,564904,2024-12-31\nPoznań,POL,534239,2025-12-31\nNuremberg,GER,531159,2025-12-31\nLyon,FRA,527236,2024-01-01\nToulouse,FRA,522662,2024-01-01\nHanover,GER,522131,2024-12-31\nDuisburg,GER,500810,2025-12-31\nGdańsk,POL,489328,2025-12-31\nBratislava,SVK,480947,2026-01-01\nMurcia,ESP,479405,2025-01-01\nTallinn,EST,452563,2026-01-01\nSintra,POR,449956,2025-12-31\nPalma de Mallorca,ESP,434786,2025-01-01\nBrno,CZE,404296,2026-01-01\nBologna,ITA,391473,2026-01-01\nSzczecin,POL,383786,2025-12-31\nLas Palmas,ESP,381868,2025-01-01\nUtrecht,NLD,378444,2026-06-30\nAarhus,DEN,378361,2026-01-01\nMalmö,SWE,368660,2026-06-30\nAlicante,ESP,366221,2025-01-01\nFlorence,ITA,361625,2026-01-01\nBochum,GER,358880,2025-12-31\nNice,FRA,358527,2024-01-01\nWuppertal,GER,357243,2025-12-31\nBilbao,ESP,351124,2025-01-01\nPlovdiv,BUL,333994,2025-12-31\nNantes,FRA,332411,2024-01-01\nBielefeld,GER,331419,2025-12-31\nVarna,BUL,331260,2025-12-31\nEspoo,FIN,328502,2026-07-01\nLublin,POL,326685,2025-12-31\nBonn,GER,323587,2025-12-31\nCórdoba,ESP,323262,2025-01-01\nVila Nova de Gaia,POR,323202,2025-12-31\nBydgoszcz,POL,321100,2025-12-31\nMannheim,GER,318035,2024-12-31\nBari,ITA,316248,2026-01-01\nMontpellier,FRA,312537,2024-01-01\nKarlsruhe,GER,309050,2024-12-31\nThessaloniki,GRC,307920,2024-01-01\nMünster,GER,306368,2025-12-31\nGraz,AUT,305314,2025-01-01\nKaunas,LTU,303613,2026-07-01\nLjubljana,SVN,302826,2026-01-01\nValladolid,ESP,302614,2025-01-01\nAugsburg,GER,301105,2024-12-31\n"
```

city, state (three-letter code), population within city limits, counted (the date of the
count). Wikipedia, "List of cities in the European Union by population within city limits",
read 8 Nov 2026.

### gtcars (proc) · [#datasets-gtcars](https://pietroppeter.github.io/tabelline/api/#datasets-gtcars)

```nim
proc gtcars(): TableData
```

47 deluxe automobiles from the 2014-2017 model years, with their performance and price
(gt's `gtcars`).

gt: `gtcars()`

### countrypops (proc) · [#datasets-countrypops](https://pietroppeter.github.io/tabelline/api/#datasets-countrypops)

```nim
proc countrypops(): TableData
```

The population of every country, every year from 1960 to 2022 (World Bank; gt's
`countrypops`).

gt: `countrypops()`

### illness (proc) · [#datasets-illness](https://pietroppeter.github.io/tabelline/api/#datasets-illness)

```nim
proc illness(): TableData
```

Daily tests of a patient with yellow fever, days 3 to 9, with their normal ranges (gt's
`illness`).

gt: `illness()`

### metro (proc) · [#datasets-metro](https://pietroppeter.github.io/tabelline/api/#datasets-metro)

```nim
proc metro(): TableData
```

The stations of the Paris Metro, with their lines and passengers in 2021 (gt's `metro`).

gt: `metro()`

### planets (proc) · [#datasets-planets](https://pietroppeter.github.io/tabelline/api/#datasets-planets)

```nim
proc planets(): TableData
```

tabelline's own (not in gt)

Example (spec table-parts):

```nim
let preview = tabellaPreview(planets(), topN = 2, bottomN = 1):
  colsHide ["mass", "diameter", "density", "gravity", "day_length", "distance", "orbital_period", "mean_temp"]
echo preview
```

```text
┌──────┬─────────┬─────────────┬───────┬───────┐
│      │ planet  │ type        │ moons │ rings │
╞══════╪═════════╪═════════════╪═══════╪═══════╡
│ 1    │ Mercury │ Terrestrial │     0 │ false │
│ 2    │ Venus   │ Terrestrial │     0 │ false │
│ 3..7 │         │             │       │       │
│ 8    │ Neptune │ Ice giant   │    16 │ true  │
└──────┴─────────┴─────────────┴───────┴───────┘
```

### exibble (proc) · [#datasets-exibble](https://pietroppeter.github.io/tabelline/api/#datasets-exibble)

```nim
proc exibble(): TableData
```

gt: `exibble()`

### isole (proc) · [#datasets-isole](https://pietroppeter.github.io/tabelline/api/#datasets-isole)

```nim
proc isole(): TableData
```

Example (spec table-data):

```nim
echo tabella(tavolaPitagorica(4), rownameCol = "×")
echo isole().nrows, " islands, ", citta().nrows, " cities; the largest: ", isole()["island", 0], ", ", citta()["city", 0]
```

```text
┌───┬───┬───┬────┬────┐
│   │ 1 │ 2 │  3 │  4 │
╞═══╪═══╪═══╪════╪════╡
│ 1 │ 1 │ 2 │  3 │  4 │
│ 2 │ 2 │ 4 │  6 │  8 │
│ 3 │ 3 │ 6 │  9 │ 12 │
│ 4 │ 4 │ 8 │ 12 │ 16 │
└───┴───┴───┴────┴────┘
194 islands, 95 cities; the largest: Sicily, Berlin
```

### citta (proc) · [#datasets-citta](https://pietroppeter.github.io/tabelline/api/#datasets-citta)

```nim
proc citta(): TableData
```

Example (spec table-data):

```nim
echo tabella(tavolaPitagorica(4), rownameCol = "×")
echo isole().nrows, " islands, ", citta().nrows, " cities; the largest: ", isole()["island", 0], ", ", citta()["city", 0]
```

```text
┌───┬───┬───┬────┬────┐
│   │ 1 │ 2 │  3 │  4 │
╞═══╪═══╪═══╪════╪════╡
│ 1 │ 1 │ 2 │  3 │  4 │
│ 2 │ 2 │ 4 │  6 │  8 │
│ 3 │ 3 │ 6 │  9 │ 12 │
│ 4 │ 4 │ 8 │ 12 │ 16 │
└───┴───┴───┴────┴────┘
194 islands, 95 cities; the largest: Sicily, Berlin
```

### tavolaPitagorica (proc) · [#datasets-tavolaPitagorica](https://pietroppeter.github.io/tabelline/api/#datasets-tavolaPitagorica)

```nim
proc tavolaPitagorica(n = 10): TableData
```

An n×n times table: a column `×` with 1..n, then one column per factor ("1" .. "n").

tabelline's own (not in gt)

Example (spec table-parts):

```nim
let t = tabella(tavolaPitagorica(2), rownameCol = "×"):
  colsLabelWith proc (s: string): string = "×" & s
echo t
```

```text
┌───┬────┬────┐
│   │ ×1 │ ×2 │
╞═══╪════╪════╡
│ 1 │  1 │  2 │
│ 2 │  2 │  4 │
└───┴────┴────┘
```

## In nimib (`tabelline/nimib`)

`import tabelline/nimib`: tables in a nimib notebook.

tabelline in nimib notebooks: `nbTable t` shows a table as a block of the page.

### NbTable (type) · [#nimib-NbTable](https://pietroppeter.github.io/tabelline/api/#nimib-NbTable)

```nim
NbTable = ref object of NbBlock
  html*: string
  markdown*: string
```

### newNbTable (proc) · [#nimib-newNbTable](https://pietroppeter.github.io/tabelline/api/#nimib-newNbTable)

```nim
proc newNbTable(html: string = default(typedesc[string]);
                markdown: string = default(typedesc[string])): NbTable
```

### nbtableToHtml (proc) · [#nimib-nbtableToHtml](https://pietroppeter.github.io/tabelline/api/#nimib-nbtableToHtml)

```nim
proc nbtableToHtml(blk: NbBlock; nb: Nb): string
```

### dump (method) · [#nimib-dump](https://pietroppeter.github.io/tabelline/api/#nimib-dump)

```nim
method dump(n`gensym5: NbTable): string
```

### nbTableToMd (func) · [#nimib-nbTableToMd](https://pietroppeter.github.io/tabelline/api/#nimib-nbTableToMd)

```nim
func nbTableToMd(blk: NbBlock; nb: Nb): string
```

### tableHtml (proc) · [#nimib-tableHtml](https://pietroppeter.github.io/tabelline/api/#nimib-tableHtml)

```nim
proc tableHtml(nb: var Nb; t: Tabella): string
```

The HTML of `t` for this page: with `tabellaCss` the first time on the page, without it
afterwards. For a block that puts a table inside its own HTML.

### table (proc) · [#nimib-table](https://pietroppeter.github.io/tabelline/api/#nimib-table)

```nim
proc table(nb: var Nb; t: Tabella)
```

Example (spec table-parts):

```nim
let t = tabella(tavolaPitagorica(3), rownameCol = "×"):
  tabHeader "Times table", "from 1 to 3"
  tabStubhead "×"
  tabSourceNote md("Learned **by heart**")
echo t
```

```text
   Times table
   from 1 to 3
┌───┬───┬───┬───┐
│ × │ 1 │ 2 │ 3 │
╞═══╪═══╪═══╪═══╡
│ 1 │ 1 │ 2 │ 3 │
│ 2 │ 2 │ 4 │ 6 │
│ 3 │ 3 │ 6 │ 9 │
└───┴───┴───┴───┘
Learned by heart
```

### nbTable (macro) · [#nimib-nbTable](https://pietroppeter.github.io/tabelline/api/#nimib-nbTable)

```nim
macro nbTable(args: varargs[untyped]): untyped
```

Adds a table to the page: `nbTable t` for a table `t`, and `nbTable data` for a table of
`data` as it is. With a body, `nbTable data: body` adds `tabella(data): body`, in one step,
without naming the table (the other arguments of `tabella`, such as `rownameCol`, go too):

```nim
nbTable planets(), rownameCol = "planet":
  tabHeader "Planets"
  fmtNumber "mass", decimals = 1
```
A body works on a table too: `nbTable t: tabHeader "Again"` adds `t` with a heading.
(A macro: written as a template, Nim would give the body to `nbTable`, not to `tabella`.)

tabelline's own (not in gt)

## From nanuq (`tabelline/nanuq`)

`import tabelline/nanuq`: a table from a nanuq (Polars) DataFrame.

tabelline/nanuq: a table straight from a `nanuq <https://github.com/pietroppeter/nanuq>`_ DataFrame (Polars for Nim).

### toTableData (proc) · [#nanuq-toTableData](https://pietroppeter.github.io/tabelline/api/#nanuq-toTableData)

```nim
proc toTableData(df: nq.DataFrame): TableData
```

Copies every column of `df`, in order: integers become ints, floats floats, booleans bools,
strings strings, a list of numbers, booleans or strings a list (a nanoplot's values), and
any other type (dates, durations, categories, structs) the text Polars writes for it. A null
becomes a missing value.

tabelline's own (not in gt)

### initTabella (proc) · [#nanuq-initTabella](https://pietroppeter.github.io/tabelline/api/#nanuq-initTabella)

```nim
proc initTabella(df: nq.DataFrame; rownameCol = ""; groupnameCol = ""; id = "";
                 locale = ""; autoAlign = true): Tabella
```

A display table for a nanuq DataFrame, so that `tabella(df): body` works as for any data.

