From 1a55558601d4dec073542ff42910413863e939cc Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Fri, 10 Apr 2026 01:07:42 +0100 Subject: Add markdown table builder function. --- kaakaa/tea.scm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/kaakaa/tea.scm b/kaakaa/tea.scm index a4cf250..b7eaadc 100644 --- a/kaakaa/tea.scm +++ b/kaakaa/tea.scm @@ -197,6 +197,23 @@ in @var{state}." (focus (state-cwd session-id) state))))))) +(define (markdown-table lines) + "Return a markdown table built from @var{lines}. Each line is a list of strings, +each string the contents of a cell. The first line is considered the header of +the table." + (define (cells->line cells) + (string-append "| " + (string-join cells " | ") + " |")) + + (match lines + ((header other-lines ...) + (string-join (cons* (cells->line header) + (cells->line (make-list (length header) "---")) + (map cells->line + other-lines)) + "\n")))) + (define %commands `(("cwd" . ,%cwd-command))) -- cgit 1.4.1