Skip to content

Commit

Permalink
fix: allow tag comment (fix #5)
Browse files Browse the repository at this point in the history
  • Loading branch information
albertolerda committed Mar 26, 2024
1 parent 7b13e59 commit 22a7dab
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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)"
8 changes: 6 additions & 2 deletions html2clwho.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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~})"
Expand All @@ -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))

Expand Down
16 changes: 16 additions & 0 deletions test.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@
(is-html "<div><span>Hello</span></div>" "(:div
(:span \"Hello\"))"))

(def-test simple-comment ()
(is-html "<html><!--with comment--></html>"
"(:html #| \"with comment\"|#)"))

(def-test complex-comment ()
(is-html " <p>This is a paragraph.</p>
<!--
<p>Look at this cool image:</p>
<img border=\"0\" src=\"pic_trulli.jpg\" alt=\"Trulli\">
-->
<p>This is a paragraph too.</p> "
"(: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))

0 comments on commit 22a7dab

Please sign in to comment.