emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Cook, Malcolm" <MEC@stowers.org>
To: "'Charles C. Berry'" <ccberry@ucsd.edu>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: capture htmlwidgets for export - a pattern in search of a new :results type???
Date: Wed, 29 Jul 2015 00:08:44 +0000	[thread overview]
Message-ID: <9f3c40e52cdd4e2aa752f01d7733812a@exchsrv2.sgc.loc> (raw)
In-Reply-To: <alpine.OSX.2.11.1507281417430.1057@charles-berrys-macbook.local>

> On Tue, 28 Jul 2015, Cook, Malcolm wrote:
> 
> > I have been playing with exporting htmlwidgets [1] generated in R code-
> blocks.
> >
> 
> [snip: proposal for new :results format to accomodate repetitive codes]
> 
> 
> >
> > Perhaps there is  a better or more useful abstraction.
> >
> > Or a better workaround than simply following the pattern when needed
> (which is not too hard anyway).
> >
> > Any ideas along these lines?
> 
> See
> 
>  	(info "(org) Noweb reference syntax")
> 
> for one way to handle repetitive codes.
> 
> Alternately, header args :var, :post, :prologue and/or :epilogue could be used
> to crystallize your code.

Excellent!  Glad to be directed to these.  The combination of all of them gets me over the fence:

#+name: iframe
#+begin_src sh :var it="" :var height="700px" :var width="700px" :results output :exports none
       printf "<iframe src=%s height=%s width=%s >" $it $height $width
#+end_src

#+header: :prologue {file="d3heatmap_widget.html"; saveWidget({
#+header: :epilogue },file) ;file}
#+BEGIN_SRC R :session *R* :results html :exports both :post iframe(it=*this*,height="800px" width="800px")
library(htmlwidgets)
library(d3heatmap)
d3heatmap(mtcars, scale="column", colors="Greens")
#+END_SRC

#+RESULTS:
#+BEGIN_HTML
<iframe src=d3heatmap_widget.html height=800px width=700px >
#+END_HTML


I don't really care for all the verbosity of the header, but the effect is perfect.  The code block does not contain ANY extra org-mode export-specific cruft.

TH,

Malcolm

> 
> One other alternative is to write an R function that creates the extra markup.
> 
> HTH,
> 
> Chuck

      reply	other threads:[~2015-07-29  0:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-28 19:29 capture htmlwidgets for export - a pattern in search of a new :results type??? Cook, Malcolm
2015-07-28 21:34 ` Charles C. Berry
2015-07-29  0:08   ` Cook, Malcolm [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9f3c40e52cdd4e2aa752f01d7733812a@exchsrv2.sgc.loc \
    --to=mec@stowers.org \
    --cc=ccberry@ucsd.edu \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).