From 411505245c696f7e1e7c80ee2392639165b6b39f Mon Sep 17 00:00:00 2001 From: riton Date: Sun, 23 Mar 2025 23:44:30 +0300 Subject: =?UTF-8?q?dosya=20yeniden=20adland=C4=B1rma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html-jen.asd | 2 +- html-jen.lisp | 70 ---------------------------------------------------- "\303\274retim.lisp" | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 71 deletions(-) delete mode 100644 html-jen.lisp create mode 100644 "\303\274retim.lisp" diff --git a/html-jen.asd b/html-jen.asd index 60ee243..da2af8c 100644 --- a/html-jen.asd +++ b/html-jen.asd @@ -6,4 +6,4 @@ :components ((:file "paket") (:file "tanım") (:file "okur") - (:file "html-jen"))) + (:file "üretim"))) diff --git a/html-jen.lisp b/html-jen.lisp deleted file mode 100644 index 6074888..0000000 --- a/html-jen.lisp +++ /dev/null @@ -1,70 +0,0 @@ -(in-package :html-jen) - -(defparameter *indent* 0) -(defparameter *indent-increment* 2) -(defparameter *yeni-satır* t) - -(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 :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))) - (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))) - -(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 node) &optional (stream *standard-output*)) - (unless (not *yeni-satır*) - (loop :for i :from 0 :below *indent* - :do (write-char #\Space stream))) - (if (tag-inline? (tag node)) - (format stream "" (tag node)) - (progn (format stream "~%" (tag node)) - (setf *yeni-satır* t)))) - - -(defun node->cons (node) - "node u listeye çevirir." - (if (stringp node) - node - (if (null (children node)) - (list (tag node) (props node) (value node)) - (append (list (tag node) (props node)) - (mapcar #'node->cons (children node)))))) - -(defparameter bir-node - (node! :html (list (node! :head - (list (node! :title nil nil "başlık")) - nil nil) - (node! :body - (list (node! :p nil '(:color "red") "içerik")) - nil nil)) - nil nil)) diff --git "a/\303\274retim.lisp" "b/\303\274retim.lisp" new file mode 100644 index 0000000..6074888 --- /dev/null +++ "b/\303\274retim.lisp" @@ -0,0 +1,70 @@ +(in-package :html-jen) + +(defparameter *indent* 0) +(defparameter *indent-increment* 2) +(defparameter *yeni-satır* t) + +(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 :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))) + (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))) + +(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 node) &optional (stream *standard-output*)) + (unless (not *yeni-satır*) + (loop :for i :from 0 :below *indent* + :do (write-char #\Space stream))) + (if (tag-inline? (tag node)) + (format stream "" (tag node)) + (progn (format stream "~%" (tag node)) + (setf *yeni-satır* t)))) + + +(defun node->cons (node) + "node u listeye çevirir." + (if (stringp node) + node + (if (null (children node)) + (list (tag node) (props node) (value node)) + (append (list (tag node) (props node)) + (mapcar #'node->cons (children node)))))) + +(defparameter bir-node + (node! :html (list (node! :head + (list (node! :title nil nil "başlık")) + nil nil) + (node! :body + (list (node! :p nil '(:color "red") "içerik")) + nil nil)) + nil nil)) -- cgit v1.2.3