emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Christian Moe <mail@christianmoe.com>
To: "Łukasz Stelmach" <lukasz.stelmach@iem.pw.edu.pl>
Cc: emacs-orgmode@gnu.org
Subject: Re: publishing a drawer
Date: Fri, 05 Nov 2010 10:20:59 +0100	[thread overview]
Message-ID: <4CD3CC7B.1000505@christianmoe.com> (raw)
In-Reply-To: <87pqum7hmq.fsf@dasa3.iem.pw.edu.pl>

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

  parent reply	other threads:[~2010-11-05  9:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-03 11:48 publishing a drawer Łukasz Stelmach
2010-11-03 16:11 ` Jeff Horn
2010-11-03 16:32   ` Thomas S. Dye
2010-11-05  9:20 ` Christian Moe [this message]
2010-11-06 11:15   ` Łukasz Stelmach

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=4CD3CC7B.1000505@christianmoe.com \
    --to=mail@christianmoe.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=lukasz.stelmach@iem.pw.edu.pl \
    /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).