diff options
| author | Mark A. Hershberger <mah@everybody.org> | 2007-12-18 03:22:05 +0000 | 
|---|---|---|
| committer | Mark A. Hershberger <mah@everybody.org> | 2007-12-18 03:22:05 +0000 | 
| commit | 7731c9f4012b43ee393417ae8cd541c5d89b172b (patch) | |
| tree | 5de40a7fb1eaad3ccc7f4f0ff3fc241ca4cec37d /lisp | |
| parent | 4f9d920a2d764ffe93e7ec1a75c70cb1d46810f0 (diff) | |
| download | emacs-7731c9f4012b43ee393417ae8cd541c5d89b172b.tar.gz | |
fix up xml-debug-print
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/xml.el | 17 | 
2 files changed, 22 insertions, 2 deletions
| diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 30b7a23d712..3c348071fda 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2007-12-18  Mark A. Hershberger  <mah@everybody.org> + +	* xml.el (xml-escape-string): New function.  Escape string using +	xml-entity-alist. +	(xml-debug-print-internal): Use xml-escape-string to escape +	characters in attributes and in text children of elements. +  2007-12-18  Glenn Morris  <rgm@gnu.org>  	* progmodes/cc-subword.el (c-subword-mode): Drop support for diff --git a/lisp/xml.el b/lisp/xml.el index 6ea6dd4f56c..20c582f06e8 100644 --- a/lisp/xml.el +++ b/lisp/xml.el @@ -844,6 +844,17 @@ The first line is indented with the optional INDENT-STRING."  (defalias 'xml-print 'xml-debug-print) +(defun xml-escape-string (string) +  (mapconcat (lambda (byte) +               (let ((char (char-to-string byte))) +                 (if (rassoc char xml-entity-alist) +                     (concat "&" (car (rassoc char xml-entity-alist)) ";") +                   char))) +             (if (multibyte-string-p string) +                 (encode-coding-string string 'utf-8) +               string) +             "")) +  (defun xml-debug-print-internal (xml indent-string)    "Outputs the XML tree in the current buffer.  The first line is indented with INDENT-STRING." @@ -854,7 +865,8 @@ The first line is indented with INDENT-STRING."      ;;  output the attribute list      (setq attlist (xml-node-attributes tree))      (while attlist -      (insert ?\  (symbol-name (caar attlist)) "=\"" (cdar attlist) ?\") +      (insert ?\  (symbol-name (caar attlist)) "=\"" +              (xml-escape-string (cdar attlist)) ?\")        (setq attlist (cdr attlist)))      (setq tree (xml-node-children tree)) @@ -869,7 +881,8 @@ The first line is indented with INDENT-STRING."  	 ((listp node)  	  (insert ?\n)  	  (xml-debug-print-internal node (concat indent-string "  "))) -	 ((stringp node) (insert node)) +	 ((stringp node) +          (insert (xml-escape-string node)))  	 (t  	  (error "Invalid XML tree")))) | 
