emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Filtering in export hooks


From: suvayu ali
Subject: Re: [O] Filtering in export hooks
Date: Tue, 6 Sep 2011 12:16:56 +0200

Hi Carsten,

On Tue, Sep 6, 2011 at 11:49 AM, Carsten Dominik
<address@hidden> wrote:
> Which of the preprocessing hooks are you using?  I am still confused
> by your description, maybe you can make a small example and show exactly what 
> works and what does not work?
>

This is what I am using at the moment:

(defun my-org-export-latex-wrap-todo ()
  "Wrap heading with arbitrary latex environment."
  (interactive)
  (let* ((tags (org-get-tags-string))
         (heading (org-get-heading t))  ; heading with todo
         (content (org-get-entry))
         (color (cond ((string-match ":QnA:" tags)  "color=blue!40")
                      ((string-match ":Qn:" tags) "color=yellow!40"))))
    (when color
      (org-mark-subtree)
      (delete-region (region-beginning) (region-end))
      (insert (concat
               (format "\\todo[inline,%s]{\\textbf{%s}%%\n" color heading)
               (format "%s\n}%%\n" content))))))

(add-hook 'org-export-preprocess-after-blockquote-hook
          (lambda ()
            (let ((match "QnA|Qn"))
              (org-map-entries (lambda () (my-org-export-latex-wrap-todo))
                               match))))

This works great as long as the tags: option is non-nil (t or
not-in-toc). Setting it to nil just ignores it and everything gets
like a regular headline. I am not using org-export-preprocess-hook
because some of the latex gets escaped during the export (e.g. {..}
becomes \{..}).

I hope this is clearer.

-- 
Suvayu

Open source is the future. It sets us free.



reply via email to

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