From: David Maus <dmaus@ictsoc.de>
To: emacs-orgmode@gnu.org
Subject: [PATCH 3/4] Unescape protected entities defined in `xml-entity-alist'.
Date: Sat, 19 Jun 2010 16:25:40 +0200 [thread overview]
Message-ID: <1276957541-29908-4-git-send-email-dmaus@ictsoc.de> (raw)
In-Reply-To: <87wrtvdzv2.fsf@gmail.com>
* 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
next prev parent reply other threads:[~2010-06-19 14:27 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-19 3:15 org-feed not working for codeproject zwz
2010-06-19 10:48 ` David Maus
2010-06-19 11:29 ` zwz
2010-06-19 14:25 ` [PATCH 0/4] org-feed: Improve feed parsing David Maus
2010-07-01 13:23 ` Carsten Dominik
2010-07-01 18:02 ` [PATCH] Resubmit: Remove superfluous lambda David Maus
2010-07-01 18:02 ` [PATCH] " David Maus
2010-07-02 4:40 ` Carsten Dominik
2010-07-02 6:04 ` David Maus
2010-07-02 13:21 ` Sebastian Rose
2010-07-02 13:23 ` John Wiegley
2010-07-02 13:49 ` Sebastian Rose
2010-07-02 13:53 ` John Wiegley
2010-07-02 13:55 ` Sebastian Rose
2010-07-06 7:44 ` Carsten Dominik
2010-06-19 14:25 ` [PATCH 1/4] Respect possible XML namespace of rss:item elements David Maus
2010-06-19 14:25 ` [PATCH 2/4] Ignore case of rss element names David Maus
2010-06-19 14:25 ` David Maus [this message]
2010-06-19 14:25 ` [PATCH 4/4] Unescape rss element content David Maus
2010-06-19 14:28 ` [PATCH] Declare variable `xml-entity-alist' for byte compiler David Maus
2010-06-19 14:44 ` [PATCH] Remove superfluous lambda David Maus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1276957541-29908-4-git-send-email-dmaus@ictsoc.de \
--to=dmaus@ictsoc.de \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).