emacs-orgmode
[Top][All Lists]
Advanced

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

Re: Build a menu for an HTML publish


From: Sébastien Gendre
Subject: Re: Build a menu for an HTML publish
Date: Tue, 13 Aug 2024 11:56:34 +0200
User-agent: mu4e 1.12.1; emacs 29.4

Another reply to myself about this specific part:

Sébastien Gendre <seb@k-7.ch> writes:
> But if I set the variable `org-html-preamble` to my custom preamble
> function like this:
>
> (setq org-html-preamble 'my/preamble-test)
>
> I cannot found a way to define "very-strawbery" value in an Org-mode
> buffer and having it used while I manually export the Org-mode buffer.
>
> I tried with "#+very-strawbery: test123" and "#+OPTIONS: very-strawbery:
> test123", without success.
>
> Someone have an idea ?

If I want to define the value of my new option "very-strawbery" in the
level of an Org-mode buffer (or file), I need to add this new option
into the variable `org-export-options-alist` like this:

If I evaluate this:

    (add-to-list 'org-export-options-alist
                 '(:very-strawbery "VERYSTRAWBERY" nil nil))


To quote the docstring of `org-export-options-alist`:

> Alist between export properties and ways to set them.
> 
> The key of the alist is the property name, and the value is a list
> like (KEYWORD OPTION DEFAULT BEHAVIOR) where:
> 
> KEYWORD is a string representing a buffer keyword, or nil.  Each
>   property defined this way can also be set, during subtree
>   export, through a headline property named after the keyword
>   with the "EXPORT_" prefix (i.e. DATE keyword and EXPORT_DATE
>   property).
> OPTION is a string that could be found in an #+OPTIONS: line.
> DEFAULT is the default value for the property.
> BEHAVIOR determines how Org should handle multiple keywords for
>   the same property.  It is a symbol among:
>   nil       Keep old value and discard the new one.
>   t         Replace old value with the new one.
>   ‘space’   Concatenate the values, separating them with a space.
>   ‘newline’ Concatenate the values, separating them with
>           a newline.
>   ‘split’   Split values at white spaces, and cons them to the
>           previous list.
>   ‘parse’   Parse value as a list of strings and Org objects,
>             which can then be transcoded with, e.g.,
>             ‘org-export-data’.  It implies ‘space’ behavior.
> 
> Values set through KEYWORD and OPTION have precedence over
> DEFAULT.

After adding my new export option, I can use it by writing this on my
Org-mode buffer/file I want to export:

    #+VERYSTRAWBERRY: TestTestTest


After exporting my Org-mode buffer/file to HTML, I get a preamble with
the text "TestTestTest".


Note :

* Having a buffer option for "very-strawbery" is useful for export
  but also for publish. I can set a value that will override the
  value set in the Org-publish project settings.

* The variable `org-export-options-alist` is made for options who are
  back-end agnostic. But I didn't found a way to modify export options of
  HTML backend without redefine a new backend.


Best regards

-------
Gendre Sébastien

Attachment: signature.asc
Description: PGP signature


reply via email to

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