Hi Carsten,

On Tue, Sep 6, 2011 at 11:49 AM, Carsten Dominik
<carsten.domi...@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.
#+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.

Reply via email to