module Riffer::Rig::Terminal::Markdown::Table
Constants
- CELL
-
GFM splits at a pipe inside a code span, but models rarely escape one there, so a code span keeps its pipes. A tick run with no closer is matched whole, so a later tick in it opens no span.
- DIVIDER
- LABEL_SEPARATOR
- MIN_COLUMN_WIDTH
-
Narrower than this a column breaks most words apart.
- UNPAINTED
-
Columnscan’t measure a link’s escapes, so a cell is padded by the width of its unpainted twin. - WIDTH_LIMIT
-
Rows are padded to the grid’s width, so with no terminal width to wrap to one long cell would pad every other row to its length.
Public Instance Methods
(Array[String] chunk, theme: Riffer::Rig::Terminal::Theme, width: Integer?) → Array[String]
Source
# File lib/riffer/rig/terminal/markdown/table.rb, line 30 def lines(chunk, theme:, width:) grid = grid(chunk, theme) room = width && width < WIDTH_LIMIT ? width : WIDTH_LIMIT columns = grid.transpose natural = columns.map { |column| column.map { |spans| cell_width(spans) }.max.to_i } words = columns.map { |column| column.flat_map { |spans| word_widths(spans) }.max.to_i } widths = fit(natural, words, room) widths ? layout(grid, widths, theme) : records(grid, theme, room) end
@rbs chunk: Array @rbs theme: Riffer::Rig::Terminal::Theme @rbs width: Integer? @rbs return: Array