From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: how to quote "#+end_src" string in a Babel block? Date: Wed, 24 Jul 2013 16:32:34 -0600 Message-ID: <87siz3oaa3.fsf@gmail.com> References: <65A347E6-F361-4410-93B6-CEA910195E7E@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49665) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V27iC-0008DR-E9 for emacs-orgmode@gnu.org; Wed, 24 Jul 2013 18:39:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V27iB-0006Se-Ee for emacs-orgmode@gnu.org; Wed, 24 Jul 2013 18:39:12 -0400 Received: from mail-pa0-x234.google.com ([2607:f8b0:400e:c03::234]:54515) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V27iB-0006SY-82 for emacs-orgmode@gnu.org; Wed, 24 Jul 2013 18:39:11 -0400 Received: by mail-pa0-f52.google.com with SMTP id kq13so1205790pab.11 for ; Wed, 24 Jul 2013 15:39:10 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: asenal Cc: emacs-orgmode@gnu.org asenal 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