emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [Orgmode] publishing a drawer


From: Christian Moe
Subject: Re: [Orgmode] publishing a drawer
Date: Fri, 05 Nov 2010 10:20:59 +0100
User-agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; en-US; rv:1.9.2.12) Gecko/20101027 Thunderbird/3.1.6

On 11/3/10 12:48 PM, Łukasz Stelmach wrote:
Hello.

Is it possible to publish drawer's content during export (both HTML and
LaTeX)? I am creating a presentation with S5 and I'd love to have
:LOGBOOK: (or :NOTES:) published as<div class="notes"></div>  (or
\note{} for Beamer).


The following ought to work, but doesn't for Latex. Code improvements welcome.

* Set option to include drawers in export

: #+OPTIONS: d:t

For some reason, this doesn't work for me with Latex export. I've filed a bug report.

* Customize drawer export

Make org-export-format-drawer-function point to a custom function, e.g. like this for your exact case (improvements welcome):

#+begin_src emacs-lisp
  (defun my-org-export-format-drawer (name content backend)
    "Export :NOTES: and :LOGBOOK: drawers to HTML class
  or LaTeX command"
    (cond
     ((string-match "NOTES\\|LOGBOOK" name)
      (cond
       ((eq backend 'html)
        (format "@<div class=\"notes\"> %s @</div>" content))
       ((eq backend 'latex)   ; FIXME: This doesn't work
        (format "#+BEGIN_LATEX:\n\note{%s}\n#+END_LATEX " content))
       (t nil)))
     (t nil)))

  (setq org-export-format-drawer-function 'my-org-export-format-drawer)
#+end_src

* Style the HTML `notes' class as you want it

e.g. with

: #+STYLE: <style>.notes {color: grey; margin-bottom: 1em} .notes:before {content: "Notes: "; font-weight: bold}</style>

* Options

You can add more conditional clauses for other drawers you want styled a different way.

The function could be written more simply if you simply want all your drawers exported with the drawer name as HTML class/LaTeX command.

#+begin_src emacs-lisp
  (defun my-org-export-format-drawer (name content backend)
    "Export drawers to HTML class or LaTeX command with same name"
    (setq name (downcase name))
    (cond
     ((eq backend 'html)
      (format "@<div class=\"%s\"> %s @</div>" name content))
     ((eq backend 'latex)   ; FIXME: This doesn't work
      (format "#+BEGIN_LATEX:\n\%s{%s}\n#+END_LATEX " name content))
     (t nil)))
#+end_src

...and if you're using org-special-blocks, you can do the same simply with:

#+begin_src emacs-lisp
  (defun my-org-export-format-drawer (name content backend)
    "Export drawers to HTML class or LaTeX command with same name"
    (setq name (downcase name))
    (format "#+BEGIN_%s\n%s\n#+END_%s" name content name))
#+end_src

Let me know how it turns out. It's an interesting alternative route to extensible block-level markup.

HTH,
Christian



reply via email to

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