[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] How to export drawer?
From: |
Marcin Antczak |
Subject: |
Re: [O] How to export drawer? |
Date: |
Fri, 04 Apr 2014 23:06:11 +0200 |
User-agent: |
mu4e 0.9.9.5; emacs 24.4.50.2 |
Nicolas Goaziou writes:
> Hello,
>
> Marcin Antczak <address@hidden> writes:
>
>> I would like to export some org to html with custom backend based on
>> 'html.
>>
>> What I need is to override function org-html-headline from ox-html.el
>
> OK. But this isn't related to drawers, is it? If you want to alter
> drawers export, you need to override `org-html-drawer' too.
Unfortunately you misunderstood me.
What I want to do is to override drawers export to exclude some
predefined drawers. Let's say: LOGBOOK and CLOCKTABLE.
Then I want to attach these drawers to headline(!)
This is why I want to add a piece of code to return drawer in org-html-headline.
>
>> I just want to export drawer with some specific name. For example
>> LOGBOOK or CLOCKTABLE.
>
> You can set `org-export-with-drawers'. You can also hard-code the list
> into `org-mybackend-drawer':
>
> (defun org-mybackend-drawer (drawer contents info)
> (when (member-ignore-case (org-element-property :drawer-name drawer)
> '("LOGBOOK" "CLOCKTABLE"))
> (org-export-data-with-backend drawer 'html info)))
Yes. I want to hard-code these drawers and ignore them in default export.
Anyway thing is that I want to export drawer with specific name while
I'm in org-html-headline function.
(defun org-html-headline (headline contents info)
"Transcode a HEADLINE element from Org to HTML.
CONTENTS holds the contents of the headline. INFO is a plist
holding contextual information."
;; Empty contents?
(setq contents (or contents ""))
(let* ((numberedp (org-export-numbered-headline-p headline info))
(level (org-export-get-relative-level headline info))
And here I wan't to add:
(clocktable (and (plist-get info :with-drawers)
(let* ((drawers (org-element-map headline 'drawer 'identity
info nil 'headline)))
(mapconcat (lambda (d)
(when (string= (org-element-property
:drawer-name d) "CLOCKTABLE")
(org-export-data-with-backend d 'html info)))
drawers ""))))
In this way I could attach HTML code with CLOCKTABLE drawer to headline.
Unfortunately as I mentioned before I don't know how to achieve this
without recursion. My code returns all CLOCKTABLE drawers in child
tasks.
org-element-map has optional argument 'no-recursion' but I don't know
how to set it up properly.
Regards,
--
Marcin