[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] export to single html file (like reveal_single_file:t) in regula
From: |
John Kitchin |
Subject: |
Re: [O] export to single html file (like reveal_single_file:t) in regular html export |
Date: |
Sat, 26 Nov 2016 07:56:13 -0500 |
User-agent: |
mu4e 0.9.16; emacs 25.1.50.1 |
Here is some code lightly modified from a comment by Evgeny here:
http://kitchingroup.cheme.cmu.edu/blog/2016/10/29/Sending-html-emails-from-org-mode-with-org-mime/
It seems to do what you want. Of course, I only tested it with one
image, one time, so I hope it works for you too! It assumes png, but it
would not be too hard to generalize.
#+BEGIN_SRC emacs-lisp
(defun org-image-data-uri (path)
(let ((data (with-temp-buffer (insert-file-contents path) (buffer-string))))
(concat "<img src=\""
"data:image/png;charset=utf-8;base64,"
(base64-encode-string (encode-coding-string data 'binary) t)
"\"/>")))
(defun my-link (link contents info)
(let ((type (org-element-property :type link))
(path (org-element-property :path link)))
(if (and (string= type "file")
(f-ext? path "png"))
(org-image-data-uri path)
(org-html-link link contents info))))
(org-export-define-derived-backend 'my-html 'html
:translate-alist '((link . my-link)))
(browse-url (org-export-to-file 'my-html "embedded-image.html"))
#+END_SRC
Xebar Saram writes:
> ping anyone :) gotta prepare new assignments for students next week :)
>
> On Sat, Nov 19, 2016 at 7:46 AM, Xebar Saram <address@hidden> wrote:
>
>> Hi all
>>
>> i love the option in org revel (reveal_single_file:t) that allows me to
>> export a presentation to my students with image support embedded in the
>> html file./
>>
>> ive searched for a way to do it in the normal org to html exporter with no
>> success. any clue how that can be done?
>>
>> best
>>
>> Z
>>
--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu