emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] embed base64 encoded images in exported html


From: Noah Hoffman
Subject: [O] embed base64 encoded images in exported html
Date: Mon, 23 Apr 2012 10:33:24 -0700

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 '<img src="data:image/png;base64,%s">' % data.encode("base64")
#+END_SRC

#+RESULTS:
<img 
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAeAAAAHgCAMAAABKCk6nAAACuFBMVEUAAAABAQEDAwMEBAQHBwcJ
CQkKCgoMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwf
Hx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjI0
NDQ4ODg5OTk6Ojo7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJDQ0NERERFRUVGRkZHR0dISEhJSUlK
SkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVXV1dYWFhZWVlaWlpbW1tcXFxdXV1e

<remainder truncated>

Here the "results" block is not exposed as raw html in the exported
file. Can anyone suggest how I might do this? I'm using emacs 23.4.1,
org-mode 7.8.03

Thanks a lot,
Noah



reply via email to

[Prev in Thread] Current Thread [Next in Thread]