self closing (void) elementlerin düzgün yazdırılması
This commit is contained in:
@@ -19,6 +19,10 @@
|
|||||||
((:html :head :body :div :ol :ul :li :p :title :pre :h1 :h2 :h3 :h4 :h5 :h6) t)
|
((:html :head :body :div :ol :ul :li :p :title :pre :h1 :h2 :h3 :h4 :h5 :h6) t)
|
||||||
((:b :i :code) nil)))
|
((:b :i :code) nil)))
|
||||||
|
|
||||||
|
(defun tag-sonu-tagsız? (tag)
|
||||||
|
(case tag
|
||||||
|
(:img t)))
|
||||||
|
|
||||||
(defun yeni-satır-yaz (stream)
|
(defun yeni-satır-yaz (stream)
|
||||||
(write-char #\Newline stream)
|
(write-char #\Newline stream)
|
||||||
(setf *satır-başı* t))
|
(setf *satır-başı* t))
|
||||||
@@ -38,18 +42,21 @@
|
|||||||
(loop :for i :from 0 :below *indent*
|
(loop :for i :from 0 :below *indent*
|
||||||
:do (write-char #\Space stream)))
|
: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)))
|
(if (tag-sonu-tagsız? (tag node))
|
||||||
|
(write-string " />" stream)
|
||||||
|
(write-char #\> stream))
|
||||||
(setf *satır-başı* nil)
|
(setf *satır-başı* nil)
|
||||||
(when (tag-başı-yeni-satır? (tag node))
|
(when (tag-başı-yeni-satır? (tag node))
|
||||||
(yeni-satır-yaz stream)))
|
(yeni-satır-yaz stream)))
|
||||||
|
|
||||||
(defmethod node->html ((node node) &optional (stream *standard-output*))
|
(defmethod node->html ((node node) &optional (stream *standard-output*))
|
||||||
(if (null (children node))
|
(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*)))
|
(let ((*indent* (+ *indent* *indent-increment*)))
|
||||||
(loop :for child :in (children node)
|
(loop :for child :in (children node)
|
||||||
:do (node->html child stream)))))
|
:do (node->html child stream)))))
|
||||||
@@ -58,7 +65,8 @@
|
|||||||
(unless (not *satır-başı*)
|
(unless (not *satır-başı*)
|
||||||
(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))
|
(unless (tag-sonu-tagsız? (tag node))
|
||||||
|
(format stream "</~a>" (tag node)))
|
||||||
(when (tag-sonu-yeni-satır? (tag node))
|
(when (tag-sonu-yeni-satır? (tag node))
|
||||||
(yeni-satır-yaz stream)))
|
(yeni-satır-yaz stream)))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user