From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lixin Chin Subject: Re: Bug: Unable to nest headings within export blocks [9.0 (9.0-elpa @ c:/Data/Documents/emacs.d/elpa/org-20161102/)] Date: Wed, 9 Nov 2016 12:51:24 +0800 Message-ID: <20161109125040.00004325@gmail.com> References: <338ea338-093e-6323-083e-ac8732c44778@gmail.com> <878tsybcg7.fsf@nicolasgoaziou.fr> <3cb1d470-fb7b-adde-70ca-d34a3ec9c717@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42490) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c4Kqk-0002rA-Tg for emacs-orgmode@gnu.org; Tue, 08 Nov 2016 23:51:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c4Kqh-0007lS-LP for emacs-orgmode@gnu.org; Tue, 08 Nov 2016 23:51:02 -0500 Received: from mail-pf0-x22e.google.com ([2607:f8b0:400e:c00::22e]:33853) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c4Kqh-0007ke-EW for emacs-orgmode@gnu.org; Tue, 08 Nov 2016 23:50:59 -0500 Received: by mail-pf0-x22e.google.com with SMTP id n85so119997744pfi.1 for ; Tue, 08 Nov 2016 20:50:58 -0800 (PST) In-Reply-To: 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" To: "Charles C. Berry" Cc: emacs-orgmode@gnu.org On Mon, 7 Nov 2016 08:44:47 -0800 "Charles C. Berry" wrote: > Run this: > > #+BEGIN_SRC emacs-lisp :eval never-export :exports none > (require 'ob-org) > (defun eval-if-html () > (if (not (eq org-export-current-backend 'html)) "never")) > #+END_SRC > > > Then export this with the html backend: > > #+OPTIONS: toc:nil > > #+BEGIN_SRC org :eval (eval-if-html) :exports results :results replace > ,* HTML only heading > Text which should appear in HTML exports, but not \LaTeX{}. > #+END_SRC > > and you will get this: > >
>

1 HTML only > heading

>
>

> Text which should appear in HTML exports, but not \LaTeX{}. >

>
>
> > With other backends you get nothing. > > HTH, > > Chuck Thank you very much, that works perfectly! For future reference, I tweaked the source code block to allow specifying multiple export backends, and to avoid generating results when evaluating using C-c C-c: #+BEGIN_SRC emacs-lisp :eval never-export :exports none :results silent (require 'cl-extra) (defun eval-if-export (backend) "For use within org-mode source blocks :eval argument. Causes the block to be evaluated if the current export backend matches any of the backends in BACKEND. (e.g., (eval-if-export '(latex html)))." (unless (cl-some (lambda (back) (eq org-export-current-backend back)) backend) "never")) #+END_SRC Then using: #+BEGIN_SRC org :eval (eval-if-export '(html)) :exports results :results replace ,* HTML only heading Text which should appear in HTML exports, but not \LaTeX{}. #+END_SRC The syntax isn't as elegant as #+BEGIN_EXPORT ... #+END_EXPORT, but it works nicely enough. Thanks, Lixin