emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: John Kitchin <jkitchin@andrew.cmu.edu>
To: emacs-orgmode@gnu.org
Subject: update on missing :parameters in code blocks
Date: Sun, 21 Sep 2014 18:31:10 -0400	[thread overview]
Message-ID: <m261ggvc5t.fsf@andrew.cmu.edu> (raw)

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

             reply	other threads:[~2014-09-21 22:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-21 22:31 John Kitchin [this message]
2014-09-22  2:38 ` update on missing :parameters in code blocks 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m261ggvc5t.fsf@andrew.cmu.edu \
    --to=jkitchin@andrew.cmu.edu \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).