From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: embed base64 encoded images in exported html Date: Mon, 23 Apr 2012 12:35:41 -0400 Message-ID: <878vhmxv6q.fsf@gmx.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:39397) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SMO7H-0003vp-My for emacs-orgmode@gnu.org; Mon, 23 Apr 2012 14:36:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SMO7C-0001fY-UF for emacs-orgmode@gnu.org; Mon, 23 Apr 2012 14:36:03 -0400 Received: from mailout-us.gmx.com ([74.208.5.67]:36850 helo=mailout-us.mail.com) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1SMO7C-0001cj-Nm for emacs-orgmode@gnu.org; Mon, 23 Apr 2012 14:35:58 -0400 In-Reply-To: (Noah Hoffman's message of "Mon, 23 Apr 2012 10:33:24 -0700") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Noah Hoffman Cc: emacs-orgmode@gnu.org Noah Hoffman writes: > Hello - > > I am trying to export a monolithic html file by embedding > base64-encoded images, and I can't quite figure out how to prevent the > output from being escaped in one way or another... here's an example > of one permutation that doesn't do exactly what I want: > > #+BEGIN_SRC R :results output > png('plot.png') > plot(1:10) > invisible(dev.off()) > list.files(pattern = '*.png') > #+END_SRC > > #+RESULTS: > : [1] "plot.png" > > #+BEGIN_SRC python :results output raw :exports results > with open('plot.png', 'rb') as image: > data = image.read() > print '' % data.encode("base64") > #+END_SRC > > #+RESULTS: > file. Can anyone suggest how I might do this? I'm using emacs 23.4.1, > org-mode 7.8.03 > Hi Noah, To include raw html in an Org-mode file you can use either the single line #+HTML: escape or wrap it in a being/end html block, so adjusting your example above would yield #+BEGIN_SRC python :results output raw :exports results with open('plot.png', 'rb') as image: data = image.read() print '#+HTML: ' % data.encode("base64") #+END_SRC or #+BEGIN_SRC python :results output html :exports results with open('plot.png', 'rb') as image: data = image.read() print '' % data.encode("base64") #+END_SRC Best, > > Thanks a lot, > Noah > -- Eric Schulte http://cs.unm.edu/~eschulte/