Add Eric Marsden's patch.
authorShengHuo ZHU <zsh@cs.rochester.edu>
Mon, 13 Dec 1999 15:53:29 +0000 (15:53 +0000)
committerShengHuo ZHU <zsh@cs.rochester.edu>
Mon, 13 Dec 1999 15:53:29 +0000 (15:53 +0000)
Merge several decode-entities copies.

lisp/ChangeLog
lisp/nnslashdot.el
lisp/nnwarchive.el
lisp/nnweb.el
lisp/webmail.el

index 0b48216..017b7d8 100644 (file)
@@ -1,3 +1,20 @@
+1999-12-13 10:39:53  Shenghuo ZHU  <zsh@cs.rochester.edu>
+
+       * nnweb.el (nnweb-decode-entities): Decode numerical entities.
+       (nnweb-decode-entities-string): New function.
+       
+       * nnwarchive.el (nnwarchive-decode-entities-string): Rename to
+       nnweb-* and move to nnweb.el.
+       * nnwarchive.el: Use nnweb-decode-entities, etc.
+       * webmail.el: Ditto.
+       
+       * nnslashdot.el: Use nnweb-decode-entities-string.
+       (nnslashdot-decode-entities): Remove.
+               
+1999-12-13 10:40:56  Eric Marsden <emarsden@mail.dotcom.fr>
+
+       * nnslashdot.el: Decode entities.
+
 1999-12-12  Dave Love  <fx@gnu.org>
 
        * gnus-agent.el (gnus-category-edit-groups)
index 7ffa711..fb20908 100644 (file)
          (goto-char (point-min))
          (search-forward "Posted by ")
          (when (looking-at "<a[^>]+>\\([^<]+\\)")
-           (setq from (match-string 1)))
+           (setq from (nnweb-decode-entities-string (match-string 1))))
          (search-forward " on ")
          (setq date (nnslashdot-date-to-date
                      (buffer-substring (point) (1- (search-forward "<")))))
                  score (match-string 3))
            (when (string-match "^Re: *" subject)
              (setq subject (concat "Re: " (substring subject (match-end 0)))))
+            (setq subject (nnweb-decode-entities-string subject))
            (forward-line 1)
            (if (looking-at
                 "by <a[^>]+>\\([^<]+\\)</a>[ \t\n]*.*(\\([^)]+\\))")
-               (setq from (concat (match-string 1)
+               (setq from (concat (nnweb-decode-entities-string (match-string 1))
                                   " <" (match-string 2) ">"))
              (looking-at "by \\(.+\\) on ")
-             (setq from (match-string 1)))
+             (setq from (nnweb-decode-entities-string (match-string 1))))
            (goto-char (- (match-end 0) 5))
            (search-forward " on ")
            (setq date
        (goto-char (point-min))
        (search-forward "Posted by ")
        (when (looking-at "<a[^>]+>\\([^<]+\\)")
-         (setq from (match-string 1)))
+         (setq from (nnweb-decode-entities-string (match-string 1))))
        (search-forward " on ")
        (setq date (nnslashdot-date-to-date
                    (buffer-substring (point) (1- (search-forward "<")))))
                score (match-string 3))
          (when (string-match "^Re: *" subject)
            (setq subject (concat "Re: " (substring subject (match-end 0)))))
+          (setq subject (nnweb-decode-entities-string subject))
          (forward-line 1)
          (if (looking-at
               "by <a[^>]+>\\([^<]+\\)</a>[ \t\n]*.*(\\([^)]+\\))")
-             (setq from (concat (match-string 1) " <" (match-string 2) ">"))
+             (setq from (concat (nnweb-decode-entities-string (match-string 1))
+                                 " <" (match-string 2) ">"))
            (looking-at "by \\(.+\\) on ")
-           (setq from (match-string 1)))
+           (setq from (nnweb-decode-entities-string (match-string 1))))
          (goto-char (- (match-end 0) 5))
          (search-forward " on ")
          (setq date
              (narrow-to-region (point) (search-forward "</story>"))
              (goto-char (point-min))
              (re-search-forward "<title>\\([^<]+\\)</title>")
-             (setq description (match-string 1))
+             (setq description (nnweb-decode-entities-string (match-string 1)))
              (re-search-forward "<url>\\([^<]+\\)</url>")
              (setq sid (match-string 1))
              (string-match "/\\([0-9/]+\\).shtml" sid)
                (while (re-search-forward
                        "article.pl\\?sid=\\([^&]+\\).*<b>\\([^<]+\\)</b>" nil t)
                  (setq sid (match-string 1)
-                       description (match-string 2))
+                       description (nnweb-decode-entities-string (match-string 2)))
                  (forward-line 1)
                  (when (re-search-forward "<b>\\([0-9]+\\)</b>" nil t)
                    (setq articles (string-to-number (match-string 1))))
index a9d2dbb..8c0d443 100644 (file)
      (t
       (nnweb-insert (apply 'format (nnwarchive-eval xurl)))))))
 
-(defun nnwarchive-decode-entities ()
-  (goto-char (point-min))
-  (while (re-search-forward "&\\(#[0-9]+\\|[a-z]+\\);" nil t)
-    (replace-match (char-to-string 
-                   (if (eq (aref (match-string 1) 0) ?\#)
-                       (string-to-number (substring (match-string 1) 1))
-                     (or (cdr (assq (intern (match-string 1))
-                                    w3-html-entities))
-                         ?#)))
-                  t t)))
-
-(defun nnwarchive-decode-entities-string (str)
-  (with-temp-buffer
-    (insert str)
-    (nnwarchive-decode-entities)
-    (buffer-substring (point-min) (point-max))))
-
-(defun nnwarchive-remove-markup ()
-  (goto-char (point-min))
-  (while (search-forward "<!--" nil t)
-    (delete-region (match-beginning 0)
-                  (or (search-forward "-->" nil t)
-                      (point-max))))
-  (goto-char (point-min))
-  (while (re-search-forward "<[^>]+>" nil t)
-    (replace-match "" t t)))
-
-(defun nnwarchive-date-to-date (sdate)
-  (let ((elem (split-string sdate)))
-    (concat (substring (nth 0 elem) 0 3) " "
-           (substring (nth 1 elem) 0 3) " "
-           (substring (nth 2 elem) 0 2) " "
-           (substring (nth 3 elem) 1 6) " "
-           (format-time-string "%Y") " "
-           (nth 4 elem))))
-
 (defun nnwarchive-generate-active ()
   (save-excursion
     (set-buffer nntp-server-buffer)
               article
               (make-full-mail-header
                article 
-               (nnwarchive-decode-entities-string subject)
-               (nnwarchive-decode-entities-string from)
+               (nnweb-decode-entities-string subject)
+               (nnweb-decode-entities-string from)
                date
                (concat "<" group "%"
                        (number-to-string article) 
   (goto-char (point-min))
   (while (re-search-forward "<a[^>]+>\\([^<]+\\)</a>" nil t)
     (replace-match "<\\1>"))
-  (nnwarchive-decode-entities)
+  (nnweb-decode-entities)
   (buffer-string))
 
 (defun nnwarchive-egroups-xover-files (group articles)
               article
               (make-full-mail-header
                article 
-               (nnwarchive-decode-entities-string subject)
-               (nnwarchive-decode-entities-string from)
+               (nnweb-decode-entities-string subject)
+               (nnweb-decode-entities-string from)
                date
                (format "<%05d%%%s>\n" (1- article) group)
                ""
       (when (search-forward "X-Head-End" nil t)
        (beginning-of-line)
        (narrow-to-region (point-min) (point))
-       (nnwarchive-decode-entities)
+       (nnweb-decode-entities)
        (goto-char (point-min))
        (while (search-forward "<!--X-" nil t)
          (replace-match ""))
        (search-forward "</ul>" nil t)
        (end-of-line)
        (narrow-to-region (point-min) (point))
-       (nnwarchive-remove-markup)
-       (nnwarchive-decode-entities)
+       (nnweb-remove-markup)
+       (nnweb-decode-entities)
        (goto-char (point-min))
        (delete-blank-lines)
        (when from
                (delete-region (match-beginning 0) (match-end 0))
                (save-restriction
                  (narrow-to-region p (point))
-                 (nnwarchive-remove-markup)
-                 (nnwarchive-decode-entities)
+                 (nnweb-remove-markup)
+                 (nnweb-decode-entities)
                  (goto-char (point-max)))))
             ((looking-at "<P><A HREF=\"\\([^\"]+\\)")
              (setq url (match-string 1))
index a1b1c38..1a6fab5 100644 (file)
@@ -719,12 +719,21 @@ and `altavista'.")
 (defun nnweb-decode-entities ()
   "Decode all HTML entities."
   (goto-char (point-min))
-  (while (re-search-forward "&\\([a-z]+\\);" nil t)
-    (replace-match (char-to-string (or (cdr (assq (intern (match-string 1))
-                                                 w3-html-entities))
-                                      ?#))
+  (while (re-search-forward "&\\(#[0-9]+\\|[a-z]+\\);" nil t)
+    (replace-match (char-to-string 
+                   (if (eq (aref (match-string 1) 0) ?\#)
+                       (string-to-number (substring (match-string 1) 1))
+                     (or (cdr (assq (intern (match-string 1))
+                                    w3-html-entities))
+                         ?#)))
                   t t)))
 
+(defun nnweb-decode-entities-string (str)
+  (with-temp-buffer
+    (insert str)
+    (nnweb-decode-entities)
+    (buffer-substring (point-min) (point-max))))
+
 (defun nnweb-remove-markup ()
   "Remove all HTML markup, leaving just plain text."
   (goto-char (point-min))
index 6cc8f7c..6a23eb7 100644 (file)
      (t
       (nnweb-insert (apply 'format (webmail-eval xurl)))))))
   
-(defun webmail-decode-entities ()
-  (goto-char (point-min))
-  (while (re-search-forward "&\\(#[0-9]+\\|[a-z]+\\);" nil t)
-    (replace-match (char-to-string 
-                   (if (eq (aref (match-string 1) 0) ?\#)
-                       (string-to-number (substring (match-string 1) 1))
-                     (or (cdr (assq (intern (match-string 1))
-                                    w3-html-entities))
-                         ?#)))
-                  t t)))
-
-(defun webmail-decode-entities-string (str)
-  (with-temp-buffer
-    (insert str)
-    (webmail-decode-entities)
-    (buffer-substring (point-min) (point-max))))
-
-(defun webmail-remove-markup ()
-  (goto-char (point-min))
-  (while (search-forward "<!--" nil t)
-    (delete-region (match-beginning 0)
-                  (or (search-forward "-->" nil t)
-                      (point-max))))
-  (goto-char (point-min))
-  (while (re-search-forward "<[^>]+>" nil t)
-    (replace-match "" t t)))
-
 (defun webmail-init ()
   "Initialize buffers and such."
   (if (gnus-buffer-live-p webmail-buffer)
        (setq p (match-beginning 0))
        (search-forward "</a>" nil t)
        (delete-region p (match-end 0)))
-      (webmail-remove-markup)
-      (webmail-decode-entities)
+      (nnweb-remove-markup)
+      (nnweb-decode-entities)
       (goto-char (point-min))
       (delete-blank-lines)
       (goto-char (point-min))
            (goto-char (match-end 0))
            (if (looking-at "$") (forward-char))
            (delete-region (point-min) (point))
-           (webmail-remove-markup)
-           (webmail-decode-entities)
+           (nnweb-remove-markup)
+           (nnweb-decode-entities)
            nil)
           (t
            (setq mime t)
        (setq p (match-beginning 0))
        (search-forward "</a>" nil t)
        (delete-region p (match-end 0)))
-      (webmail-remove-markup)
-      (webmail-decode-entities)
+      (nnweb-remove-markup)
+      (nnweb-decode-entities)
       (goto-char (point-min))
       (delete-blank-lines)
       (goto-char (point-max))
          (if (not (search-forward "</table>" nil t))
              (error "Can't find start label (article@5)"))
          (narrow-to-region p (match-end 0))
-         (webmail-remove-markup)
-         (webmail-decode-entities)
+         (nnweb-remove-markup)
+         (nnweb-decode-entities)
          (goto-char (point-min))
          (delete-blank-lines)
          (setq ct (mail-fetch-field "content-type")
     (goto-char (point-min))
     (while (re-search-forward "<br>" nil t)
       (replace-match "\n"))
-    (webmail-remove-markup)
-    (webmail-decode-entities) 
+    (nnweb-remove-markup)
+    (nnweb-decode-entities) 
     nil)
    (t
     (insert "<#part type=\"text/html\" disposition=inline>")
       (goto-char (point-min))
       (while (search-forward "<b>" nil t)
        (replace-match "\n"))
-      (webmail-remove-markup)
-      (webmail-decode-entities)
+      (nnweb-remove-markup)
+      (nnweb-decode-entities)
       (goto-char (point-min))
       (delete-blank-lines)
       (goto-char (point-min))