aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2023-05-28 21:09:45 -0700
committerKaz Kylheku <kaz@kylheku.com>2023-05-28 21:09:45 -0700
commit3fccacf506c6d2ee58c3083dd509020e53e14c2d (patch)
tree974624794c86cd855ae03fe54b5295c72e1a30af
parent8b08528f6a597a298ca1d6a20f23a8823b88db59 (diff)
downloadtl-who-3fccacf506c6d2ee58c3083dd509020e53e14c2d.tar.gz
tl-who-3fccacf506c6d2ee58c3083dd509020e53e14c2d.tar.bz2
tl-who-3fccacf506c6d2ee58c3083dd509020e53e14c2d.zip
Fix attribute bugs: tests 1 to 7 working.
* who.tl (convert-attributes): In the run-time case, we must generate code to print the calculated string, not just to calculate it. (convert-tag-to-string-list): Test the original tag keyword against the *html-empty-tags*, not the transformed string. * test/simple.tl: Port and enable tests 1 to 7.
-rw-r--r--test/simple.tl74
-rw-r--r--who.tl16
2 files changed, 46 insertions, 44 deletions
diff --git a/test/simple.tl b/test/simple.tl
index 1100f25..17dfd87 100644
--- a/test/simple.tl
+++ b/test/simple.tl
@@ -26,60 +26,62 @@
:br))))
"<a href='http://zappa.com/'><b>Frank Zappa</b></a><br /><a href='http://marcusmiller.com/'><b>Marcus Miller</b></a><br /><a href='http://www.milesdavis.com/'><b>Miles Davis</b></a><br />")
-(exit)
-
;;; 2
-(string= (with-output-to-string (out)
- (with-html-output (out nil)
- (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa")
- ("http://marcusmiller.com/" . "Marcus Miller")
- ("http://www.milesdavis.com/" . "Miles Davis"))
- do (htm (:a :href link
- (:b (str title)))
- :br))))
+(test (with-out-string-stream (out)
+ (with-html-output (out nil)
+ (keep-matches ((@link . @title) '(("http://zappa.com/" . "Frank Zappa")
+ ("http://marcusmiller.com/" . "Marcus Miller")
+ ("http://www.milesdavis.com/" . "Miles Davis")))
+ (htm (:a :href link
+ (:b (str title)))
+ :br))))
"<a href='http://zappa.com/'><b>Frank Zappa</b></a><br /><a href='http://marcusmiller.com/'><b>Marcus Miller</b></a><br /><a href='http://www.milesdavis.com/'><b>Miles Davis</b></a><br />")
;;; 3
-(string= (with-output-to-string (foo)
- (with-html-output (out foo)
- (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa")
- ("http://marcusmiller.com/" . "Marcus Miller")
- ("http://www.milesdavis.com/" . "Miles Davis"))
- do (htm (:a :href link
- (:b (str title)))
- :br))))
+(test (with-out-string-stream (foo)
+ (with-html-output (out foo)
+ (keep-matches ((@link . @title) '(("http://zappa.com/" . "Frank Zappa")
+ ("http://marcusmiller.com/" . "Marcus Miller")
+ ("http://www.milesdavis.com/" . "Miles Davis")))
+ (htm (:a :href link
+ (:b (str title)))
+ :br))))
"<a href='http://zappa.com/'><b>Frank Zappa</b></a><br /><a href='http://marcusmiller.com/'><b>Marcus Miller</b></a><br /><a href='http://www.milesdavis.com/'><b>Miles Davis</b></a><br />")
;;; 4
-(string= (with-html-output-to-string (out)
- (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa")
+(test (with-html-output-to-string (out)
+ (keep-matches ((@link . @title) '(("http://zappa.com/" . "Frank Zappa")
("http://marcusmiller.com/" . "Marcus Miller")
- ("http://www.milesdavis.com/" . "Miles Davis"))
- do (htm (:a :href link
- (:b (str title)))
- :br)))
+ ("http://www.milesdavis.com/" . "Miles Davis")))
+ (htm (:a :href link
+ (:b (str title)))
+ :br)))
"<a href='http://zappa.com/'><b>Frank Zappa</b></a><br /><a href='http://marcusmiller.com/'><b>Marcus Miller</b></a><br /><a href='http://www.milesdavis.com/'><b>Miles Davis</b></a><br />")
;;; 5
-(string= (with-html-output-to-string (out nil)
- (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa")
+(test (with-html-output-to-string (out nil)
+ (keep-matches ((@link . @title) '(("http://zappa.com/" . "Frank Zappa")
("http://marcusmiller.com/" . "Marcus Miller")
- ("http://www.milesdavis.com/" . "Miles Davis"))
- do (htm (:a :href link
- (:b (str title)))
- :br)))
+ ("http://www.milesdavis.com/" . "Miles Davis")))
+ (htm (:a :href link
+ (:b (str title)))
+ :br)))
"<a href='http://zappa.com/'><b>Frank Zappa</b></a><br /><a href='http://marcusmiller.com/'><b>Marcus Miller</b></a><br /><a href='http://www.milesdavis.com/'><b>Miles Davis</b></a><br />")
;;; 6
-(string= (with-html-output-to-string (out nil :prologue nil)
- (loop for (link . title) in '(("http://zappa.com/" . "Frank Zappa")
+(test (with-html-output-to-string (out nil :prologue nil)
+ (keep-matches ((@link . @title) '(("http://zappa.com/" . "Frank Zappa")
("http://marcusmiller.com/" . "Marcus Miller")
- ("http://www.milesdavis.com/" . "Miles Davis"))
- do (htm (:a :href link
- (:b (str title)))
- :br)))
+ ("http://www.milesdavis.com/" . "Miles Davis")))
+ (htm (:a :href link
+ (:b (str title)))
+ :br)))
"<a href='http://zappa.com/'><b>Frank Zappa</b></a><br /><a href='http://marcusmiller.com/'><b>Marcus Miller</b></a><br /><a href='http://www.milesdavis.com/'><b>Miles Davis</b></a><br />")
+(exit)
+
+
+
;;; 7
(eq (array-element-type
(with-html-output-to-string (out nil :element-type 'base-char)
diff --git a/who.tl b/who.tl
index 0449b86..79b8e25 100644
--- a/who.tl
+++ b/who.tl
@@ -107,11 +107,11 @@
(cond
((null ,=var=))
((eq ,=var= t)
- ,(if *empty-attribute-syntax*
- ` @attr`
- ` @attr=@aqc@attr@aqc`))
+ (str ,(if *empty-attribute-syntax*
+ ^` @,attr`
+ ^` @,attr=@,aqc@,attr@,aqc`)))
(t
- ` @,attr=@,aqc@{,=var=}@,aqc`))))))))))
+ (str ` @,attr=@,aqc@{,=var=}@,aqc`)))))))))))
;; Used by process-tag to convert `HTML' into a list
@@ -124,11 +124,11 @@
;; In CL-WHO, this is a generic function where the idea is that
;; you can use EQL specializers on the first argument to create
;; custom handling for different tags.
-(defun convert-tag-to-string-list (tag attr-list body body-fn)
- (let ((tag (maybe-upcase tag))
+(defun convert-tag-to-string-list (tag-kw attr-list body body-fn)
+ (let ((tag (maybe-upcase tag-kw))
(body-indent
;; increase *indent* by 2 for body -- or disable it
- (when (and *indent* (not (member tag *html-no-indent-tags*)))
+ (when (and *indent* (not (member tag-kw *html-no-indent-tags*)))
(ssucc *indent*))))
(nconc
(if *indent*
@@ -152,7 +152,7 @@
(list "</" tag ">"))
;; no body, so no closing tag unless defined in *html-empty-tags*
(if (or (not *html-empty-tag-aware-p*)
- (member tag *html-empty-tags*))
+ (member tag-kw *html-empty-tags*))
(list *empty-tag-end*)
(list ">" "</" tag ">"))))))