From 277405e703dde048306c55ab564de0e1e7f78c16 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Wed, 2 Mar 2011 13:48:18 +0100 Subject: Skip single newlines after directives. --- json-template.lisp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/json-template.lisp b/json-template.lisp index 59e1265..237d627 100644 --- a/json-template.lisp +++ b/json-template.lisp @@ -31,6 +31,7 @@ (defun tokenize-template-string (string) (loop with in-command-p = nil + with skip-newline-p = nil with position = 0 for terminator = (position (if in-command-p #\} #\{) string :start position) @@ -38,8 +39,16 @@ (subseq string position (or terminator (length string)))) - do (setq position (and terminator (1+ terminator)) - in-command-p (not in-command-p)) + do (setq position (and terminator (1+ terminator))) + when (and skip-newline-p + position + (< position (length string)) + (char= (char string position) #\Newline)) + do (incf position) + do (setq in-command-p (not in-command-p) + skip-newline-p (and in-command-p + position + (char= (char string position) #\.))) until (null terminator))) (defun parse-template-string (stream) -- cgit v1.2.3