summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Maus <dmaus@ictsoc.de>2010-08-18 20:44:57 +0200
committerDavid Maus <dmaus@ictsoc.de>2010-08-18 20:49:54 +0200
commit7cbc7a67d4f7a08d901b612ff0b46aca6f4f8858 (patch)
tree2ae74d8c8ef4ec0e0671e1ed4b61da17c6d600bc
parent76790e1aa807bc7d13af17db696ffa11ce764602 (diff)
downloadorg-mode-7cbc7a67d4f7a08d901b612ff0b46aca6f4f8858.tar.gz
org-feed: Use `xml-substitute-special' for unescaping XML entities.
* org-feed.el (xml-substitute-special): Declare function for byte compiler. (org-feed-unescape): Removed. (org-feed-parse-rss-entry, org-feed-parse-atom-entry): Use `xml-substitute-special' to unescape XML entities. TINYCHANGE Patch by Michael Brand
-rw-r--r--lisp/org-feed.el22
1 files changed, 6 insertions, 16 deletions
diff --git a/lisp/org-feed.el b/lisp/org-feed.el
index 073d344..f50678b 100644
--- a/lisp/org-feed.el
+++ b/lisp/org-feed.el
@@ -99,7 +99,7 @@
(declare-function xml-get-children "xml" (node child-name))
(declare-function xml-get-attribute "xml" (node attribute))
(declare-function xml-get-attribute-or-nil "xml" (node attribute))
-(defvar xml-entity-alist)
+(declare-function xml-substitute-special "xml" (string))
(defgroup org-feed nil
"Options concerning RSS feeds as inputs for Org files."
@@ -269,17 +269,6 @@ 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."
- (require 'xml)
- (let ((re (concat "&\\("
- (mapconcat 'car 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'."
@@ -613,6 +602,7 @@ containing the properties `:guid' and `:item-full-text'."
(defun org-feed-parse-rss-entry (entry)
"Parse the `:item-full-text' field for xml tags and create new properties."
+ (require 'xml)
(with-temp-buffer
(insert (plist-get entry :item-full-text))
(goto-char (point-min))
@@ -620,7 +610,7 @@ containing the properties `:guid' and `:item-full-text'."
nil t)
(setq entry (plist-put entry
(intern (concat ":" (match-string 1)))
- (org-feed-unescape (match-string 2)))))
+ (xml-substitute-special (match-string 2)))))
(goto-char (point-min))
(unless (re-search-forward "isPermaLink[ \t]*=[ \t]*\"false\"" nil t)
(setq entry (plist-put entry :guid-permalink t))))
@@ -654,7 +644,7 @@ formatted as a string, not the original XML data."
'href)))
;; Add <title/> as :title.
(setq entry (plist-put entry :title
- (org-feed-unescape
+ (xml-substitute-special
(car (xml-node-children
(car (xml-get-children xml 'title)))))))
(let* ((content (car (xml-get-children xml 'content)))
@@ -664,12 +654,12 @@ formatted as a string, not the original XML data."
((string= type "text")
;; We like plain text.
(setq entry (plist-put entry :description
- (org-feed-unescape
+ (xml-substitute-special
(car (xml-node-children content))))))
((string= type "html")
;; TODO: convert HTML to Org markup.
(setq entry (plist-put entry :description
- (org-feed-unescape
+ (xml-substitute-special
(car (xml-node-children content))))))
((string= type "xhtml")
;; TODO: convert XHTML to Org markup.