diff options
author | riton <riton@riton.home> | 2025-03-31 23:52:03 +0300 |
---|---|---|
committer | riton <riton@riton.home> | 2025-03-31 23:52:03 +0300 |
commit | 2e16ed1e2a741ee6ae5f8dfe13a739219d8bb562 (patch) | |
tree | ad06bf7649bc1e5ab828d3706281960f5b5c4153 /src | |
parent | ba8fe59c0f39a87c36e3e0514f31fa6162024484 (diff) |
self closing (void) elementlerin düzgün yazdırılması
Diffstat (limited to 'src')
-rw-r--r-- | src/üretim.lisp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/üretim.lisp b/src/üretim.lisp index 3b3530d..bff33f2 100644 --- a/src/üretim.lisp +++ b/src/üretim.lisp @@ -19,6 +19,10 @@ ((:html :head :body :div :ol :ul :li :p :title :pre :h1 :h2 :h3 :h4 :h5 :h6) t) ((:b :i :code) nil))) +(defun tag-sonu-tagsız? (tag) + (case tag + (:img t))) + (defun yeni-satır-yaz (stream) (write-char #\Newline stream) (setf *satır-başı* t)) @@ -38,18 +42,21 @@ (loop :for i :from 0 :below *indent* :do (write-char #\Space stream))) (if (null (props node)) - (format stream "<~a>" (tag node)) + (format stream "<~a" (tag node)) (loop :initially (format stream "<~a" (tag node)) :for (k v) :on (props node) :by #'cddr - :do (format stream " ~a=\"~a\"" k v) - :finally (write-char #\> stream))) + :do (format stream " ~a=\"~a\"" k v))) + (if (tag-sonu-tagsız? (tag node)) + (write-string " />" stream) + (write-char #\> stream)) (setf *satır-başı* nil) (when (tag-başı-yeni-satır? (tag node)) (yeni-satır-yaz stream))) (defmethod node->html ((node node) &optional (stream *standard-output*)) (if (null (children node)) - (kaçışlı-içerik-yazdır (value node) stream) + (when (not (null (value node))) + (kaçışlı-içerik-yazdır (value node) stream)) (let ((*indent* (+ *indent* *indent-increment*))) (loop :for child :in (children node) :do (node->html child stream))))) @@ -58,7 +65,8 @@ (unless (not *satır-başı*) (loop :for i :from 0 :below *indent* :do (write-char #\Space stream))) - (format stream "</~a>" (tag node)) + (unless (tag-sonu-tagsız? (tag node)) + (format stream "</~a>" (tag node))) (when (tag-sonu-yeni-satır? (tag node)) (yeni-satır-yaz stream))) |