Gnus development mailing list
 help / color / mirror / Atom feed
From: "Rüdiger Sonderfeld" <ruediger@c-plusplus.de>
To: ding@gnus.org
Cc: larsi@gnus.org
Subject: [PATCH] shr.el: Add support for SVG elements.
Date: Thu, 13 Jun 2013 06:21:59 +0200	[thread overview]
Message-ID: <2078521.h7ZcY5jiiK@descartes> (raw)

* lisp/shr.el (shr-dom-to-xml): New function.
  (shr-tag-svg): Add support for the SVG tag.

Signed-off-by: Rüdiger Sonderfeld <ruediger@c-plusplus.de>
---
 lisp/shr.el | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/lisp/shr.el b/lisp/shr.el
index 0a2c698..68ed95c 100644
--- a/lisp/shr.el
+++ b/lisp/shr.el
@@ -891,8 +891,31 @@ (defun shr-tag-script (cont)
 (defun shr-tag-comment (cont)
   )
 
+(defun shr-dom-to-xml (dom)
+  "Convert DOM into a string containing the xml representation."
+  (let ((arg " ")
+        (text ""))
+    (dolist (sub (cdr dom))
+      (cond
+       ((listp (cdr sub))
+        (setq text (concat text (dom-to-text sub))))
+       ((eq (car sub) 'text)
+        (setq text (concat text (cdr sub))))
+       (t
+        (setq arg (concat arg (format "%s=\"%s\" "
+                                      (substring (symbol-name (car sub)) 1)
+                                      (cdr sub)))))))
+    (format "<%s%s>%s</%s>"
+            (car dom)
+            (substring arg 0 (1- (length arg)))
+            text
+            (car dom))))
+
 (defun shr-tag-svg (cont)
-  )
+  (when (image-type-available-p 'svg)
+    (funcall shr-put-image-function
+             (shr-dom-to-xml (cons 'svg cont))
+             "SVG Image")))
 
 (defun shr-tag-sup (cont)
   (let ((start (point)))
-- 
1.8.3




             reply	other threads:[~2013-06-13  4:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-13  4:21 Rüdiger Sonderfeld [this message]
2013-06-16 14:18 ` Lars Magne Ingebrigtsen
2013-06-16 15:14   ` [PATCH] shr.el: Fix function call to `shr-dom-to-xml' Rüdiger Sonderfeld
2013-06-16 15:31     ` Lars Magne Ingebrigtsen

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2078521.h7ZcY5jiiK@descartes \
    --to=ruediger@c-plusplus.de \
    --cc=ding@gnus.org \
    --cc=larsi@gnus.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.
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 NNTP newsgroup(s).