On Mon, Dec 12, 2016 at 12:16 PM, Charles C. Berry <ccbe...@ucsd.edu> wrote:
> On Mon, 12 Dec 2016, Matt Price wrote: > > > [snip] > > >> My questions are: >> 1. can I pass this html attribute to the <pre><code> block somehow? >> > > Yes. > > ATTR_HTML doesn't seem to work. Is this a bug? If so, should I try to fix >> it? >> > > No and no. > > Did you try > > : (plist-get (cadr src-block) :attr_html) > > in `org-html-src-block' ? > > ah, ok. Now I will reveal some of the depths of my ignorance. Looks like :attr_html is a plist (right?). (a) what is the appropriate way to identify an attribute here. should I write, e.g.: #+ATTR_HTML: :data-external-libs "http://underscorejs.org/underscore-min.js" :class "list of classes" or: #+ATTR_HTML: data-external-libs "http://underscorejs.org/underscore-min.js" class "list of classes" or #+ATTR_HTML: "data-external-libs" "http://underscorejs.org/underscore-min.js" "class" "list of classes" And then, if I want to transform this into: data-external-libs="http://underscorejs.org/underscore-min.js" class="list of classes" can I just do something like: (let ((attributes (org-export-get-attribute :attr_html src-block)) (cl-loop for (key value) in attributes (collect (concat key "=" "\"" value "\" " )))) or do I need to transform the key into a string first? I'm sorry to be writing such basic lisp questions; obviously I need to read a really good lisp introduction, but I haven't found one yet. > > If not, is there a simple way to use header arguments to pass >> information down? >> > > The answer is still no. ;-) > > There are complicated ways. See > > https://github.com/chasberry/orgmode-accessories/blob/ravel- > lang/ox-ravel.org > > for one such. But for what you are doing ATTR_HTML is easiest. > > I will take the easiest please! > > I am already rewriting the exporter's src-block export >> function, so I can try to accomplish what I need to in that context. >> > > BTW, the cleanest way to do this is by writing a derived exporter: > > : (org-export-define-derived-backend 'reveal 'revealplus ... > > In your case you only provide the src-block entry for the > :translate-alist, :options-alist entries for any you redefine or introduce, > and optionally a :menu-entry. > > Also, you'll probably want to add a hook to `org-export-before-parsing-hook' > (see below). > > > If you do this, then `#+ATTR_REVEALPLUS:' seems suitable. > right. Up till now I have been hoping to integrate these change sback into ox-reveal, but now it's starting to feel a bit invasive. I may try this route. > > 2. I'd like to be able to test my code directly in org (since I'm a lousy >> coder and a clumsy typist). Can I tell org to load other files before >> executing a src block? >> > > Yes. Depending on what you want one of these: > > * Add this to `org-export-before-parsing-hook', perhaps in setting up a > derived exporter. > > * Or perhaps by using a local variable `eval' see > > : (info "(emacs) Specifying File Variables") > > * Or by executing a src-block that loads those files. > I think this might be the best route, since I would probably want to load such files on a block-by-block basis. > > HTH, > > Chuck > very much, I think!