* Org-publish: how do I access user-defined keywords in html-preamble function?
@ 2019-12-29 10:18 Giovanni Moretti
0 siblings, 0 replies; only message in thread
From: Giovanni Moretti @ 2019-12-29 10:18 UTC (permalink / raw)
To: emacs-orgmode
[-- 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 --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-12-29 10:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-29 10:18 Org-publish: how do I access user-defined keywords in html-preamble function? Giovanni Moretti
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).