diff options
author | riton <riton@riton.home> | 2025-03-26 22:04:43 +0300 |
---|---|---|
committer | riton <riton@riton.home> | 2025-03-26 22:04:43 +0300 |
commit | 4b494af46035e80bb741881c1717c789638607c5 (patch) | |
tree | ef3a0d6c2dcd57777785bfe218499a0ce5cb95d5 | |
parent | 1459b3c8cb150f06b7befa3c2a5366bd935c2fc5 (diff) |
test eklendi
-rw-r--r-- | testler/test.lisp | 46 | ||||
-rw-r--r-- | üretim.lisp | 18 |
2 files changed, 40 insertions, 24 deletions
diff --git a/testler/test.lisp b/testler/test.lisp index 5a04f0b..500abbc 100644 --- a/testler/test.lisp +++ b/testler/test.lisp @@ -3,11 +3,45 @@ (in-package :html-jen/testler) -(defun test-test () - (assert (= 3 (+ 1 2))) - (unless (= 3 2) - (error "hata"))) +(defun mklist (thing) + (if (listp thing) + thing + (list thing))) + +(defun node->cons (node) + "node u listeye çevirir." + (if (stringp node) + node + (with-slots (tag props children value) node + (append (list tag) + props + (if (null children) + (mklist value) + (mapcar #'node->cons children)))))) + +(defun test-1 () + (let ((okur (okur! "../cheat.md"))) + (equal (node->cons (markdown-ayrıştır okur)) + '(:DIV (:H1 "heading") + (:P "paragraph, " (:B "bold") " " (:I "italic") " ya da " (:I "italic") " ve " (:CODE "inline code") " +" + (:A :HREF "https://www.markdownguide.org/cheat-sheet/" "links")) + (:H2 "h2") + (:UL (:LI "unordered") (:LI "list")) + (:OL (:LI "ordered") (:LI "list")) + (:P "footnote [^1]") + (:PRE (:CODE "code block +")) + "" + (:P "!" (:A :HREF "image.jpg" "alt text")) + (:P " +[^1]: this is the footnote (extended markdown)"))))) + +(defun test-2 () + (equal (node->cons (markdown-ayrıştır (metin-okur! "# başlık 1"))) + '(:div (:h1 "başlık 1")))) (defun testleri-çalıştır () - ;; (test-test) - ) + (assert (eq t (test-1))) + (assert (eq t (test-2)))) + diff --git a/üretim.lisp b/üretim.lisp index 6cbc344..3b3530d 100644 --- a/üretim.lisp +++ b/üretim.lisp @@ -62,21 +62,3 @@ (when (tag-sonu-yeni-satır? (tag node)) (yeni-satır-yaz stream))) - -(defun node->cons (node) - "node u listeye çevirir." - (if (stringp node) - node - (if (null (children node)) - (list (tag node) (props node) (value node)) - (append (list (tag node) (props node)) - (mapcar #'node->cons (children node)))))) - -(defparameter bir-node - (node! :html (list (node! :head - (list (node! :title nil nil "başlık")) - nil nil) - (node! :body - (list (node! :p nil '(:color "red") "içerik")) - nil nil)) - nil nil)) |