Add support for SVG images
authorRüdiger Sonderfeld <ruediger@c-plusplus.de>
Sun, 16 Jun 2013 14:18:02 +0000 (16:18 +0200)
committerLars Magne Ingebrigtsen <larsi@gnus.org>
Sun, 16 Jun 2013 14:18:02 +0000 (16:18 +0200)
* shr.el (shr-dom-to-xml): (shr-dom-to-xml): New function.
(shr-tag-svg): Add support for the SVG tag.

lisp/ChangeLog
lisp/shr.el

index 7a1d4b1..2b2b63c 100644 (file)
@@ -1,3 +1,8 @@
+2013-06-16  Rüdiger Sonderfeld  <ruediger@c-plusplus.de>
+
+       * shr.el (shr-dom-to-xml): (shr-dom-to-xml): New function.
+       (shr-tag-svg): Add support for the SVG tag.
+
 2013-06-16  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
        * shr.el (shr-expand-url): Respect // URLs.
index 7ed5778..5173908 100644 (file)
@@ -905,8 +905,31 @@ ones, in case fg and bg are nil."
 (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)))