From: John Kitchin <jkitchin@andrew.cmu.edu>
To: emacs-orgmode@gnu.org
Subject: filter for src-block export question
Date: Sat, 20 Sep 2014 19:33:59 -0400 [thread overview]
Message-ID: <m2k34xhno8.fsf@andrew.cmu.edu> (raw)
I have noticed that when code blocks have input variables, e.g.
#+tblname: tbl-data
| x | y |
|---+---|
| 1 | 1 |
| 2 | 4 |
| 3 | 9 |
#+BEGIN_SRC python :var data=tbl-data
print data
#+END_SRC
#+RESULTS:
: [[1, 1], [2, 4], [3, 9]]
When I export this, the codeblock shows no indication of what "data" is,
or where it came from. I had hoped to develop a filter that would allow
me to put something like:
<pre>language=python
parameters: :var data=tbl-data</pre>
in front of the block for an html export. I tried following the example
here: http://orgmode.org/manual/Advanced-configuration.html at the end,
by defining a derived mode. However, it does not appear that the
information is kept in the parse tree.
(src-block (:language python :switches nil :parameters nil :begin 536 :end 578 :number-lines nil :preserve-indent t :retain-labels t :use-labels t :label-fmt nil :hiddenp nil :value print data
:post-blank 2 :post-affiliated 536 :parent #4))
although if I look at the element at point, it seems to be there:
(src-block (:language python :switches nil :parameters :var
data=tbl-data :begin 536 :end 629 :number-lines nil :preserve-indent t
:retain-labels t :use-labels t :label-fmt nil :hiddenp nil :value print
data (princ (org-element-at-point))
I am not sure why the :end values are not the same though.
Here is what I was trying to use:
#+BEGIN_SRC emacs-lisp
(defun my-src-block (src-block contents info)
(message "start-block\n\n%s\n\nend-block" info)
(concat "<pre>"
(format "[language: %s]" (org-element-property :language src-block))
(format "\nparameters: %s" (org-element-property :parameters src-block))
"</pre><br>"
(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")
(browse-url "custom-src-table-export.html")
#+END_SRC
There are two issues with this block:
1. All parameters are listed as nil
2. the code is not syntax highlighted in html at all.
Any suggestions on how to achieve this? I also want to insert
tablenames, and if the src-block is named to put the name above the
block (for extra gravy, a hyperlink from :var to the source ;).
thanks,
--
-----------------------------------
John Kitchin
http://kitchingroup.cheme.cmu.edu
next reply other threads:[~2014-09-20 23:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-20 23:33 John Kitchin [this message]
2014-09-21 21:11 ` filter for src-block export question 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=m2k34xhno8.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).