From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/61621 Path: news.gmane.org!not-for-mail From: Mark Plaksin Newsgroups: gmane.emacs.gnus.general Subject: Re: Prevent nnrss from generating text/plain parts for HTML text Date: Mon, 02 Jan 2006 12:51:37 -0500 Message-ID: <87sls6ecwm.fsf@stone.tss.usg.edu> References: <87wthiedd8.fsf@stone.tss.usg.edu> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1136224355 2404 80.91.229.2 (2 Jan 2006 17:52:35 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 2 Jan 2006 17:52:35 +0000 (UTC) Original-X-From: ding-owner+m10153@lists.math.uh.edu Mon Jan 02 18:52:33 2006 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EtTr5-00012b-Ga for ding-account@gmane.org; Mon, 02 Jan 2006 18:52:23 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu ident=lists) by malifon.math.uh.edu with smtp (Exim 3.20 #1) id 1EtTr1-00078J-00; Mon, 02 Jan 2006 11:52:19 -0600 Original-Received: from nas01.math.uh.edu ([129.7.128.39]) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 1EtTqq-00078E-00 for ding@lists.math.uh.edu; Mon, 02 Jan 2006 11:52:08 -0600 Original-Received: from quimby.gnus.org ([80.91.224.244]) by nas01.math.uh.edu with esmtp (Exim 4.52) id 1EtTql-0004ou-Hy for ding@lists.math.uh.edu; Mon, 02 Jan 2006 11:52:08 -0600 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1EtTqk-0007FJ-00 for ; Mon, 02 Jan 2006 18:52:02 +0100 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1EtTqb-0000uw-DF for ding@gnus.org; Mon, 02 Jan 2006 18:51:53 +0100 Original-Received: from stone.tss.usg.edu ([168.24.82.77]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 02 Jan 2006 18:51:53 +0100 Original-Received: from happy by stone.tss.usg.edu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 02 Jan 2006 18:51:53 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-To: ding@gnus.org Original-Lines: 104 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: stone.tss.usg.edu User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0 (gnu/linux) Cancel-Lock: sha1:iaMHqhTROO3g1NW9f3yxtxuqi0w= X-Spam-Score: -2.6 (--) Precedence: bulk Original-Sender: ding-owner@lists.math.uh.edu Xref: news.gmane.org gmane.emacs.gnus.general:61621 Archived-At: --=-=-= Mark Plaksin writes: > I don't know the best way to check for HTML in elisp. I've attached a > patch which uses a regexp to do the job. The patch works OK for me but I > don't think it's ideal. What's a better way to do this? Oops--that patch failed when the text of an item was empty (e.g., some items in del.icio.us feeds). Here's a new patch which fixes that. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=nnrss-textplain.patch Content-Description: nnrss textplain --- nnrss.el.orig 2005-12-21 12:43:03.000000000 -0500 +++ nnrss.el 2006-01-02 12:44:33.000000000 -0500 @@ -208,40 +208,48 @@ rfc2047-encode-encoded-words body) (when (or text link enclosure comments) (insert "\n") - (insert "<#multipart type=alternative>\n" - "<#part type=\"text/plain\">\n") - (setq body (point)) - (when text - (insert text) - (goto-char body) - ;; See `nnrss-check-group', which inserts "

". - (if (search-forward "

" nil t) - (if (eobp) - (replace-match "\n") - (replace-match "\n\n") - (let ((fill-column default-fill-column) - (window (get-buffer-window nntp-server-buffer))) - (when window - (setq fill-column - (max 1 (/ (* (window-width window) 7) 8)))) - (fill-region (point) (point-max)) - (goto-char (point-max)) - ;; XEmacs version of `fill-region' inserts newline. - (unless (bolp) - (insert "\n")))) - (goto-char (point-max)) - (insert "\n")) - (when (or link enclosure) - (insert "\n"))) - (when link - (insert link "\n")) - (when enclosure - (insert (car enclosure) " " - (nth 2 enclosure) " " - (nth 3 enclosure) "\n")) - (when comments - (insert comments "\n")) - (setq body (buffer-substring body (point))) + (insert "<#multipart type=alternative>\n") + ;; If text contains HTML, don't generate a text/plain part + ;; FIXME: The regexp is not very smart. A regexp probably isn't + ;; the right thing to use anyhow. It means any article which has + ;; had "

" inserted by nnrss-check-group will have no + ;; text/plain part. + (if (and text + (not (string-match "<[a-zA-Z]+[^>]*>" text))) + (progn + (insert "<#part type=\"text/plain\">\n") + (setq body (point)) + (when text + (insert text) + (goto-char body) + ;; See `nnrss-check-group', which inserts "

". + (if (search-forward "

" nil t) + (if (eobp) + (replace-match "\n") + (replace-match "\n\n") + (let ((fill-column default-fill-column) + (window (get-buffer-window nntp-server-buffer))) + (when window + (setq fill-column + (max 1 (/ (* (window-width window) 7) 8)))) + (fill-region (point) (point-max)) + (goto-char (point-max)) + ;; XEmacs version of `fill-region' inserts newline. + (unless (bolp) + (insert "\n")))) + (goto-char (point-max)) + (insert "\n")) + (when (or link enclosure) + (insert "\n"))) + (when link + (insert link "\n")) + (when enclosure + (insert (car enclosure) " " + (nth 2 enclosure) " " + (nth 3 enclosure) "\n")) + (when comments + (insert comments "\n")) + (setq body (buffer-substring body (point))))) (insert "<#/part>\n" "<#part type=\"text/html\">\n" "\n") --=-=-=--