emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] Help with export filter?


From: Thomas S. Dye
Subject: [O] Help with export filter?
Date: Sat, 19 Jul 2014 08:53:08 -1000

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]