Re: shared-text substrings
Shriram Krishnamurthi 08 Feb 2000 17:46 UTC
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)
empty
(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.
'shriram