From 4804d2f84caf4810fe6b2b4bb21829c288cab8c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Pant=C5=AF=C4=8Dek?= Date: Thu, 23 Mar 2023 20:09:46 +0100 Subject: [PATCH] Finish table documentation. --- MODULES.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/MODULES.md b/MODULES.md index 20ac354..e0db6d1 100644 --- a/MODULES.md +++ b/MODULES.md @@ -621,6 +621,7 @@ substituted. [#:border-style (*table-border-style*)] [#:ansi #f]) +* ```tbl``` - list of lists with cell data * ```#:table-border``` - if ```#t```, the table has outer border * ```#:row-border``` - if ```#t```, the rows are separated by borders * ```#:col-border``` - if ```#t```, the columns are separated by borders @@ -629,3 +630,26 @@ substituted. * ```#:ansi``` - if ```#t```, all cell line strings are terminated with ```a:default``` +The table ```tbl``` is represented as a list of rows where each row is +a list of cells that hold arbitrary values that are converted to +string when rendering the table. + +Before rendering the table, the following steps are performed: + +* The table is made rectangular - that is all rows are extended by + empty strings to have the same length. +* All non-string cells are converted to string using ```sprintf``` +* All cells are split into list of strings representing the lines of + text inside them. +* For each row, all cells are extended by empty strings to have + matching number of lines of text inside them. +* For each column, all lines of text inside all of the cells are + padded with spaces to have uniform width. + +Then each table row is converted to list of strings adding column +separators and table borders as required. These lists are then joined +with row separators and possibly prefixed and suffixed by top and +bottom table border. + +The resulting list of strings is joined with newline character as the +separator.