Common lisp 使用:li时,通过html输出添加字符串

Common lisp 使用:li时,通过html输出添加字符串,common-lisp,sbcl,cl-who,Common Lisp,Sbcl,Cl Who,我正在使用Adam Tornhill的Lisp For The Web,我一直在生成一个包含li元素的html页面 (with-html-output (*standard-output* nil :prologue t :indent t) (htm (:li (:a :href "Link" "Vote!") ))) 当我编译它时,以下输出被打印到REPL (with-html-output (*standard-output* nil :prologu

我正在使用Adam Tornhill的Lisp For The Web,我一直在生成一个包含li元素的html页面

(with-html-output (*standard-output* nil :prologue t :indent t)
   (htm
       (:li (:a :href "Link" "Vote!")
        )))
当我编译它时,以下输出被打印到REPL

(with-html-output (*standard-output* nil :prologue t :indent t)
   (htm 
       (:li (:a :href "Link" "Vote!")
        )))
 <!DOCTYPE html>

<li>
  <a href='Link'>Vote!
  </a>
</li>
"
<li>
  <a href='Link'>Vote!
  </a>     
</li>"   

您首先看到的是表单在计算时打印到
*标准输出*
的内容。之后看到的字符串是表单的结果,由REPL打印。由于Hunchentoot处理程序只对输出流中的内容感兴趣,因此结果并不重要

要简单地将结果作为字符串获取,可以使用
和html输出到字符串

(with-html-output-to-string (str nil :prologue t :indent t)
  (htm 
   (:li (:a :href "Link" "Vote!"))))
另一方面,要抑制结果字符串并仅查看写出的文档,可以执行以下操作:

(progn
  (with-html-output (*standard-output* nil :prologue t :indent t)
    (htm 
     (:li (:a :href "Link" "Vote!"))))
  (values))

今天,当我再次尝试它时,由于某种原因它起了作用。感谢您对表单结果与输出流的解释。
(progn
  (with-html-output (*standard-output* nil :prologue t :indent t)
    (htm 
     (:li (:a :href "Link" "Vote!"))))
  (values))