* exporter: How to get :file property on a src block in an exporter @ 2021-12-21 21:26 Yasushi SHOJI 2021-12-22 14:34 ` Ihor Radchenko 0 siblings, 1 reply; 7+ messages in thread From: Yasushi SHOJI @ 2021-12-21 21:26 UTC (permalink / raw) To: emacs-org list Hi, I'm writing an exporter and I'd like to get :file property on a src block. Let's say I have the following src block in an org file. #+BEGIN_SRC ditaa :file images/hello-world.png :exports code +--------------+ | Hello World! | +--------------+ #+END_SRC" And, say, I'm writing a function for my exporter: (defun org-myexporter-src-block (src-block contents info) (let ((file (xxxxxxx yyy))))) How can I get "images/hello-world.png" in org-myexporter-src-block? Thanks, -- yashi ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: exporter: How to get :file property on a src block in an exporter 2021-12-21 21:26 exporter: How to get :file property on a src block in an exporter Yasushi SHOJI @ 2021-12-22 14:34 ` Ihor Radchenko 2021-12-22 15:52 ` Yasushi SHOJI 0 siblings, 1 reply; 7+ messages in thread From: Ihor Radchenko @ 2021-12-22 14:34 UTC (permalink / raw) To: Yasushi SHOJI; +Cc: emacs-org list Yasushi SHOJI <yasushi.shoji@gmail.com> writes: > Hi, > > I'm writing an exporter and I'd like to get :file property on a src block. > Let's say I have the following src block in an org file. > ... > How can I get "images/hello-world.png" in org-myexporter-src-block? See org-babel-get-src-block-info. It can accept the parsed src-block element. Best, Ihor ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: exporter: How to get :file property on a src block in an exporter 2021-12-22 14:34 ` Ihor Radchenko @ 2021-12-22 15:52 ` Yasushi SHOJI 2021-12-22 16:07 ` Yasushi SHOJI 0 siblings, 1 reply; 7+ messages in thread From: Yasushi SHOJI @ 2021-12-22 15:52 UTC (permalink / raw) To: Ihor Radchenko; +Cc: emacs-org list Hi Ihor, On Wed, Dec 22, 2021 at 11:32 PM Ihor Radchenko <yantar92@gmail.com> wrote: > Yasushi SHOJI <yasushi.shoji@gmail.com> writes: > > I'm writing an exporter and I'd like to get :file property on a src block. > > Let's say I have the following src block in an org file. > > ... > > How can I get "images/hello-world.png" in org-myexporter-src-block? > > See org-babel-get-src-block-info. It can accept the parsed src-block element. This is what I got from (org-bable-get-src-block-info nil src-block) ("ditaa" "+--------------+\n| Hello World! |\n+--------------+" ((:colname-names) (:rowname-names) (:result-params "replace") (:result-type . value) (:results . "replace") (:exports . "code") (:tangle . "no") (:hlines . "no") (:noweb . "no") (:cache . "no") (:session . "none")) "" nil 41 "(ref:%s)") I don't see :file in it. What am I missing? I've been reading org-element-src-block-parser, but I'm not sure it's parsing `:file` as ob does. How does org-bable-execute:ditaa gets params, which I can get :file from? I seems to me org-babel-exp-src-block -> org-babel-get-src-block-info -> org-bable-exp-do-export -> .... Then, why don't I have :file in the info? Thank you for your time. -- yashi ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: exporter: How to get :file property on a src block in an exporter 2021-12-22 15:52 ` Yasushi SHOJI @ 2021-12-22 16:07 ` Yasushi SHOJI 2021-12-22 18:22 ` Berry, Charles 0 siblings, 1 reply; 7+ messages in thread From: Yasushi SHOJI @ 2021-12-22 16:07 UTC (permalink / raw) To: Ihor Radchenko; +Cc: emacs-org list On Thu, Dec 23, 2021 at 12:52 AM Yasushi SHOJI <yasushi.shoji@gmail.com> wrote: > Then, why don't I have :file in the info? The :exports must be "file" to have the file name in the info. I used to have "code" because I wanted to export code with the file name as an attribute. I think I can work on it. Thanks Ihor for your hint! Best regards, -- yashi ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: exporter: How to get :file property on a src block in an exporter 2021-12-22 16:07 ` Yasushi SHOJI @ 2021-12-22 18:22 ` Berry, Charles 2021-12-22 22:16 ` Yasushi SHOJI 0 siblings, 1 reply; 7+ messages in thread From: Berry, Charles @ 2021-12-22 18:22 UTC (permalink / raw) To: Yasushi SHOJI; +Cc: emacs-org list > On Dec 22, 2021, at 8:07 AM, Yasushi SHOJI <yasushi.shoji@gmail.com> wrote: > > On Thu, Dec 23, 2021 at 12:52 AM Yasushi SHOJI <yasushi.shoji@gmail.com> wrote: >> Then, why don't I have :file in the info? > > The :exports must be "file" to have the file name in the info. I used > to have "code" because > I wanted to export code with the file name as an attribute. > I don't see that here: #+begin_src emacs-lisp :exports code :file abc (assq :file (caddr (org-babel-get-src-block-info 'light))) #+end_src #+RESULTS: : (:file . abc) --- Another problem for you: `org-export-as' runs `org-babel-exp-process-buffer' *before* it parses the buffer and the header args get stripped from the copy buffer at that time. So you need to find a way to get the :file header arg whilst babel runs and hang onto it for later use. This can be a tricky business. HTH, Chuck > I think I can work on it. > > Thanks Ihor for your hint! > > Best regards, > -- > yashi > > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: exporter: How to get :file property on a src block in an exporter 2021-12-22 18:22 ` Berry, Charles @ 2021-12-22 22:16 ` Yasushi SHOJI 2021-12-23 2:28 ` Berry, Charles 0 siblings, 1 reply; 7+ messages in thread From: Yasushi SHOJI @ 2021-12-22 22:16 UTC (permalink / raw) To: Berry, Charles; +Cc: emacs-org list Hi, On Thu, Dec 23, 2021 at 3:22 AM Berry, Charles <ccberry@health.ucsd.edu> wrote: > > On Dec 22, 2021, at 8:07 AM, Yasushi SHOJI <yasushi.shoji@gmail.com> wrote: > > On Thu, Dec 23, 2021 at 12:52 AM Yasushi SHOJI <yasushi.shoji@gmail.com> wrote: > >> Then, why don't I have :file in the info? > > > > The :exports must be "file" to have the file name in the info. I used > > to have "code" because > > I wanted to export code with the file name as an attribute. > > I don't see that here: > > #+begin_src emacs-lisp :exports code :file abc > (assq :file (caddr (org-babel-get-src-block-info 'light))) > #+end_src > > #+RESULTS: > : (:file . abc) Indeed, this one works. But I don't see :file, or the whole :parameters in the info arg passed to my function. > `org-export-as' runs `org-babel-exp-process-buffer' *before* it parses the buffer and the header args get stripped from the copy buffer at that time. Would you mind telling me where the stripping part is in the code, and the reason why it strips? > So you need to find a way to get the :file header arg whilst babel runs and hang onto it for later use. I'm still learning but :parameters, which holds :file, are already gone from the info arg when org-myexporter-src-block is called. Thanks, -- yashi ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: exporter: How to get :file property on a src block in an exporter 2021-12-22 22:16 ` Yasushi SHOJI @ 2021-12-23 2:28 ` Berry, Charles 0 siblings, 0 replies; 7+ messages in thread From: Berry, Charles @ 2021-12-23 2:28 UTC (permalink / raw) To: Yasushi SHOJI; +Cc: emacs-org list > On Dec 22, 2021, at 2:16 PM, Yasushi SHOJI <yasushi.shoji@gmail.com> wrote: > > Hi, > > On Thu, Dec 23, 2021 at 3:22 AM Berry, Charles <ccberry@health.ucsd.edu> wrote: >>> On Dec 22, 2021, at 8:07 AM, Yasushi SHOJI <yasushi.shoji@gmail.com> wrote: >>> On Thu, Dec 23, 2021 at 12:52 AM Yasushi SHOJI <yasushi.shoji@gmail.com> wrote: >>>> Then, why don't I have :file in the info? >>> >>> The :exports must be "file" to have the file name in the info. I used >>> to have "code" because >>> I wanted to export code with the file name as an attribute. >> >> I don't see that here: >> >> #+begin_src emacs-lisp :exports code :file abc >> (assq :file (caddr (org-babel-get-src-block-info 'light))) >> #+end_src >> >> #+RESULTS: >> : (:file . abc) > > Indeed, this one works. But I don't see :file, or the whole > :parameters in the info arg passed to my function. Of course. Your function is called after the buffer is parsed. > >> `org-export-as' runs `org-babel-exp-process-buffer' *before* it parses the buffer and the header args get stripped from the copy buffer at that time. > > Would you mind telling me where the stripping part is in the code, and > the reason why it strips? '...at that time' was meant to refer to when `org-babel-exp-process-buffer' runs. So look there. Why? I didn't have a hand in that decision, but my guess is that almost always the header args are only useful in babel per se, so there is no reason to hang onto them. > >> So you need to find a way to get the :file header arg whilst babel runs and hang onto it for later use. > > I'm still learning but :parameters, which holds :file, are already > gone from the info arg when org-myexporter-src-block is called. > That is what I tried to say. Best, Chuck ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-12-23 2:29 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2021-12-21 21:26 exporter: How to get :file property on a src block in an exporter Yasushi SHOJI 2021-12-22 14:34 ` Ihor Radchenko 2021-12-22 15:52 ` Yasushi SHOJI 2021-12-22 16:07 ` Yasushi SHOJI 2021-12-22 18:22 ` Berry, Charles 2021-12-22 22:16 ` Yasushi SHOJI 2021-12-23 2:28 ` Berry, Charles
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.