From cadca16bf478383ff4681ffbefe379fcbf1328fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Wed, 24 Oct 2018 17:11:06 +0200 Subject: Add display code for generating HTML table. --- display.scm | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 display.scm (limited to 'display.scm') diff --git a/display.scm b/display.scm new file mode 100755 index 0000000..6a2fade --- /dev/null +++ b/display.scm @@ -0,0 +1,26 @@ +#!/usr/bin/guile \ +-e main -s +!# + +(add-to-load-path (dirname (current-filename))) +(add-to-load-path (string-append (getenv "HOME") + "/lib/guile")) + + +(use-modules (parse) + (sxml simple)) + +(define (build-table csv) + `(table (@ (border 1)) + (tr (th "Title") (th "Author")) + ,@(map (lambda (i) + `(tr (td ,(csv-ref csv 'title i)) + (td ,(csv-ref csv 'author_details i)))) + (iota (csv-length csv)))) ) + +(define (main args) + (let ((csv (load-csv* "boklista.csv"))) + (sxml->xml + `(html (head (title "Boklista")) + (body + ,(build-table csv)))))) -- cgit v1.2.3