emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Parsing property drawers in subtree scope exports
@ 2017-07-01  6:58 Kaushal Modi
  2017-07-01  7:48 ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: Kaushal Modi @ 2017-07-01  6:58 UTC (permalink / raw)
  To: emacs-org list

[-- Attachment #1: Type: text/plain, Size: 507 bytes --]

Hello,

I have this test Org file:

=====
* Title
:PROPERTIES:
:FOO: 123
:END:
Something
=====

I am working on an exporter back-end, and I need to get the value of the
:FOO property
- During *subtree* export (C-c C-e C-s ..)
- In the body filter fn. So I have only info and body at my access.

I looked at ox-html.el for hints but that didn't help. In there too, the
CUSTOM_ID property drawer (picked one example I knew) is not parsed during
subtreep export.

How can I do this?

Thanks.
-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 853 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Parsing property drawers in subtree scope exports
  2017-07-01  6:58 Parsing property drawers in subtree scope exports Kaushal Modi
@ 2017-07-01  7:48 ` Nicolas Goaziou
  2017-07-01 13:09   ` Kaushal Modi
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2017-07-01  7:48 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-org list

Hello,

Kaushal Modi <kaushal.modi@gmail.com> writes:

> I have this test Org file:
>
> =====
> * Title
> :PROPERTIES:
> :FOO: 123
> :END:
> Something
> =====
>
> I am working on an exporter back-end, and I need to get the value of the
> :FOO property
> - During *subtree* export (C-c C-e C-s ..)
> - In the body filter fn. So I have only info and body at my access.
>
> I looked at ox-html.el for hints but that didn't help. In there too, the
> CUSTOM_ID property drawer (picked one example I knew) is not parsed during
> subtreep export.
>
> How can I do this?

It depends. 

You can write it :EXPORT_FOO: and define it in the back-end options.
Otherwise, you simply need to retrieve it and store it before calling
`org-export-to-file' or whatever.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Parsing property drawers in subtree scope exports
  2017-07-01  7:48 ` Nicolas Goaziou
@ 2017-07-01 13:09   ` Kaushal Modi
  2017-07-01 16:08     ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: Kaushal Modi @ 2017-07-01 13:09 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-org list

[-- Attachment #1: Type: text/plain, Size: 1082 bytes --]

Hello,

On Sat, Jul 1, 2017, 3:48 AM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

>
> You can write it :EXPORT_FOO: and define it in the back-end options.
>

I didn't follow that. Do you mean that the "EXPORT_" is a special prefix?
Or "EXPORT" is any backend prefix I choose?

Should that be added to these?

=====
:options-alist '((:hugo-front-matter-format "HUGO_FRONT_MATTER_FORMAT" nil
org-hugo-front-matter-format)
(:hugo-tags "HUGO_TAGS" nil nil)
=====

I already tried above, but I don't know how to get the ":HUGO_TAGS" value
from the property drawer, in subtreep export only, in the body filter (with
only body and info available).

If it is a full document export, I can use the "org export parse headlines"
function (forgot the name, on the phone at the moment) to get the
properties from each headline. But the same doesn't work when exporting
just one sub-tree.

Otherwise, you simply need to retrieve it and store it before calling
> `org-export-to-file' or whatever.


Hmm, will give this a try.. may be look at the pre export hook?

Thank you.
-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 1916 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Parsing property drawers in subtree scope exports
  2017-07-01 13:09   ` Kaushal Modi
@ 2017-07-01 16:08     ` Nicolas Goaziou
  2017-07-06 17:08       ` Kaushal Modi
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2017-07-01 16:08 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-org list

Kaushal Modi <kaushal.modi@gmail.com> writes:

> I didn't follow that. Do you mean that the "EXPORT_" is a special
> prefix?

I do. See (info "(org) Export settings").

> Should that be added to these?
>
> =====
> :options-alist '((:hugo-front-matter-format "HUGO_FRONT_MATTER_FORMAT" nil
> org-hugo-front-matter-format)
> (:hugo-tags "HUGO_TAGS" nil nil)
> =====

If you set this, you can access to EXPORT_HUgo_TAGS property
with :hugo-tags.

> I already tried above, but I don't know how to get the ":HUGO_TAGS" value
> from the property drawer, in subtreep export only, in the body filter (with
> only body and info available).

(plist-get info :hugo-tags)

> Otherwise, you simply need to retrieve it and store it before calling
>> `org-export-to-file' or whatever.
>
>
> Hmm, will give this a try.. may be look at the pre export hook?

You can also do that, if you don't use the "EXPORT_" prefix above.
However, you need to expand the buffer first, because it will be
narrowed to the current subtree.

Regards,

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Parsing property drawers in subtree scope exports
  2017-07-01 16:08     ` Nicolas Goaziou
@ 2017-07-06 17:08       ` Kaushal Modi
  2017-07-06 17:19         ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: Kaushal Modi @ 2017-07-06 17:08 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-org list

[-- Attachment #1: Type: text/plain, Size: 2996 bytes --]

On Sat, Jul 1, 2017 at 12:08 PM Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

> Kaushal Modi <kaushal.modi@gmail.com> writes:
>
> > I didn't follow that. Do you mean that the "EXPORT_" is a special
> > prefix?
>
> I do. See (info "(org) Export settings").
>

Thanks! Sorry for not reading that earlier. For reference:

> When exporting sub-trees, special node properties in them can override
the above keywords. They are special because they have an ‘EXPORT_’ prefix.
For example, ‘DATE’ and ‘OPTIONS’ keywords become, respectively,
‘EXPORT_DATE’ and ‘EXPORT_OPTIONS’. Except for ‘SETUPFILE’, all other
keywords listed above have an ‘EXPORT_’ equivalent.


> > Should that be added to these?
> >
> > =====
> > :options-alist '((:hugo-front-matter-format "HUGO_FRONT_MATTER_FORMAT"
> nil
> > org-hugo-front-matter-format)
> > (:hugo-tags "HUGO_TAGS" nil nil)
> > =====
>
> If you set this, you can access to EXPORT_HUgo_TAGS property
> with :hugo-tags.
>

Thanks. That works. Just curious though.. if one specifies certain keywords
to be exporter specific keywords in the backend definition in
:options-alist, it is evident that those keywords are specifically for
export. Should the requirement to have "EXPORT_" prefix before them be
relaxed? Do you foresee things not happening right if we started doing that?


> > I already tried above, but I don't know how to get the ":HUGO_TAGS" value
> > from the property drawer, in subtreep export only, in the body filter
> (with
> > only body and info available).
>
> (plist-get info :hugo-tags)
>

I was already doing that, but I was missing the "EXPORT_" prefix in the
property drawer keys. Thanks!


> > Otherwise, you simply need to retrieve it and store it before calling
> >> `org-export-to-file' or whatever.
> >
> >
> > Hmm, will give this a try.. may be look at the pre export hook?
>
> You can also do that, if you don't use the "EXPORT_" prefix above.
>

Using "EXPORT_" prefix works, but then the keys become too wordy; example:
EXPORT_HUGO_CATEGORIES.

So I have two options:

- Make use of the inbuilt EXPORT_ prefix and get rid of the "HUGO_" prefix
from the exporter backend definition. Then if categories are specified
per-Org-file, it would look like "#+CATEGORIES: foo bar", and if they are
specified per subtree, it would look like ":EXPORT_CATEGORIES: foo bar" in
the property drawer.
- Do not use the "EXPORT_" keyword in the property drawers, but then either
do the pre-export parsing, or.. above suggestion to update Org ox to not
require "EXPORT_" before FOO if FOO is a special keyword defined in the
backend?


> However, you need to expand the buffer first, because it will be
> narrowed to the current subtree.


I need exactly that. My idea is to have a single Org file with one subtree
per a blog post. So each subtree will have meta data about that post, like
data, categories, etc.
-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 4296 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Parsing property drawers in subtree scope exports
  2017-07-06 17:08       ` Kaushal Modi
@ 2017-07-06 17:19         ` Nicolas Goaziou
  0 siblings, 0 replies; 6+ messages in thread
From: Nicolas Goaziou @ 2017-07-06 17:19 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-org list

Hello,

Kaushal Modi <kaushal.modi@gmail.com> writes:

> Thanks. That works. Just curious though.. if one specifies certain keywords
> to be exporter specific keywords in the backend definition in
> :options-alist, it is evident that those keywords are specifically for
> export. Should the requirement to have "EXPORT_" prefix before them be
> relaxed? Do you foresee things not happening right if we started doing
> that?

I do. User may not be aware of keywords defined in export back-ends. As
a consequence user-defined properties could interfere with export
specific ones. E.g., ":TITLE:" and ":EXPORT_TITLE:" could mean different
things.

> - Make use of the inbuilt EXPORT_ prefix and get rid of the "HUGO_" prefix
> I need exactly that. My idea is to have a single Org file with one subtree
> per a blog post. So each subtree will have meta data about that post, like
> data, categories, etc.

I meant that you probably need to expand the buffer in order to get the
properties. Once this is done, you can return to the original narrowing.

Regards,

-- 
Nicolas Goaziou                                                0x80A93738

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-07-06 17:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-01  6:58 Parsing property drawers in subtree scope exports Kaushal Modi
2017-07-01  7:48 ` Nicolas Goaziou
2017-07-01 13:09   ` Kaushal Modi
2017-07-01 16:08     ` Nicolas Goaziou
2017-07-06 17:08       ` Kaushal Modi
2017-07-06 17:19         ` Nicolas Goaziou

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).