diff --git a/Makefile b/Makefile index ceca422..d091fd4 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ serve: - sbcl --eval "(ql:quickload :html-conv)" \ - --eval "(asdf:load-system :html-conv)" \ - --eval "(html-conv::main)" + sbcl --eval "(ql:quickload :html2clwho)" \ + --eval "(asdf:load-system :html2clwho)" \ + --eval "(html2clwho::main)" diff --git a/html2clwho.lisp b/html2clwho.lisp index 4572042..a215cd0 100644 --- a/html2clwho.lisp +++ b/html2clwho.lisp @@ -9,8 +9,10 @@ ((text-node-p root) (let ((txt (string-trim '(#\Space #\Newline #\Backspace #\Tab #\Linefeed #\Page #\Return #\Rubout) - (text root)))) + (render-text root)))) (if (equal txt "") "" (format nil " \"~A\"" txt)))) + ((comment-p root) + (format nil " #|~A|#" (build-sexp (render-text root)))) (t (let ((attrs (attributes root))) (format nil "~%(:~A~:{ :~A \"~A\"~}~{~A~})" @@ -19,7 +21,9 @@ for value being the hash-value of attrs collect (list key value)) (map 'list #'iter (children root)))))))) - (apply #'concatenate (cons 'string (map 'list #'iter (children (plump:parse str))))))) + (apply #'concatenate (cons 'string + (map 'list #'iter (children + (plump:parse str))))))) (defvar *server* (make-instance 'easy-acceptor :port 3333)) diff --git a/test.lisp b/test.lisp index fe7f1ce..c73d8f0 100644 --- a/test.lisp +++ b/test.lisp @@ -18,6 +18,22 @@ (is-html "
Hello
" "(:div (:span \"Hello\"))")) +(def-test simple-comment () + (is-html "" + "(:html #| \"with comment\"|#)")) + +(def-test complex-comment () + (is-html "

This is a paragraph.

+ +

This is a paragraph too.

" + "(:p \"This is a paragraph.\") #| +(:p \"Look at this cool image:\") +(:img :border \"0\" :src \"pic_trulli.jpg\" :alt \"Trulli\")|# +(:p \"This is a paragraph too.\")")) + ;; https://stackoverflow.com/questions/54889460/asdftest-system-from-a-makefile-doesnt-return-an-error-return-code (defun run-tests () (run! 'html2clwho-suite))