From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/83060 Path: news.gmane.org!not-for-mail From: David Edmondson Newsgroups: gmane.emacs.gnus.general Subject: and shr Date: Thu, 11 Apr 2013 11:37:20 +0100 Organization: none Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: ger.gmane.org 1365676717 25666 80.91.229.3 (11 Apr 2013 10:38:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 11 Apr 2013 10:38:37 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M31326@lists.math.uh.edu Thu Apr 11 12:38:39 2013 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UQEtq-0001eU-PT for ding-account@gmane.org; Thu, 11 Apr 2013 12:38:39 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1UQEss-0001Sd-BU; Thu, 11 Apr 2013 05:37:38 -0500 Original-Received: from mx2.math.uh.edu ([129.7.128.33]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1UQEso-0001SE-Ii for ding@lists.math.uh.edu; Thu, 11 Apr 2013 05:37:34 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1UQEsm-0003b2-Ms for ding@lists.math.uh.edu; Thu, 11 Apr 2013 05:37:33 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]) by quimby.gnus.org with esmtp (Exim 4.72) (envelope-from ) id 1UQEsj-0007xm-Vb for ding@gnus.org; Thu, 11 Apr 2013 12:37:29 +0200 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UQEsi-0008C1-5Q for ding@gnus.org; Thu, 11 Apr 2013 12:37:28 +0200 Original-Received: from disaster-area.hh.sledj.net ([81.149.164.25]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 11 Apr 2013 12:37:28 +0200 Original-Received: from dme by disaster-area.hh.sledj.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 11 Apr 2013 12:37:28 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 58 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: disaster-area.hh.sledj.net Cancel-Lock: sha1:P3CDoRo0yRnZ9E/4uH0NZhicEPE= X-Spam-Score: -4.3 (----) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:83060 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Here is a rudimentary patch to support the display of images inlined using data: URIs. It works in the few cases that I have available to test, but would benefit from examination and improvement, I'm sure. diff --git a/lisp/shr.el b/lisp/shr.el index 5df5297..0cf8d39 100644 =2D-- a/lisp/shr.el +++ b/lisp/shr.el @@ -593,6 +593,20 @@ size, and full-buffer size." (put-text-property start (point) type value)))))))))) (kill-buffer image-buffer))) =20 +(defun shr-image-from-data (data) + "Return an image from the data: URI content DATA." + (when (string-match "\\([a-z]+/[a-z]+\\)\\(;[a-z0-9]+\\)?,\\(.*\\)" data) + (let ((content-type (match-string 1 data)) + (encoding (match-string 2 data)) + (payload (match-string 3 data))) + (cond + ((string=3D encoding "")) + ((string=3D encoding ";base64") + (setq payload (base64-decode-string payload))) + (t + (error "Unknown inline data encoding: %s" encoding))) + payload))) + (defun shr-put-image (data alt &optional flags) "Put image DATA with a string ALT. Return image." (if (display-graphic-p) @@ -983,6 +997,12 @@ ones, in case fg and bg are nil." ;; Ignore zero-sized or single-pixel images. ) ((and (not shr-inhibit-images) + (string-match "\\`data:" url)) + (let ((image (shr-image-from-data (substring url (match-end 0))))) + (if image + (funcall shr-put-image-function image alt) + (insert alt)))) + ((and (not shr-inhibit-images) (string-match "\\`cid:" url)) (let ((url (substring url (match-end 0))) image) --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlFmkmAACgkQaezQq/BJZRaSCgCghlFoKY5iMceyGu7D3Jo8L1nT TUwAnRi1UOE+yqk4Rps6DTe2fQvP3sDA =A3Z5 -----END PGP SIGNATURE----- --=-=-=--