emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* update on missing :parameters in code blocks
@ 2014-09-21 22:31 John Kitchin
  2014-09-22  2:38 ` Charles Berry
  2014-09-22  2:39 ` Aaron Ecay
  0 siblings, 2 replies; 8+ messages in thread
From: John Kitchin @ 2014-09-21 22:31 UTC (permalink / raw)
  To: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-09-22 21:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-21 22:31 update on missing :parameters in code blocks John Kitchin
2014-09-22  2:38 ` Charles Berry
2014-09-22 16:43   ` John Kitchin
2014-09-22 17:10     ` Nicolas Goaziou
2014-09-22 20:50       ` John Kitchin
2014-09-22 21:24         ` Nicolas Goaziou
2014-09-22  2:39 ` Aaron Ecay
2014-09-22 16:40   ` John Kitchin

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