>From 23776bb643354aaaba09289300fc5c79ce747f4c Mon Sep 17 00:00:00 2001 From: Jarmo Hurri Date: Sun, 24 Jul 2016 16:37:21 +0300 Subject: [PATCH] lisp/ox-html.el: Embed SVG images with tag instead of * lisp/ox-html.el (org-html--svg-image): Embed SVG file using tag, providing fallbacks for cases where SVG is not supported or SVG file is missing. Also provide CSS class org-svg for customizing presentation of embedded SVG images. * doc/org.texi (CSS support): Documentation of CSS class org-svg for SVG images embedded into exported HTML. --- doc/org.texi | 1 + lisp/ox-html.el | 18 +++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 1c3868c..c53d1c6 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -11750,6 +11750,7 @@ div.footnotes @r{footnote section headline} p.footnote @r{footnote definition paragraph, containing a footnote} .footref @r{a footnote reference number (always a )} .footnum @r{footnote number in footnote definition (always )} +.org-svg @r{linked SVG image} @end example @vindex org-html-style-default diff --git a/lisp/ox-html.el b/lisp/ox-html.el index ce4694d..f5b5497 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -1628,21 +1628,21 @@ a communication channel." info))) (defun org-html--svg-image (source attributes info) - "Return \"object\" appropriate for embedding svg file SOURCE -with assoicated ATTRIBUTES. INFO is a plist used as a + "Return \"img\" appropriate for embedding svg file SOURCE +with associated ATTRIBUTES. INFO is a plist used as a communication channel. The special attribute \"fallback\" can be used to specify a fallback -image file to use if the object embedding is not supported." +image file to use if svg display is not supported." (let ((fallback (plist-get attributes :fallback)) (attrs (org-html--make-attribute-string (plist-put attributes :fallback nil)))) - (format "\n%s" - source attrs - (if fallback - (org-html-close-tag - "img" (format "src=\"%s\" %s" fallback attrs) info) - "Sorry, your browser does not support SVG.")))) + (format "" + source attrs + (if fallback + (format "onerror=\"this.src='%s'; this.onerror=null;\"" + fallback) + "alt=\"Sorry, your browser does not support SVG.\"")))) (defun org-html--textarea-block (element) "Transcode ELEMENT into a textarea block. -- 2.4.11