Since classes and ids are pretty common it could shorten a lot of calls to tag. arc> (tag (a class "foo"))
<a class="foo"></a>
becomes arc> (tag a.foo)
<a class="foo"></a>
likewise: arc> (tag (a id "foo" href "http://foo.com"))
<a id=foo href="http://foo.com"></a>
arc> (tag (a#foo href "http://foo.com"))
<a id=foo href="http://foo.com"></a>
I gave it a shot (def decssize-spec (spec)
(let tname (coerce (carif spec) 'string)
(with (first# (findsubseq "#" tname) first. (findsubseq "." tname))
(if (or first# first.)
(with (new-tname (subseq tname 0 (or first# first.))
opt-pair (if first#
`(id ,(subseq tname (+ 1 first#)))
`(class ,(subseq tname (+ 1 first.)))))
(if (atom spec)
(flat (list new-tname opt-pair))
(flat (list new-tname opt-pair (cdr spec)))))
spec))))
(mac tag (spec . body)
(let spec (decssize-spec spec)
`(do ,(start-tag spec)
,@body
,(end-tag spec))))
I'm pretty new to lisp, any tips to make it cleaner or more idiomatic would be nice. I guess next up would be stringing multiple classes and ids together like a#foo.bar.bat |