summaryrefslogtreecommitdiff
path: root/üretim.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'üretim.lisp')
-rw-r--r--üretim.lisp12
1 files changed, 11 insertions, 1 deletions
diff --git a/üretim.lisp b/üretim.lisp
index 51d75e0..2ae81f4 100644
--- a/üretim.lisp
+++ b/üretim.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 "&lt;" stream))
+ (#\> (write-string "&gt;" stream))
+ (#\& (write-string "&amp;" 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)))))