tag içeriğinde '<', '>' ve '&' karakterlerini özel yazdır
This commit is contained in:
12
üretim.lisp
12
ü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 "<" 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)))))
|
||||
|
||||
Reference in New Issue
Block a user