[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] update on missing :parameters in code blocks
From: |
John Kitchin |
Subject: |
[O] update on missing :parameters in code blocks |
Date: |
Sun, 21 Sep 2014 18:31:10 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (darwin) |
I did some more digging on the missing :parameters during export, and it
seems that the src block itself is different during export than in the
buffer. Below illustrates what I mean. In the buffer, if I look at the
contents of the code block using output from org-element-at-point, it
looks as I expect, with the complete header. But, using the same method
in the export, it is clear that the header args are not there.
I have not figured out where they disappear yet.
* Bug report 2 for org-mode
Here is a named table
#+tblname: tbl-data
| x | y |
|---+---|
| 1 | 1 |
| 2 | 4 |
| 3 | 9 |
Here is a named src-block with a defined var
#+name: print-table
#+BEGIN_SRC python :var data=tbl-data :results value
return data
#+END_SRC
Now, we illustrate that the src-block does have :parameters.
#+name: get-properties
#+BEGIN_SRC emacs-lisp
(save-excursion
(re-search-backward "#\\+name: print-table")
(buffer-substring
(org-element-property :begin (org-element-at-point))
(org-element-property :end (org-element-at-point))))
#+END_SRC
#+RESULTS: get-properties
: #+name: print-table
: #+BEGIN_SRC python :var data=tbl-data :results value
: return data
: #+END_SRC
:
:
In the export machinery, though it appears the src-block is not the same.
#+BEGIN_SRC emacs-lisp :results output :exports none
(defun my-src-block (src-block contents info)
(princ (buffer-substring
(org-element-property :begin src-block)
(org-element-property :end src-block)))
(org-export-format-code-default src-block info))
(org-export-define-derived-backend 'my-html 'html
:translate-alist '((src-block . my-src-block)))
(org-export-to-file 'my-html "custom-src-table-export.html")
#+END_SRC
#+RESULTS:
#+begin_example
#+name: print-table
#+BEGIN_SRC python
return data
#+END_SRC
#+name: get-properties
#+BEGIN_SRC emacs-lisp
(save-excursion
(re-search-backward "#\\+name: print-table")
(buffer-substring
(org-element-property :begin (org-element-at-point))
(org-element-property :end (org-element-at-point))))
#+END_SRC
#+end_example
The parameters seem to be gone in the python block.
--
-----------------------------------
John Kitchin
http://kitchingroup.cheme.cmu.edu
- [O] update on missing :parameters in code blocks,
John Kitchin <=
Re: [O] update on missing :parameters in code blocks, Aaron Ecay, 2014/09/21