emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric Schulte <schulte.eric@gmail.com>
To: asenal <asenalhere@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: how to quote "#+end_src" string in a Babel block?
Date: Wed, 24 Jul 2013 16:32:34 -0600	[thread overview]
Message-ID: <87siz3oaa3.fsf@gmail.com> (raw)
In-Reply-To: 65A347E6-F361-4410-93B6-CEA910195E7E@gmail.com

asenal <asenalhere@gmail.com> writes:

> Hi Guys I'm trying to do literature programming with org mode.
> My problem is How can I safely quote "#+XXX" inside a Babel-block?
> I found org-mode mismatch the outter "#+begin_src"  with the first "#+end_src" inside the block hence gives me a wrong parse.
>
> Here's an example:
> #+headers: :var varlist=top_iv
> #+begin_src python :return iv_template(varlist)
>   def iv_template(varlist,db,table):
>       for var in varlist:
>           babel_template='''
> 	  #+name: var
>           #+begin_src sqlite :db mydb
>             SELECT colName,cnt,suc,fal,iv FROM mytable WHERE colName == %s';
>           #+end_src   # org mode stop here!
>           ''' % (var,var)
>
>           print babel_template
> #+end_src
>
> I know it looks twisted,but what I really care is wheather org-mode
> holds the capability to do so.
>

The following syntax should work.  If you edit code blocks with C-' the
leading ' characters will be added and stripped automatically.

#+begin_src python :return iv_template(varlist)
  def iv_template(varlist,db,table):
      for var in varlist:
          babel_template='''
          ,#+name: var
          ,#+begin_src sqlite :db mydb
          SELECT colName,cnt,suc,fal,iv FROM mytable WHERE colName == %s';
          ,#+end_src   # org mode stop here!
          ''' % (var,var)
  
          print babel_template
#+end_src


-- 
Eric Schulte
http://cs.unm.edu/~eschulte

  parent reply	other threads:[~2013-07-24 22:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-24  5:39 how to quote "#+end_src" string in a Babel block? asenal
2013-07-24  6:11 ` Thorsten Jolitz
2013-07-24  7:24 ` Nicolas Goaziou
2013-07-24 22:32 ` Eric Schulte [this message]
2013-08-15 11:38   ` asenal

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=87siz3oaa3.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=asenalhere@gmail.com \
    --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).