From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?Cl=c3=a9ment_Pit--Claudel?= Subject: Re: Restrict include to some backend Date: Tue, 6 Sep 2016 10:59:54 -0400 Message-ID: <54006c8e-f4c0-f07d-1160-07528230681d@gmail.com> References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="9LLHUtJrRAq5qPb58lNNupNOXX0Ion7V9" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57363) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhHrA-0000sR-1j for emacs-orgmode@gnu.org; Tue, 06 Sep 2016 11:00:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhHr3-0005H3-Uf for emacs-orgmode@gnu.org; Tue, 06 Sep 2016 11:00:10 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:64393) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhHr3-0005GO-K5 for emacs-orgmode@gnu.org; Tue, 06 Sep 2016 11:00:05 -0400 Received: from [18.189.118.169] ([18.189.118.169]) by mrelayeu.kundenserver.de (mreue001) with ESMTPSA (Nemesis) id 0MU9x3-1bYj7F1YOH-00Qna7 for ; Tue, 06 Sep 2016 17:00:04 +0200 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: emacs-orgmode@gnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --9LLHUtJrRAq5qPb58lNNupNOXX0Ion7V9 Content-Type: multipart/mixed; boundary="PN5LaNEQkQ6t0xi1swQH1oaxOEGsalPpq"; protected-headers="v1" From: =?UTF-8?Q?Cl=c3=a9ment_Pit--Claudel?= To: emacs-orgmode@gnu.org Message-ID: <54006c8e-f4c0-f07d-1160-07528230681d@gmail.com> Subject: Re: [O] Restrict include to some backend References: In-Reply-To: --PN5LaNEQkQ6t0xi1swQH1oaxOEGsalPpq Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable The examples below should have read begin_only: > #+begin_only html > #+include foo.py src python > #+end_ony >=20 > #+begin_only latex > This is processed as *regular* ~org-mode~ code, but only when exporting= to LaTeX. > #+end_only Cl=C3=A9ment On 2016-09-06 09:59, Cl=C3=A9ment Pit--Claudel wrote: > Hi Fabrice, >=20 > I've run into this issue recently (while writing my first large documen= t in Org). I couldn't find a good native solution, so I used a rather un= pleasant trick, and I've been meaning to write emacs-orgmode about it sin= ce then. >=20 > In my documents I have a BEGIN_ONLY environment that I use like this: >=20 > #+begin_only html > #+include foo.py src python > #+end_ony >=20 > #+begin_only latex > This is processed as *regular* ~org-mode~ code, but only when exporting= to LaTeX. > #+end_only >=20 > I remove the blocks based on the current backend using a crude pre-proc= essing step in Emacs lisp. I can share the code if you're in a hurry, but= maybe this idea can also be integrated to Org itself? >=20 > For the record, here are places where this was useful: >=20 > * Some complex math was improperly rendered by MathJax; I made SVG imag= es of it and declared a macro that inserted the actual math in LaTeX mode= , and the SVG in HTML mode. To get backend-dependent macro definitions, I= used BEGIN_ONLY blocks. >=20 > * I wanted to set the TOC depth only for the HTML version; I used=20 > #+BEGIN_ONLY html > #+TOC: headlines 2 > #+END_ONLY html >=20 > * In HTML mode listings are labeled as "listings," but in TeX mode they= are listed as "figures"; I used a backend-dependent macro definition to = smoothe out the difference. >=20 > * I split a figure in two in HTML, while using two subfigures in LaTeX >=20 > * I included PDF figures in LaTeX and SVG figures in HTML in some place= s >=20 > * I have my own custom-written citation processor for HTML; I included = the "* Bibliography" header only in the HTML, since LaTeX inserted it by = itself. >=20 > Cheers, > Cl=C3=A9ment. >=20 > On 2016-09-06 01:13, Fabrice Popineau wrote: >> Hi, >> >> Maybe there is an obvious answer but I wonder how to restrict >> including a file to some backend. The following doesn't work: >> >> #+begin_export latex >> #+include foo.py src python >> #+end_export >> >> (Not that I expected it to actually work, but it shows the goal) >> Any idea ? Thanks for your help. >> >> Fabrice >=20 --PN5LaNEQkQ6t0xi1swQH1oaxOEGsalPpq-- --9LLHUtJrRAq5qPb58lNNupNOXX0Ion7V9 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXztnqAAoJEPqg+cTm90wjy8oQAIdF9DjhmCv4ZKLM1igYjVzw S65JwYFM1RTM2kcWBgegRypIU0sIxAr2TYN4gFOMzJ29kSjqmkjbLR51GPgrCTso tzG7EAHIgZPWZV2g8jAtVVCUR/GXXzhyWSx9V3mkzZKbdxz4kLh9ZV6xjBsKU4JA 5169G8VLGUs2Ia8xbre3qXMBYij4OMJpasdWtUBlxtVIEa3q55HMa5DbDcCyB31U f7zLttX09uhgcWPTEMtt5Wl/9SLVEIHZ5sJNO/7RNYAR1YR7mTLuYa7WClqE4hlg Em/aufmWRzNTusrFBdQEw0atqdspbrxlBXdzRhL/EC22oXzMV1X+IyYxrUHVb5RP 12KldfGIuRm+vXoZHX8RgLluxWyLZevfbHGyAp209+sIxxyEZyYyW8a6O6OKkjAw VUDNhakPn0SyQTHjeuTJEov+7EBz1zL5kdmx+D7r+zi+8WzflPeL6rTgTyY/8EFW BTcByGoiJBMrtvjdqIlNvuYq73okGakcaNq3Qwvv7tKj1XQ2ynhhxUIMjKqAxNxm lfpvB/JKmjgkayaXpRVNy+eNciMwBdtHiGGWZCXj/wwl1+HyYt9Ibo0rtZl6wkGv CmnrcWNRRRgWendDhXmrHD2YZYEfqTEK4eN7w9LwPwc6aYjA7WBpVohlhSEjUZ7f nUoKq0zke4FA1DKr3KT/ =TZYO -----END PGP SIGNATURE----- --9LLHUtJrRAq5qPb58lNNupNOXX0Ion7V9--