diff options
| author | Arun Isaac | 2026-04-10 01:07:42 +0100 |
|---|---|---|
| committer | Arun Isaac | 2026-04-10 01:07:42 +0100 |
| commit | 1a55558601d4dec073542ff42910413863e939cc (patch) | |
| tree | b9fcb24dc98dc35f83746040069665bb6aa71672 | |
| parent | 70abbe3b69a6474c62c162fa1ca65ef1e95417ff (diff) | |
| download | kaagum-1a55558601d4dec073542ff42910413863e939cc.tar.gz kaagum-1a55558601d4dec073542ff42910413863e939cc.tar.lz kaagum-1a55558601d4dec073542ff42910413863e939cc.zip | |
Add markdown table builder function.
| -rw-r--r-- | kaakaa/tea.scm | 17 |
1 files changed, 17 insertions, 0 deletions
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))) |
