From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Maus Subject: [PATCH 3/4] Unescape protected entities defined in `xml-entity-alist'. Date: Sat, 19 Jun 2010 16:25:40 +0200 Message-ID: <1276957541-29908-4-git-send-email-dmaus@ictsoc.de> References: <87wrtvdzv2.fsf@gmail.com> Return-path: Received: from [140.186.70.92] (port=49743 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OPz15-0005JH-5S for emacs-orgmode@gnu.org; Sat, 19 Jun 2010 10:27:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OPz14-0003Qt-4z for emacs-orgmode@gnu.org; Sat, 19 Jun 2010 10:27:27 -0400 Received: from mysql1.xlhost.de ([213.202.242.106]:58396) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OPz13-0003Qk-V7 for emacs-orgmode@gnu.org; Sat, 19 Jun 2010 10:27:26 -0400 In-Reply-To: <87wrtvdzv2.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org * org-feed.el (org-feed-unescape): New function. Unescape protected entities. (org-feed-parse-atom-entry): Use function for atom:content type text and html. --- lisp/org-feed.el | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lisp/org-feed.el b/lisp/org-feed.el index b0373e5..2621008 100644 --- a/lisp/org-feed.el +++ b/lisp/org-feed.el @@ -267,6 +267,17 @@ have been saved." (defvar org-feed-buffer "*Org feed*" "The buffer used to retrieve a feed.") +(defun org-feed-unescape (s) + "Unescape protected entities in S." + (let ((re (concat "&\\(" + (mapconcat (lambda (e) + (car e)) xml-entity-alist "\\|") + "\\);"))) + (while (string-match re s) + (setq s (replace-match + (cdr (assoc (match-string 1 s) xml-entity-alist)) nil nil s))) + s)) + ;;;###autoload (defun org-feed-update-all () "Get inbox items from all feeds in `org-feed-alist'." @@ -647,10 +658,10 @@ formatted as a string, not the original XML data." (cond ((string= type "text") ;; We like plain text. - (setq entry (plist-put entry :description (car (xml-node-children content))))) + (setq entry (plist-put entry :description (org-feed-unescape (car (xml-node-children content)))))) ((string= type "html") ;; TODO: convert HTML to Org markup. - (setq entry (plist-put entry :description (car (xml-node-children content))))) + (setq entry (plist-put entry :description (org-feed-unescape (car (xml-node-children content)))))) ((string= type "xhtml") ;; TODO: convert XHTML to Org markup. (setq entry (plist-put entry :description (prin1-to-string (xml-node-children content))))) -- 1.7.1