[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: shared-text substrings

This page is part of the web mail archives of SRFI 13 from before July 7th, 2015. The new archives for SRFI 13 contain all messages, not just those from before July 7th, 2015.

As an aside, unrelated to SRFI-13:

> For what it's worth, I have a little Scheme-based html generation
> program (don't we all :)

Not any longer.  I grew tired of futzing with strings.  This is
Scheme, not Perl -- I don't want to use strings unless theyre
*essential*, and they sure aren't in this context.  Now I use the PLT
Scheme XML collection, and couldn't be happier.  Here's a random
excerpt from a program/document:

`(p ((align "CENTER"))
	(table ((style "font-size: x-large"))
	       (tr ()
		   (td ((align "RIGHT")) "Talks ")
		   (td ((align "CENTER")) " = ")
		   (td ((align "LEFT")) " slides + transitions"))
	       (tr ()
		   (td ())
		   (td ((align "CENTER")) " = ")
		   (td ((align "LEFT")) " data + control"))
	       (tr ()
		   (td ())
		   (td ((align "CENTER")) " = ")
		   (td ((align "LEFT")) " programs"))))

and another, to show that you really are getting the full power of
quasiquote here:

(define (generate-index-list slides)
  `(ul ()
       ,@(let loop ((slides slides)
                    (index first-slide-index))
           (if (empty? slides)
               (let ((a (first slides))
                     (d (rest slides)))
                 (if (content-slide? a)
                     (cons `(li ()
                                (a ((href ,(generate-filename index)))
                                   ,(slide-title a)))
                           (loop d (add1 index)))
                     (loop d (add1 index))))))))

You then pass this stylized s-expression to a procedure, and it
generates pristine HTML.  (There are some flags to control the
production of XML-style tags vs HTML-style tags when these differ on
matters such as closing tags.)

I find this format of writing HTML very visually appealing.  My
existing paren-matcher becomes an HTML tag-matcher, and so forth.  I
am happy.