From mboxrd@z Thu Jan 1 00:00:00 1970 From: Giovanni Moretti Subject: Org-publish: how do I access user-defined keywords in html-preamble function? Date: Sun, 29 Dec 2019 23:18:12 +1300 Message-ID: <336db28f-a036-e097-cd41-a849b08ae453@reflections.co.nz> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="------------91001372B31BD2147CB175BD" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:57748) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ilVfV-0006M9-Uw for emacs-orgmode@gnu.org; Sun, 29 Dec 2019 05:19:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ilVfU-0006y8-B5 for emacs-orgmode@gnu.org; Sun, 29 Dec 2019 05:19:29 -0500 Received: from agree-15.godzone.net.nz ([192.138.251.15]:58430 helo=smtp.godzone.net.nz) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ilVfT-0004P7-Pt for emacs-orgmode@gnu.org; Sun, 29 Dec 2019 05:19:28 -0500 Received: from [192.168.1.17] (121-79-254-122.sta.inspire.net.nz [121.79.254.122]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.godzone.net.nz (Postfix) with ESMTPSA id 5C37C57621 for ; Sun, 29 Dec 2019 23:18:13 +1300 (NZDT) Content-Language: en-US List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org This is a multi-part message in MIME format. --------------91001372B31BD2147CB175BD Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable I'm working on a blog published via org-publish but one things got me stu= mped: accessing user defined keywords while publishing to HTML: Each post is in an orgmode file, and has a simple structure. E.g. one pos= t 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 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 `( =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ("blog-posts" =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 :base-directory=C2=A0= =C2=A0 "~/projects/3-blog/" =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 :base-extension=C2=A0= =C2=A0 "org" =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 :recursive=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 t =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 --- lots= omitted =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 :html-preamble=C2=A0= *my-blog-page-preamble* =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ) and /my-blog-page-preamble/ function is: (defun *my-blog-page-preamble* (arg) =C2=A0 (with-temp-buffer =C2=A0=C2=A0=C2=A0 (insert-file-contents my-blog-page-preamble-file)=C2= =A0=C2=A0 ; Insert preamble from file =C2=A0=C2=A0=C2=A0 (concat (buffer-string) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (format "
Tags: %s"=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 (car (plist-get arg :filetags)))=C2=A0 *;* *<< WORKS* =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (format "
Category: %s " (car= (plist-get arg :category))) *;<< returns nil* =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (format "
Draft: %s"=C2=A0=C2= =A0=C2=A0=C2=A0 (car (plist-get arg :draft))))))*;<< returns nil* I can access/the values of :title/ or /:filetags/ and other predefined ke= ywords 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> :beg= in 81 :end 108 :post-blank 0 :post-affiliated 81 :parent #4)) (keyword (:key CAT= EGORY :value electronics :begin 108 :end 132 :post-blank 0 :post-affiliated 108 :p= arent #4)) (keyword (:key FILETAGS :value Arduino :begin 132 :end 152 :post-blan= k 0 :post-affiliated 132 :parent #4)) (keyword (:key DRAFT :value true :b= egin 152 :end 166 :post-blank 0 :post-affiliated 152 :parent #4)) -- LOTS MORE I tried capitalizing -- (plist-get arg :CATEGORY) -- but that returns /ni= l/ 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 /#+catego= ry:/ and user-defined keywords such as /#+draft:/ keywords? Many thanks Giovanni* * --------------91001372B31BD2147CB175BD Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

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
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 `(
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ("blog-posts" =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 :base-directory=C2= =A0=C2=A0 "~/projects/3-blog/"
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 :base-extension=C2= =A0=C2=A0 "org"
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 :recursive=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 t
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 --- = lots omitted
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 :html-preamble=C2= =A0 my-blog-page-preamble
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 )

and my-blog-page-preamble function is:

(defun my-blog-page-preamble (arg)
=C2=A0 (with-temp-buffer
=C2=A0=C2=A0=C2=A0 (insert-file-contents my-blog-page-preamble-fi= le)=C2=A0=C2=A0 ; Insert preamble from file
=C2=A0=C2=A0=C2=A0 (concat (buffer-string)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (format "<br>Tags: %s"= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (car (plist-get arg :filetags)))=C2=A0 ; << WORKS
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (format "<br>Category:= %s " (car (plist-get arg :category))) ;<< returns nil
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (format "<br>Draft: %s= "=C2=A0=C2=A0=C2=A0=C2=A0 (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


--------------91001372B31BD2147CB175BD--