From: Giovanni Moretti <Giovanni@reflections.co.nz>
To: emacs-orgmode@gnu.org
Subject: Org-publish: how do I access user-defined keywords in html-preamble function?
Date: Sun, 29 Dec 2019 23:18:12 +1300 [thread overview]
Message-ID: <336db28f-a036-e097-cd41-a849b08ae453@reflections.co.nz> (raw)
[-- Attachment #1: Type: text/plain, Size: 2499 bytes --]
I'm working on a blog published via org-publish but one things got me stumped:
accessing user defined keywords while publishing to HTML:
Each post is in an orgmode file, and has a simple structure. E.g. one post starts with:
#+title: Fix for Sparkfun Arduino Pro Micro
#+date: <2009-03-05 13:55>
#+filetags: Arduino
#+category: electronics
#+draft: true
I want to access the last two keywords values when publishing but despite lots of
searching, can't find out how:
Part of my publish-project-alist:
(setq org-publish-project-alist
`(
("blog-posts"
:base-directory "~/projects/3-blog/"
:base-extension "org"
:recursive t
--- lots omitted
:html-preamble *my-blog-page-preamble*
)
and /my-blog-page-preamble/ function is:
(defun *my-blog-page-preamble* (arg)
(with-temp-buffer
(insert-file-contents my-blog-page-preamble-file) ; Insert preamble from file
(concat (buffer-string)
(format "<br>Tags: %s" (car (plist-get arg :filetags))) *;* *<< WORKS*
(format "<br>Category: %s " (car (plist-get arg :category))) *;<< returns nil*
(format "<br>Draft: %s" (car (plist-get arg :draft))))))*;<< returns nil*
I can access/the values of :title/ or /:filetags/ and other predefined keywords but
not ones I define myself.
My keywords are being passed to the preamble-function as displaying 'arg' shows:
--LOTS OMITTED--#2 (keyword (:key DATE :value <2009-03-05 13:55> :begin 81 :end
108 :post-blank 0 :post-affiliated 81 :parent #4)) (keyword (:key CATEGORY :value
electronics :begin 108 :end 132 :post-blank 0 :post-affiliated 108 :parent #4))
(keyword (:key FILETAGS :value Arduino :begin 132 :end 152 :post-blank 0
:post-affiliated 132 :parent #4)) (keyword (:key DRAFT :value true :begin 152
:end 166 :post-blank 0 :post-affiliated 152 :parent #4)) -- LOTS MORE
I tried capitalizing -- (plist-get arg :CATEGORY) -- but that returns /nil/ too.
Given that /(plist-get arg :category)/ and /(plist-get arg :draft)/ don't return the
expected values, what's the correct way to access the values of /#+category:/ and
user-defined keywords such as /#+draft:/ keywords?
Many thanks
Giovanni*
*
[-- Attachment #2: Type: text/html, Size: 3406 bytes --]
reply other threads:[~2019-12-29 10:19 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=336db28f-a036-e097-cd41-a849b08ae453@reflections.co.nz \
--to=giovanni@reflections.co.nz \
--cc=emacs-orgmode@gnu.org \
/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).