From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sebastian Wiesner Subject: Re: Limit subtree to a specific export backend Date: Fri, 4 Oct 2013 12:33:16 +0200 Message-ID: References: <87li2e70vv.fsf@gmx.us> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51640) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VS2hH-0002xj-J6 for emacs-orgmode@gnu.org; Fri, 04 Oct 2013 06:33:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VS2hC-0003fz-Hq for emacs-orgmode@gnu.org; Fri, 04 Oct 2013 06:33:23 -0400 Received: from mail-wi0-x229.google.com ([2a00:1450:400c:c05::229]:44622) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VS2hC-0003fj-74 for emacs-orgmode@gnu.org; Fri, 04 Oct 2013 06:33:18 -0400 Received: by mail-wi0-f169.google.com with SMTP id hj3so2110451wib.2 for ; Fri, 04 Oct 2013 03:33:17 -0700 (PDT) In-Reply-To: <87li2e70vv.fsf@gmx.us> 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: Rasmus Cc: emacs-orgmode@gnu.org 2013/9/30 Rasmus : > Hi Sebastian, > > Sebastian Wiesner writes: > >> can I limit a subtree to be exported with specific backends only? >> I.e. only to HTML, but not Texinfo or LaTeX? >> >> Background: I am trying to simplify the documentation of one of my >> projects, and combine the website and the user manual into a single >> document. Naturally, there is some content on the website that should >> not appear in the manual and vice versa. > > As Sebastien suggests, if you can identify export status depending on > tags you can do it with a filter. Great, I think I will go by this way=E2=80=A6 I presume, I can set "org-export-filter-options-functions" as a directory-local variable, so that this kind of export restrictions only applies to Org mode documents in the specific project. > Here's an example that's perhaps a bit too verbose and not thoroughly > tested: > > #+BEGIN_SRC Org > #+TITLE: Conditional export > #+options: tags:nil > * Common intro > txt > ** Pdf heading :la= tex: > the math is really pretty! > ** HTML heading :h= tml: > the text features hyperlinks! > ** More common notes > Intro over > > * Code :noexp= ort: > #+begin_src emacs-lisp > (defun rasmus/conditional-export (settings backend) > "Change SETTINGS to include dynamically set export-tags. > > Enable the use of BACKEND as EXPORT_TAGS. A derived backend is > treated as its parent." > (let ((backends (remove-duplicates > (mapcar (lambda (x) > (or (org-export-backend-parent x) > (org-export-backend-name x))) > org-export--registered-backends))) > ;; for treating derived backend and parent backends differently= : > ;; (backend-or-parent backend) > (backend-or-parent (dolist (b org-export--registered-backends r= eturn) > (when (eq (org-export-backend-name b) bac= kend) > (return (or (org-export-backend-parent b= ) > (org-export-backend-name b))= ))))) > (plist-put > settings :exclude-tags > (append (plist-get settings :exclude-tags) > (mapcar 'symbol-name > (remove backend-or-parent backends)))))) > > (add-to-list 'org-export-filter-options-functions 'rasmus/conditional-e= xport) > #+end_src > #+END_SRC Do I understand correctly, that this code adds all *other* backends to the "exclude-tags" setting, instead of adding the current one to "select-tags"? Is there a specific reason to do this? Just adding "backend" to "select-tags" seems simpler to me, and I wonder whether "exclude-tags" even behaves correctly for headlines with more than one tag. As far as I understand the Org manual, it would exclude headlines tagged as ":html:latex:" when exporting to "html", because "latex" is added as exclude-tag, preventing the headline from being exported.