RosettaCodeData/Task/Create-an-HTML-table/EchoLisp/create-an-html-table-1.l

26 lines
864 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
;; styles -
(style 'td "text-align:right")
(style 'table "border-spacing: 10px;border:1px solid red")
(style 'th "color:blue;")
;; generic html5 builder
;; pushes <tag style=..> (proc content) </tag>
(define (emit-tag tag html-proc content )
2026-02-01 16:33:20 -08:00
(if (style tag)
(push html (format "<%s style='%a'>" tag (style tag)))
(push html (format "<%s>" tag )))
(html-proc content)
(push html (format "</%s> " tag )))
2023-07-01 11:58:00 -04:00
;; html procs : 1 tag, 1 proc
(define (h-raw content)
2026-02-01 16:33:20 -08:00
(push html (format "%s" content)))
2023-07-01 11:58:00 -04:00
(define (h-header headers)
2026-02-01 16:33:20 -08:00
(for ((h headers)) (emit-tag 'th h-raw h)))
2023-07-01 11:58:00 -04:00
(define (h-row row)
2026-02-01 16:33:20 -08:00
(for ((item row)) (emit-tag 'td h-raw item)))
2023-07-01 11:58:00 -04:00
(define (h-table table )
2026-02-01 16:33:20 -08:00
(emit-tag 'tr h-header (first table))
;; add row-num i at head of row
(for ((i 1000)(row (rest table))) (emit-tag 'tr h-row (cons i row))))