From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Charles C. Berry" Subject: Re: including external file in src block execution; ATTR_HTML on src blocks Date: Mon, 12 Dec 2016 19:52:23 -0800 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:40835) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cGe96-0003QE-Uj for emacs-orgmode@gnu.org; Mon, 12 Dec 2016 22:52:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cGe93-00025v-T5 for emacs-orgmode@gnu.org; Mon, 12 Dec 2016 22:52:53 -0500 Received: from iport-acv2-out.ucsd.edu ([132.239.0.174]:33806) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1cGe93-000257-FE for emacs-orgmode@gnu.org; Mon, 12 Dec 2016 22:52:49 -0500 In-Reply-To: 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" To: Matt Price Cc: Org Mode On Mon, 12 Dec 2016, Matt Price wrote: > On Mon, Dec 12, 2016 at 12:16 PM, Charles C. Berry wrote: > >> On Mon, 12 Dec 2016, Matt Price wrote: >> >> >> [snip] >> >> >>> My questions are: >>> 1. can I pass this html attribute to the
 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?).

No, it is a property name. (cadr src-block) is the plist.

See (info "(elisp) Property Lists")


> (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"

Any could be made to work, but I'd use (a). Then

: (org-babel-parse-header-arguments
:  (car (plist-get (cadr src-block) :attr_html)))

will give you

: ((: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?

Well, I'd just try it and see.

> 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.
>

This is what I use:

* Elisp: (elisp).               The Emacs Lisp Reference Manual.
* Emacs Lisp Intro: (eintr).    A simple introduction to Emacs Lisp programming.

and ample Googling, usually leading to StackOverflow, to get hints on 
stuff I am fuzzy on. And I read docstrings over and over and ...

Best,

Chuck