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: Wed, 7 Sep 2011 00:39:56 +0200 [thread overview]
Message-ID: <CAMXnza2uEDEGt1jAJmik4_oeVBPk1juhdUcO4LKccCKZVLO9qQ@mail.gmail.com> (raw)
In-Reply-To: <74E04FF8-94AD-4A44-AEC1-9D5217317269@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 596 bytes --]
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?
I finally managed to isolate the issue and construct a working example.
To replicate, in a minimal session evaluating the code blocks in the
attached org file should be sufficient. The issue is described in the
org file.
Thanks a lot,
--
Suvayu
Open source is the future. It sets us free.
[-- Attachment #2: test.org --]
[-- Type: text/x-org, Size: 3444 bytes --]
#+OPTIONS: H:4 num:nil toc:t \n:nil @:nil ::t |:t ^:t -:t f:t *:t <:nil
#+OPTIONS: TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:nil
#+LaTeX_HEADER: \usepackage[backgroundcolor=green!40]{todonotes}
#+LaTeX_HEADER: \usepackage{makerobust}
#+LaTeX_HEADER: \MakeRobustCommand\begin
#+LaTeX_HEADER: \MakeRobustCommand\end
#+LaTeX_HEADER: \MakeRobustCommand\item
* COMMENT Setup
The following code is supposed to wrap the headlines matched by the
tags search "QnA|Qn" with a =\todo[inline]{..}= Latex macro. I am
using the tags to determine the colour of the todo block.
** Case 1
This gets exported for all values of the =tags:= option. But markup
like /italics/, *bold* or +strikethrough+ are not translated to Latex.
Links are also not translated properly.
#+begin_src emacs-lisp
;; org export hooks
(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}\\protect\\linebreak{}%%\n"
color heading)
(format "%s\n}%%\n" content))))))
;; FIXME: doesn't export markup like /italics/ or *bold* and links properly
(add-hook 'org-export-preprocess-hook
(lambda ()
(let ((match "QnA|Qn"))
(org-map-entries (lambda () (my-org-export-latex-wrap-todo))
match))))
#+end_src
** Case 2
The wrapping fails when the tags option is =tags:nil= but everything
gets translated to Latex properly. However when the =tags:= option is
non-nil, the wrapping works but the latex translation fails.
#+begin_src emacs-lisp
;; org export hooks
(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}\\protect\\linebreak{}%%\n"
color heading)
(format "%s\n}%%\n" content))))))
;; FIXME: doesn't work with tags:nil
(add-hook 'org-export-preprocess-after-blockquote-hook
(lambda ()
(let ((match "QnA|Qn"))
(org-map-entries (lambda () (my-org-export-latex-wrap-todo))
match))))
#+end_src
* Bs⁰ decay
** Regular tree
Some text
1. maybe a list
2. with 2 items and some *bold text*
** Decay model :Qn:
1. Justify neglecting CP violation
- in decay for the DsK channel
- in Bs mixing for both DsK and Dsπ channels
3. Verify master equations
** Mass hypothesis :QnA:
1. Why do we need mass hypothesis?
- /Energy resolution/ of the *HCAL* is not good.
- +General purpose experiments don't care about jet constituents+.
2. Some link to [[*Regular%20tree][Regular tree]] that fails to export properly.
prev parent reply other threads:[~2011-09-06 22:40 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
2011-09-06 11:33 ` suvayu ali
2011-09-06 22:39 ` suvayu ali [this message]
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=CAMXnza2uEDEGt1jAJmik4_oeVBPk1juhdUcO4LKccCKZVLO9qQ@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).