emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Help with export filter?
@ 2014-07-19 18:53 Thomas S. Dye
  2014-07-21 10:50 ` Rasmus
  0 siblings, 1 reply; 9+ messages in thread
From: Thomas S. Dye @ 2014-07-19 18:53 UTC (permalink / raw)
  To: Org-mode

Aloha all,

Inspired by discussions and code on the mailing list, I managed to
cobble together the headline filter below.  It "works" in that the
pdf output from LaTeX export is exactly what I want.  I'm thrilled!

It has one unwanted side effect.  In the tex file, a headline tagged
with either :newpage: or :clearpage: includes some extra baggage, like
this:

  \newpage
  \section*{Introduction\hfill{}\textsc{}}
  \label{sec-5}

I tried setting the option tags:nil, but then my export tags had no
effect.  Can someone suggest how I can avoid the \hfill etc.?  Or, am I
picking nits here?

***** Filter headline tags

#+name: filter-headline-tags
#+BEGIN_SRC emacs-lisp :results silent
  (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))
                (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 "\\(\\`.*\\)newpage\\(.*\n\\)" (downcase contents)))
           (replace-match "\\\\newpage\n\\1\\2"  nil nil contents))
          ((and (org-export-derived-backend-p backend 'latex)
                (string-match "\\(\\`.*\\)clearpage\\(.*\n\\)" (downcase contents)))
           (replace-match "\\\\clearpage\n\\1\\2"  nil nil contents))))
#+END_SRC

All the best,
Tom


-- 
T.S. Dye & Colleagues, Archaeologists
735 Bishop St, Suite 315, Honolulu, HI 96813
Tel: 808-529-0866, Fax: 808-529-0884
http://www.tsdye.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-08-12 22:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).