From 99571117b7be94581afe6668daf56ecec04985ba Mon Sep 17 00:00:00 2001 From: riton Date: Sun, 23 Mar 2025 19:47:39 +0300 Subject: =?UTF-8?q?varsay=C4=B1lan=20olarak=20standard=20outputa=20yaz?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html-jen.lisp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/html-jen.lisp b/html-jen.lisp index fdae7ed..41bc1c0 100644 --- a/html-jen.lisp +++ b/html-jen.lisp @@ -4,15 +4,17 @@ (defparameter *indent-increment* 2) (defparameter *yeni-satır* t) -(defgeneric node->html (node stream) +(defgeneric node->html (node &optional stream) + (:method (node &optional (stream *standard-output*)) + (write-string node stream)) (:documentation "NODE u STREAM e yazar")) (defun tag-yeni-satır? (tag) (case tag ((:html :head :body) t) - ((:title :p) nil))) + ((:title :p :b :i :code) nil))) -(defmethod node->html :before (node stream) +(defmethod node->html :before ((node node) &optional (stream *standard-output*)) (loop :for i :from 0 :below *indent* :do (write-char #\Space stream)) (setf *yeni-satır* nil) @@ -26,14 +28,14 @@ (write-char #\Newline stream) (setf *yeni-satır* t))) -(defmethod node->html (node stream) +(defmethod node->html ((node node) &optional (stream *standard-output*)) (if (null (children node)) (format stream "~a" (value node)) (let ((*indent* (+ *indent* *indent-increment*))) (loop :for child :in (children node) :do (node->html child stream))))) -(defmethod node->html :after (node stream) +(defmethod node->html :after ((node node) &optional (stream *standard-output*)) (unless (null *yeni-satır*) (loop :for i :from 0 :below *indent* :do (write-char #\Space stream))) -- cgit v1.2.3