From mboxrd@z Thu Jan 1 00:00:00 1970 From: tsd@tsdye.com (Thomas S. Dye) Subject: Re: Help with export filter? Date: Mon, 21 Jul 2014 05:55:56 -1000 Message-ID: References: <8761ir0yvw.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]:38702) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X9Fwv-0002Jp-GG for emacs-orgmode@gnu.org; Mon, 21 Jul 2014 11:56:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X9Fwp-0003a8-6x for emacs-orgmode@gnu.org; Mon, 21 Jul 2014 11:56:25 -0400 Received: from gproxy8-pub.mail.unifiedlayer.com ([67.222.33.93]:37998) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1X9Fwo-0003ZH-Vn for emacs-orgmode@gnu.org; Mon, 21 Jul 2014 11:56:19 -0400 In-Reply-To: <8761ir0yvw.fsf@gmx.us> (rasmus@gmx.us's message of "Mon, 21 Jul 2014 12:50:11 +0200") 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 Aloha Rasmus, Rasmus writes: > Hi Tom, > > > Here's an edited filter that works with the enclosed test document. > Note that you could split this into different filters, but it may be > non-trivial with this identification-scheme since things would be > moving around. > > (defun tsd-filter-headline-tags (contents backend info) > "Ignore headlines with tag `ignoreheading' and/or start LaTeX > section with `newpage' or `clearpage' command." > (cond ((and (org-export-derived-backend-p backend 'latex) > (string-match "\\`.*newpage.*\n" (downcase contents)) > ;; if you want to get rid of labels use the string > ;; "\\`.*ignoreheading.*\n.*\n" > (string-match "\\`.*ignoreheading.*\n" (downcase contents))) > (replace-match "\\\\newpage\n" nil nil contents)) > ((and (org-export-derived-backend-p backend 'latex) > (string-match "\\`.*clearpage.*\n" (downcase contents)) > (string-match "\\`.*ignoreheading.*\n" (downcase contents))) > (replace-match "\\\\clearpage\n" nil nil contents)) > ((and (org-export-derived-backend-p backend 'latex 'html 'ascii) > (string-match "\\`.*ignoreheading.*\n" (downcase contents))) > (replace-match "" nil nil contents)) > ((and (org-export-derived-backend-p backend 'latex) > (string-match "\\(\\`.*?\\)\\(?:\\\\hfill{}\\)?\\\\textsc{.*?newpa= ge.*?}\\(.*\n\\)" > (downcase contents))) > (replace-match "\\\\newpage\n\\1\\2" nil nil contents)) > ((and (org-export-derived-backend-p backend 'latex) > (string-match "\\(\\`.*?\\)\\(?:\\\\hfill{}\\)?\\\\textsc{.*?clear= page.*?}\\(.*\n\\)" (downcase contents))) > (replace-match "\\\\clearpage\n\\1\\2" nil nil contents)))) > > (add-to-list 'org-export-filter-headline-functions 'tsd-filter-headline-t= ags) > > * my first headline > cont0 > * ignored headline :ignoreheading: > cont1 (ignored headline) > * heading with newpage :newpage: > newline before *here* > * heading with clearpage :clearpage: > clearpage before *here* > * ignored heading with newpage :newpage:tag2: > newline before *here*. =3Dtag2=3D is lost. > * ignore heading with clearpage :ignoreheading:clearpage: > clearpage before *here* > > =E2=80=94Rasmus Thanks very much for your help. The new filter does just what I want. All the best, Tom --=20 Thomas S. Dye http://www.tsdye.com