From: tsd@tsdye.com (Thomas S. Dye)
To: Rasmus <rasmus@gmx.us>
Cc: emacs-orgmode@gnu.org
Subject: Re: Help with export filter?
Date: Mon, 21 Jul 2014 05:55:56 -1000 [thread overview]
Message-ID: <m2zjg2n1tf.fsf@tsdye.com> (raw)
In-Reply-To: <8761ir0yvw.fsf@gmx.us> (rasmus@gmx.us's message of "Mon, 21 Jul 2014 12:50:11 +0200")
Aloha Rasmus,
Rasmus <rasmus@gmx.us> 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{.*?newpage.*?}\\(.*\n\\)"
> (downcase contents)))
> (replace-match "\\\\newpage\n\\1\\2" nil nil contents))
> ((and (org-export-derived-backend-p backend 'latex)
> (string-match "\\(\\`.*?\\)\\(?:\\\\hfill{}\\)?\\\\textsc{.*?clearpage.*?}\\(.*\n\\)" (downcase contents)))
> (replace-match "\\\\clearpage\n\\1\\2" nil nil contents))))
>
> (add-to-list 'org-export-filter-headline-functions 'tsd-filter-headline-tags)
>
> * 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*. =tag2= is lost.
> * ignore heading with clearpage :ignoreheading:clearpage:
> clearpage before *here*
>
> —Rasmus
Thanks very much for your help. The new filter does just what I want.
All the best,
Tom
--
Thomas S. Dye
http://www.tsdye.com
next prev parent reply other threads:[~2014-07-21 15:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-19 18:53 Help with export filter? Thomas S. Dye
2014-07-21 10:50 ` Rasmus
2014-07-21 15:55 ` Thomas S. Dye [this message]
2015-08-12 13:33 ` Samuel Loury
2015-08-12 13:46 ` Nicolas Goaziou
2015-08-12 14:32 ` Samuel Loury
2015-08-12 14:42 ` Nicolas Goaziou
2015-08-12 14:54 ` Samuel Loury
2015-08-12 22:36 ` Rasmus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2zjg2n1tf.fsf@tsdye.com \
--to=tsd@tsdye.com \
--cc=emacs-orgmode@gnu.org \
--cc=rasmus@gmx.us \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.