html üretiminde yeni satırlar düzenlendi
This commit is contained in:
@@ -11,19 +11,25 @@
|
|||||||
|
|
||||||
(defun tag-yeni-satır? (tag)
|
(defun tag-yeni-satır? (tag)
|
||||||
(case tag
|
(case tag
|
||||||
((:html :head :body) t)
|
((:html :head :body :div :ol :ul) t)
|
||||||
((:title :p :b :i :code) nil)))
|
((: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*))
|
(defmethod node->html :before ((node node) &optional (stream *standard-output*))
|
||||||
(loop :for i :from 0 :below *indent*
|
(unless (not *yeni-satır*)
|
||||||
:do (write-char #\Space stream))
|
(loop :for i :from 0 :below *indent*
|
||||||
(setf *yeni-satır* nil)
|
:do (write-char #\Space stream)))
|
||||||
(if (null (props node))
|
(if (null (props node))
|
||||||
(format stream "<~a>" (tag node))
|
(format stream "<~a>" (tag node))
|
||||||
(loop :initially (format stream "<~a" (tag node))
|
(loop :initially (format stream "<~a" (tag node))
|
||||||
:for (k v) :on (props node) :by #'cddr
|
:for (k v) :on (props node) :by #'cddr
|
||||||
:do (format stream " ~a=\"~a\"" k v)
|
:do (format stream " ~a=\"~a\"" k v)
|
||||||
:finally (write-char #\> stream)))
|
:finally (write-char #\> stream)))
|
||||||
|
(setf *yeni-satır* nil)
|
||||||
(when (tag-yeni-satır? (tag node))
|
(when (tag-yeni-satır? (tag node))
|
||||||
(write-char #\Newline stream)
|
(write-char #\Newline stream)
|
||||||
(setf *yeni-satır* t)))
|
(setf *yeni-satır* t)))
|
||||||
@@ -36,11 +42,13 @@
|
|||||||
:do (node->html child stream)))))
|
:do (node->html child stream)))))
|
||||||
|
|
||||||
(defmethod node->html :after ((node node) &optional (stream *standard-output*))
|
(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*
|
(loop :for i :from 0 :below *indent*
|
||||||
:do (write-char #\Space stream)))
|
:do (write-char #\Space stream)))
|
||||||
(format stream "</~a>~%" (tag node))
|
(if (tag-inline? (tag node))
|
||||||
(setf *yeni-satır* t))
|
(format stream "</~a>" (tag node))
|
||||||
|
(progn (format stream "</~a>~%" (tag node))
|
||||||
|
(setf *yeni-satır* t))))
|
||||||
|
|
||||||
|
|
||||||
(defun node->cons (node)
|
(defun node->cons (node)
|
||||||
|
|||||||
Reference in New Issue
Block a user