diff options
author | Rick Frankel <rick@rickster.com> | 2014-01-16 11:08:06 -0500 |
---|---|---|
committer | Rick Frankel <rick@rickster.com> | 2014-01-16 17:35:55 -0500 |
commit | e955be903a5cf29f173972ab18f851f8553ddd89 (patch) | |
tree | cea741e74ed8f916d2e2c6edcf136e24f99b4323 | |
parent | 1376df264888a3bd3afa645e1bb5e01ed2b82404 (diff) | |
download | org-mode-e955be903a5cf29f173972ab18f851f8553ddd89.tar.gz |
Add better svg support to html exporter.
* lisp/ox-html.el (org-html--format-image): If image is an svg file,
format as "object" using new function `org-html--svg-image' instead
of "img".
-rw-r--r-- | lisp/ox-html.el | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/lisp/ox-html.el b/lisp/ox-html.el index a01d913..8ea9e65 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -1406,17 +1406,36 @@ SOURCE is a string specifying the location of the image. ATTRIBUTES is a plist, as returned by `org-export-read-attribute'. INFO is a plist used as a communication channel." - (org-html-close-tag - "img" - (org-html--make-attribute-string - (org-combine-plists - (list :src source - :alt (if (string-match-p "^ltxpng/" source) - (org-html-encode-plain-text - (org-find-text-property-in-string 'org-latex-src source)) - (file-name-nondirectory source))) - attributes)) - info)) + (if (string= "svg" (file-name-extension source)) + (org-html--svg-image source attributes info) + (org-html-close-tag + "img" + (org-html--make-attribute-string + (org-combine-plists + (list :src source + :alt (if (string-match-p "^ltxpng/" source) + (org-html-encode-plain-text + (org-find-text-property-in-string 'org-latex-src source)) + (file-name-nondirectory source))) + attributes)) + 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 +communication channel. + +The special attribute \"fallback\" can be used to specify a fallback +image file to use if the object embedding is not supported." + (let ((fallback (plist-get attributes :fallback)) + (attrs (org-html--make-attribute-string + (plist-put attributes :fallback nil)))) + (format "<object type=\"image/svg+xml\" data=\"%s\" %s>\n%s</object>" + source attrs + (if fallback + (org-html-close-tag + "img" (format "src=\"%s\" %s" fallback attrs) info) + "Sorry, your browser does not support SVG.")))) (defun org-html--textarea-block (element) "Transcode ELEMENT into a textarea block. |