Subject: Re: Looking for a beter Text and HTML Lisp syntax
From: (Rob Warnock)
Date: Tue, 30 Sep 2003 04:17:44 -0500
Newsgroups: comp.lang.lisp
Message-ID: <>
Marc Battyani <> wrote:
| The problem when representing text and HTML in sexpr is how
| to differenciate attributes from content for the text elements.
| There are 5 ways that seem natural:
| 1) An arg list enclosing the element name:
| ((table :padding 5 :backgound-color 10) ... content...)))
| The classical LHTML representation
| 2) An arg list after the element name:
| (table (:padding 5 :backgound-color 10) ...content...)

Tim Bradshaw's HTOUT lets you choose between these two semi-dynamically.
[That is, for any given instance of WITH-HTML-OUTPUT you can choose which
style the body of the macro expects.]

| 3) A separator between args and content
| (table :padding 5 :backgound-color 10 :content ...content...)
| (the separator can be made more simple like | with a read macro
| (Tim Bradshaw uses <table :padding... | ...content...>)

What he calls "TML", I think. Note that in TML the content doesn't need
to be string-quoted (unlike the other four styles), though < and | and >
do need to be escaped to include them in content.

| Other ones ?

I've played with several others, but none were better than your #1-4.
But for the record:

6) Attributes only exist if some magic marker that cannot appear in
   normal content introduces [and possibly terminates] them, e.g.:
        (:table ...content...)
        (:table (:@ :padding 5 :background-color 10) ...content...)
        (:table :@ :padding 5 :background-color 10 ...content...)
        (:table :@ :padding 5 :background-color 10 :@ ...content...)

7) [Really ugly:] Wrap attributes, if any, *around* the thing being
	(:@ :padding 5 :background-color 10 (:table ...content...))
	(:@ :padding 5 (:@ :background-color 10 (:table ...content...)))

   or around the content:
	(:table (:@ :padding 5 (:@ :background-color 10 ...content...)))

As I said, all worse than #1-4.


p.s. One thing to consider when choosing a style is how to intermingle
Lisp code for dynamic generation, which is why HTOUT uses keywords
for HTML tags, i.e.:

	(:table (:padding 5 :background-color 10) ...content...)

Any S-expr with a non-keyword in functional position is taken to be
Lisp executable code which can output [or return, depending on your
infrastructure's style] a sub-element, e.g.:

	(:table (:padding 5 :background-color 10)
          (loop for row in rows do
            (htm (:tr (:align "right")
                   (loop for column in row do
                     (htm (:td (:nowrap) (esc column))))))))

Rob Warnock, PP-ASEL-IA		<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607