summaryrefslogtreecommitdiff
path: root/testler/test.lisp
blob: 500abbcdc693385f480413603d24aa7ab9a7b2c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
(defpackage :html-jen/testler
  (:use :common-lisp :html-jen))

(in-package :html-jen/testler)

(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 ()
  (assert (eq t (test-1)))
  (assert (eq t (test-2))))