From 06cc8a21bfee960d29db921c565543f55dc728ab Mon Sep 17 00:00:00 2001 From: riton Date: Wed, 26 Mar 2025 00:10:11 +0300 Subject: =?UTF-8?q?tag=20i=C3=A7eri=C4=9Finde=20'<',=20'>'=20ve=20'&'=20ka?= =?UTF-8?q?rakterlerini=20=C3=B6zel=20yazd=C4=B1r?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\303\274retim.lisp" | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git "a/\303\274retim.lisp" "b/\303\274retim.lisp" index 51d75e0..2ae81f4 100644 --- "a/\303\274retim.lisp" +++ "b/\303\274retim.lisp" @@ -23,6 +23,16 @@ (write-char #\Newline stream) (setf *satır-başı* t)) +;;;; https://stackoverflow.com/questions/7381974/which-characters-need-to-be-escaped-in-html +;;; TODO geliştirme mümkün... ama şimdilik yeter (#\" """) (#\' "'") +(defun kaçışlı-içerik-yazdır (metin stream) + (loop :for karakter :across metin + :do (case karakter + (#\< (write-string "<" stream)) + (#\> (write-string ">" stream)) + (#\& (write-string "&" stream)) + (t (write-char karakter stream))))) + (defmethod node->html :before ((node node) &optional (stream *standard-output*)) (unless (not *satır-başı*) (loop :for i :from 0 :below *indent* @@ -39,7 +49,7 @@ (defmethod node->html ((node node) &optional (stream *standard-output*)) (if (null (children node)) - (format stream "~a" (value node)) + (kaçışlı-içerik-yazdır (value node) stream) (let ((*indent* (+ *indent* *indent-increment*))) (loop :for child :in (children node) :do (node->html child stream))))) -- cgit v1.2.3