Output Formats

Gridwell renders the table IR to 11 output formats, split into text (returns a string) and binary (returns bytes). Which styling features each Tier-1 writer (HTML, LaTeX, Typst, RTF, DOCX, XLSX) actually expresses is measured, not claimed: see the Feature Matrix.

Text Formats

HTML

  • Semantic HTML5 with <table>, <thead>, <tbody>, <tfoot>
  • A fragment for a host page, styled like gt by default: the <style> block starts with a base stylesheet (system font, the rules above and below the table and around the column labels, spanner and row-group rules, the stub’s border, footnote and source-note sizes, padding), then the table’s own styles. The base rules use :where(), which has zero specificity, so the table’s styles and the host page’s CSS always override them. base_styles: false leaves only the table’s own styles. With inline_styles there is no <style> block, so no base look either.
  • standalone: true wraps the fragment in a complete UTF-8 document (doctype, charset, viewport, a <title> from the table’s title), for a file opened directly in a browser. Saved .html files are fragments unless you pass it.
  • Scoped <style> block with generated class names
  • Optional inline-style mode for email/embedded contexts
  • Footnote marks as <sup> linked to footer
  • Accessibility: scope, aria-label, <caption>
  • Class names for each structural part (below)

Every structural part has a class, so a stylesheet (the host page’s) can target it. The prefix is gw unless the class_prefix option changes it, and the classes are emitted with inline styles too.

Class Element Part
gw_container <div> Wraps the whole table
gw_title, gw_subtitle, gw_header_line <div> Heading lines above the table
gw_table <table> The table
gw_col_labels, gw_spanners <tr> in <thead> Column-label and spanner rows (a head row without a role counts as column labels)
gw_col_label, gw_spanner <th> Column labels; spanner labels (filler cells in a spanner row get no class)
gw_stubhead, gw_stub <th>, <td> Stub column cells in the head and in the body
gw_group_label <td> A row group’s label
gw_summary, gw_grand_summary <tr> Summary and grand summary rows
gw_footer, gw_footnotes, gw_source_notes <div> The footer and its two blocks
gw_footnote, gw_source_note <p> One footnote or source note
gw_footnote_mark <sup> A footnote mark, in a cell or before its footnote

Style classes are added alongside these as gw_style-<style id> (e.g. class="gw_title gw_style-gw_1"). That namespace can’t meet the part classes, so a style named title styles only what references it, not the title. Generated classes use a double underscore (gw__al_left, gw__c0). Style ids are plain names (the INVALID_STYLE_ID rule), and the writer never puts any other id into markup: given unvalidated IR, it gives such a style a generated gw__s<n> class instead.

LaTeX

  • Uses booktabs (\toprule, \midrule, \bottomrule); a column spanner is underlined with \cmidrule over its columns (\cline without booktabs)
  • \multicolumn and \multirow for spans
  • Column alignment via l, r, c, p{width}
  • Cell fills via \cellcolor, text color via \textcolor; underline and strike-through via \uline / \sout; sizes via \fontsize
  • Required packages: booktabs, multirow, longtable (long tables), xcolor with the table option, and ulem with normalem (\usepackage[normalem]{ulem}, so \emph keeps its meaning)
  • Special characters escaped: & % $ # _ { } ~ ^ \
  • vertical_align is not written: a tabular row sets its cells on one baseline

Typst

  • Uses Typst’s #table() function with named parameters
  • table.cell(colspan: N, rowspan: N) for spans
  • Column widths mapped to Typst length values
  • Styles via table.cell(fill: ...), text(weight: "bold")
  • Cell borders via table.cell(stroke: ...), solid, dashed or dotted (Typst has no double line: a double border is drawn solid)
  • Vertical alignment with the cell’s horizontal one (align: left + bottom)

RTF

  • Full RTF document with color and font tables
  • Column spans via \cellx boundaries, row spans via \clvmgf/\clvmrg
  • Column widths in twips (1/1440 inch)
  • Cell fills via \clcbpat; cell borders via \clbrdrt/\clbrdrl/\clbrdrb/\clbrdrr (solid, dashed, dotted, double; no table-wide rules)
  • Vertical alignment via \clvertalt/\clvertalc/\clvertalb

SVG

  • Standalone SVG image, self-contained (no external dependencies)
  • The same default look as HTML (gt’s rules, padding, sizes and text color, from one shared spec), drawn by gridwell’s own layout: the table’s styles (fills, bold, colors, cell borders and padding) still win
  • Text laid out with Roboto’s real widths (cells leave room for Arial-compatible fallbacks), and every line drawn with textLength, so viewers that substitute another font keep the layout. librsvg ignores textLength, so rsvg-based tools (Pandoc/Quarto PDF, R’s rsvg) render best with Roboto installed
  • Body cells are vertically centered and head cells bottom-aligned, as in HTML, unless a style’s vertical_align says otherwise
  • Known differences from HTML: a word too long for a fixed-width column is broken inside the column (HTML widens the column), and max_width always clamps

ANSI (Terminal)

  • Box-drawing characters for borders (Unicode); rules run unbroken over and under cells that span columns
  • Footnote marks as Unicode superscripts, in cells and in the notes below
  • 24-bit ANSI color sequences
  • Column widths computed from content
  • Text truncation with ellipsis for overflow
  • Saved to a file (.txt), it is plain text with no escape codes unless the color option is set

Pandoc

  • Pandoc JSON AST format (Table constructor)
  • Supports all inline formatting (Strong, Emph, Superscript, etc.)
  • Usable with pandoc -f json -t docx/pdf/epub/...

Quarto

  • The Pandoc JSON AST, as for the Pandoc format, for Quarto’s Pandoc-based pipeline
  • Optionally wrapped in a tbl-<id> div for cross-references (table_id option)

Binary Formats

DOCX (Microsoft Word)

  • Valid Office Open XML archive (ZIP)
  • Table in word/document.xml
  • Horizontal merge via <w:gridSpan>, vertical via <w:vMerge>
  • Bold, italic, color, size, shading and alignment (font family is not written yet)
  • Table-wide single grid lines; a cell’s own borders (<w:tcBorders>: solid, dashed, dotted, double) replace them on the sides it sets
  • Vertical alignment via <w:vAlign>, on every piece of a vertically merged cell

XLSX (Microsoft Excel)

  • SpreadsheetML format
  • Cells preserve typed values (numbers stay numeric), with a number format that shows them as the table does (0.0 for 76.0, #,##0 for 1,250). A typed cell whose display is not a plain number (<0.001, a footnote mark) stays text.
  • Merge regions via <mergeCells>
  • Styles in xl/styles.xml (fonts, fills, borders, number formats); rich text where a cell mixes formatting, in the shared-string table (apps such as Numbers ignore run formatting in inline strings)
  • Cells with line breaks wrap, and rows are tall enough for their lines and font sizes
  • Vertical alignment via the vertical attribute (Excel’s own default is bottom)

PPTX (Microsoft PowerPoint)

  • DrawingML table (<a:tbl>) in a slide shape
  • Grid-based spans with gridSpan/rowSpan attributes
  • Text color, weight, slant and size, cell fills and alignment
  • Cell borders as lnL/lnR/lnT/lnB lines (solid, dashed, dotted, double)
  • Vertical alignment via the cell’s anchor
  • A complete package (theme, master color map, notes size), so PowerPoint and Keynote open it