emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: suvayu ali <fatkasuvayu+linux@gmail.com>
To: Carsten Dominik <carsten.dominik@gmail.com>
Cc: org-mode mailing list <emacs-orgmode@gnu.org>
Subject: Re: Filtering in export hooks
Date: Tue, 6 Sep 2011 12:16:56 +0200	[thread overview]
Message-ID: <CAMXnza1t4Wd1LHOm9puqO3TFZL11k7JfKnCxmU_7GwRO4+d1cg@mail.gmail.com> (raw)
In-Reply-To: <74E04FF8-94AD-4A44-AEC1-9D5217317269@gmail.com>

Hi Carsten,

On Tue, Sep 6, 2011 at 11:49 AM, Carsten Dominik
<carsten.dominik@gmail.com> 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	other threads:[~2011-09-06 10:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-06  8:49 Filtering in export hooks suvayu ali
2011-09-06  8:58 ` Carsten Dominik
2011-09-06  9:08   ` suvayu ali
2011-09-06  9:49     ` Carsten Dominik
2011-09-06 10:16       ` suvayu ali [this message]
2011-09-06 11:33         ` suvayu ali
2011-09-06 22:39       ` suvayu ali

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

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMXnza1t4Wd1LHOm9puqO3TFZL11k7JfKnCxmU_7GwRO4+d1cg@mail.gmail.com \
    --to=fatkasuvayu+linux@gmail.com \
    --cc=carsten.dominik@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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 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).