html üretiminde yeni satırlar düzenlendi

This commit is contained in:
riton
2025-03-23 22:38:37 +03:00
parent 041740e761
commit 58b05733c1

View File

@@ -11,19 +11,25 @@
(defun tag-yeni-satır? (tag)
(case tag
((:html :head :body) t)
((:title :p :b :i :code) nil)))
((:html :head :body :div :ol :ul) t)
((:title :p :b :i :code :li) nil)))
(defun tag-inline? (tag)
(case tag
((:html :head :body :div :ol :ul :li :p) nil)
((:title :b :i :code) t)))
(defmethod node->html :before ((node node) &optional (stream *standard-output*))
(unless (not *yeni-satır*)
(loop :for i :from 0 :below *indent*
:do (write-char #\Space stream))
(setf *yeni-satır* nil)
:do (write-char #\Space stream)))
(if (null (props 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)))
(setf *yeni-satır* nil)
(when (tag-yeni-satır? (tag node))
(write-char #\Newline stream)
(setf *yeni-satır* t)))
@@ -36,11 +42,13 @@
:do (node->html child stream)))))
(defmethod node->html :after ((node node) &optional (stream *standard-output*))
(unless (null *yeni-satır*)
(unless (not *yeni-satır*)
(loop :for i :from 0 :below *indent*
:do (write-char #\Space stream)))
(format stream "</~a>~%" (tag node))
(setf *yeni-satır* t))
(if (tag-inline? (tag node))
(format stream "</~a>" (tag node))
(progn (format stream "</~a>~%" (tag node))
(setf *yeni-satır* t))))
(defun node->cons (node)