diff options
Diffstat (limited to 'zencoding-mode.el')
-rw-r--r-- | zencoding-mode.el | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/zencoding-mode.el b/zencoding-mode.el index 123cdb3..3ae06d8 100644 --- a/zencoding-mode.el +++ b/zencoding-mode.el @@ -392,7 +392,8 @@ '("html" (zencoding-primary-filter zencoding-make-html-tag) "c" (zencoding-primary-filter zencoding-make-commented-html-tag) "haml" (zencoding-primary-filter zencoding-make-haml-tag) - "hic" (zencoding-primary-filter zencoding-make-hiccup-tag))) + "hic" (zencoding-primary-filter zencoding-make-hiccup-tag) + "e" (zencoding-escape-xml))) (defun zencoding-primary-filter (input proc) "Process filter that needs to be executed first, ie. not given output from other filter." @@ -507,6 +508,18 @@ (concat prefix body suffix)) "")) +(defun zencoding-escape-xml (input proc) + "Escapes XML-unsafe characters: <, > and &." + (replace-regexp-in-string + "<" "<" + (replace-regexp-in-string + ">" ">" + (replace-regexp-in-string + "&" "&" + (if (stringp input) + input + (zencoding-process-filter (zencoding-default-filter) input)))))) + (defun zencoding-transform (ast-with-filters) "Transform AST (containing filter data) into string." (let ((filters (cadr ast-with-filters)) @@ -739,6 +752,9 @@ " [:a [:b]]" " [:p" " [:b]]]") + ;; Filter: escape + ("script src="|e" "<script src=\"&quot;\">" + "</script>") ))) (mapc (lambda (input) (let ((expected (mapconcat 'identity (cdr input) "\n")) |