From 9078ffa62e030f4419cd465ee604da81750da11b Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Mon, 9 Apr 2012 12:08:33 +0300 Subject: fix unportable tests Previously the tests implicitly assumed that EVAL does macroexpansion at runtime -- which is legal, but not required. Add explicit EVAL calls to tests requiring that. --- test/simple | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/simple b/test/simple index 6fa48e5..96686a1 100644 --- a/test/simple +++ b/test/simple @@ -105,8 +105,8 @@ ;;; 11 (string= (let ((*prologue* "")) - (with-html-output-to-string (out nil :prologue t) - (:apply (:factorial) (:cn "3")))) + (eval `(with-html-output-to-string (out nil :prologue t) + (:apply (:factorial) (:cn "3"))))) " 3") @@ -231,16 +231,16 @@ "

") ;;; 19 -(string= (let ((*html-empty-tag-aware-p* nil)) - (with-html-output-to-string (out) - (:p))) +(string= (let ((cl-who:*html-empty-tag-aware-p* nil)) + (eval `(with-html-output-to-string (out) + (:p)))) "

") ;;; 20 (string= (let ((*html-empty-tag-aware-p* t) (*html-empty-tags* '(:p))) - (with-html-output-to-string (out) - (:p))) + (eval `(with-html-output-to-string (out) + (:p)))) "

") ;;; 21 @@ -250,8 +250,8 @@ ;;; 22 (string= (let ((*downcase-tokens-p* nil)) - (with-html-output-to-string (out) - (:|Foo| :bar 42))) + (eval `(with-html-output-to-string (out) + (:|Foo| :bar 42)))) "") ;;; 23 -- cgit v1.2.3 From a4c3fca7153bba629c4f5c95ae68e1453afb0ed9 Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Mon, 9 Apr 2012 12:11:02 +0300 Subject: *HTML-NO-INDENT-TAGS* Tags in this list don't have their body indented even if *INDENT* is true.

 in particular is indentation sensitive, and it's irritating
  when rendering changes as :indent is flipped.
---
 packages.lisp |  1 +
 specials.lisp |  4 ++++
 test/simple   | 33 ++++++++++++++++++++++++++++++++-
 who.lisp      | 15 ++++++++-------
 4 files changed, 45 insertions(+), 8 deletions(-)

diff --git a/packages.lisp b/packages.lisp
index 89d56de..752545e 100644
--- a/packages.lisp
+++ b/packages.lisp
@@ -37,6 +37,7 @@
            :*escape-char-p*
            :*prologue*
            :*downcase-tokens-p*
+           :*html-no-indent-tags*
            :*html-empty-tags*
            :*html-empty-tag-aware-p*
            :conc
diff --git a/specials.lisp b/specials.lisp
index 349c7fc..c731a78 100755
--- a/specials.lisp
+++ b/specials.lisp
@@ -64,6 +64,10 @@ needs to output case sensitive XML.")
 (defvar *empty-tag-end* " />"
   "End of an empty tag.  Default is XML style.")
 
+(defvar *html-no-indent-tags*
+  '(:pre)
+  "List of HTML tags that disable indentation inside them. Default list containts only :PRE.")
+
 (defvar *html-empty-tags*
   '(:area
     :atop
diff --git a/test/simple b/test/simple
index 96686a1..c952fa0 100644
--- a/test/simple
+++ b/test/simple
@@ -260,4 +260,35 @@
            (with-html-output (var (pop list))
              (progn (htm (:br))))
            (get-output-stream-string stream))
-         "
") \ No newline at end of file + "
") + +;;; 24 +(string= (with-html-output-to-string (out) + (:div (:pre "Foo"))) + "
Foo
") + +;;; 25 +(string= (with-html-output-to-string (out nil :indent t) + (:div (:pre "Foo"))) + " +
+
Foo
+
") + +;;; 26 +(string= (with-html-output-to-string (out nil :indent t) + (:div (:p "Bar"))) + " +
+

Bar +

+
") + +;;; 27 +(string= (let ((*html-no-indent-tags* (cons :p *html-no-indent-tags*))) + (eval `(with-html-output-to-string (out nil :indent t) + (:div (:p "Bar"))))) + " +
+

Bar

+
") diff --git a/who.lisp b/who.lisp index f6dea56..0c1cd19 100644 --- a/who.lisp +++ b/who.lisp @@ -144,7 +144,11 @@ a list of strings or Lisp forms.")) "The standard method which is not specialized. The idea is that you can use EQL specializers on the first argument." (declare (optimize speed space)) - (let ((tag (if *downcase-tokens-p* (string-downcase tag) (string tag)))) + (let ((tag (if *downcase-tokens-p* (string-downcase tag) (string tag))) + (body-indent + ;; increase *INDENT* by 2 for body -- or disable it + (when (and *indent* (not (member tag *html-no-indent-tags* :test #'string-equal))) + (+ 2 *indent*)))) (nconc (if *indent* ;; indent by *INDENT* spaces @@ -157,13 +161,10 @@ can use EQL specializers on the first argument." (if body (append (list ">") - ;; now hand over the tag's body to TREE-TO-TEMPLATE, increase - ;; *INDENT* by 2 if necessary - (if *indent* - (let ((*indent* (+ 2 *indent*))) - (funcall body-fn body)) + ;; now hand over the tag's body to TREE-TO-TEMPLATE + (let ((*indent* body-indent)) (funcall body-fn body)) - (if *indent* + (when body-indent ;; indentation (list +newline+ (n-spaces *indent*))) ;; closing tag -- cgit v1.2.3 From 4618609f71498a6909b39d2c87ea5d26ea68cfb0 Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Mon, 9 Apr 2012 12:02:32 +0300 Subject: lock the package on SBCL Package locks are increasingly useful in the brave new QuickLisp era. --- packages.lisp | 1 + 1 file changed, 1 insertion(+) diff --git a/packages.lisp b/packages.lisp index 752545e..5ea0159 100644 --- a/packages.lisp +++ b/packages.lisp @@ -33,6 +33,7 @@ (:use :cl) (:nicknames :who) #+:sbcl (:shadow :defconstant) + #+:sb-package-locks (:lock t) (:export :*attribute-quote-char* :*escape-char-p* :*prologue* -- cgit v1.2.3