[Lisppaste-cvs] CVS update: lisppaste2/encode-for-pre.lisp
Brian Mastenbrook
bmastenbrook at common-lisp.net
Thu Jun 24 19:48:04 UTC 2004
Update of /project/lisppaste/cvsroot/lisppaste2
In directory common-lisp.net:/home/bmastenbrook/lisppaste2
Modified Files:
encode-for-pre.lisp
Log Message:
more beginning-of-line damage
Date: Thu Jun 24 12:48:04 2004
Author: bmastenbrook
Index: lisppaste2/encode-for-pre.lisp
diff -u lisppaste2/encode-for-pre.lisp:1.17 lisppaste2/encode-for-pre.lisp:1.18
--- lisppaste2/encode-for-pre.lisp:1.17 Tue Jun 8 08:20:40 2004
+++ lisppaste2/encode-for-pre.lisp Thu Jun 24 12:48:04 2004
@@ -1,4 +1,4 @@
-;;;; $Id: encode-for-pre.lisp,v 1.17 2004/06/08 15:20:40 bmastenbrook Exp $
+;;;; $Id: encode-for-pre.lisp,v 1.18 2004/06/24 19:48:04 bmastenbrook Exp $
;;;; $Source: /project/lisppaste/cvsroot/lisppaste2/encode-for-pre.lisp,v $
;;;; See the LICENSE file for licensing information.
@@ -10,13 +10,16 @@
(defun encode-for-tt (string &key with-line-numbers first-char-nbsp)
(let ((pos 0) (end (length string))
- (char nil))
+ (char nil) (last-was-newline nil))
(flet ((next-char ()
- (setf char (when (> end pos)
- (prog1
- (schar string pos)
- (incf pos))))))
- (with-output-to-string (out)
+ (prog1
+ (setf char (when (> end pos)
+ (prog1
+ (schar string pos)
+ (incf pos))))
+ (when char (setf last-was-newline (eql char #\newline))))))
+ (values
+ (with-output-to-string (out)
(block nil
(tagbody
(unless first-char-nbsp
@@ -32,9 +35,9 @@
((nil) (return))
((#\Newline)
(write-string "<br>" out)
- (if with-line-numbers
- (write-string (funcall with-line-numbers) out))
- (go escape-spaces))
+ (when with-line-numbers
+ (write-string (funcall with-line-numbers) out))
+ (go escape-spaces))
((#\&)
(write-string "&" out))
((#\<)
@@ -50,7 +53,8 @@
(t
(write-char char out)))
(next-char)
- (go process-char)))))))
+ (go process-char))))
+ last-was-newline))))
(defun encode-for-pre (string)
More information about the Lisppaste-cvs
mailing list