all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* org-publish: can I use a function in :html-preamble-format?
@ 2021-03-22 15:26 Giovanni Biscuolo
  2021-03-23 10:36 ` Giovanni Biscuolo
  0 siblings, 1 reply; 2+ messages in thread
From: Giovanni Biscuolo @ 2021-03-22 15:26 UTC (permalink / raw)
  To: help-gnu-emacs

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

Hello,

I'm a newbie with Elisp and Lisp in general; what I'm trying to do is to
customize the preamble format for a publishing-project I'm using.

I'm able to configure the HTML preamble for each project using this
configuration;

--8<---------------cut here---------------start------------->8---

("Pagine in italiano"
 :language it

[...]

 :html-preamble t
 :html-preamble-format (("en"
  			"<div><div><a href=\"/\">Home</a><span class=\"pre-sep\">|</span><a href=\"/colophon.html\">Colophon</a></div> <hr style='height:0.5px'></div>")
  		       ("it"
  			"<div><div><a href=\"/it/\">Home</a><span class=\"pre-sep\">|</span><a href=\"/it/colophon.html\">Colophon</a></div> <hr style='height:0.5px'></div>")))

--8<---------------cut here---------------end--------------->8---

This works well but I'd like to use xmlgen to format the html parts of
:html-preamble-format

If I use this:

--8<---------------cut here---------------start------------->8---

:html-preamble-format (("en"
			(xmlgen
			 '(div
			   (div
			    (a :href "/" "Home")
			    (span :class "pre-sep" "|")
			    (a :href "/colophon.html" "Colophon")))))
		       ("it"
			(xmlgen
			 '(div
			   (div
			    (a :href "/" "Home")
			    (span :class "pre-sep" "|")
			    (a :href "/colophon.html" "Colophon"))))))

--8<---------------cut here---------------end--------------->8---

(yes I know, the HTML results of xmgen does not match with the ones above
but that's not the issue)

I get this error:

Wrong type argument: char-or-string-p, (xmlgen '(div (div (a :href "/" "Home") (span :class "pre-sep" "|") (a :href "/colophon.html" "Colophon"))))

If I try to evaluate the (xmlgen ...) part in a separate buffer I get
correct sting representation in HTML but in ":html-preamble-format" it
does not work.

Please what I'm doing wrong?

Thanks! Giovanni.

-- 
Giovanni Biscuolo

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 865 bytes --]

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

* Re: org-publish: can I use a function in :html-preamble-format?
  2021-03-22 15:26 org-publish: can I use a function in :html-preamble-format? Giovanni Biscuolo
@ 2021-03-23 10:36 ` Giovanni Biscuolo
  0 siblings, 0 replies; 2+ messages in thread
From: Giovanni Biscuolo @ 2021-03-23 10:36 UTC (permalink / raw)
  To: help-gnu-emacs

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

Hello,

I solved this with a backquote (instead of quote), I write this just in
case someone need an example (of what NOT to do :-D ).

Giovanni Biscuolo <giovanni@biscuolo.net> writes:

[...]

> If I use this:
>
> --8<---------------cut here---------------start------------->8---
>
> :html-preamble-format (("en"
> 			(xmlgen
> 			 '(div
> 			   (div
> 			    (a :href "/" "Home")
> 			    (span :class "pre-sep" "|")
> 			    (a :href "/colophon.html" "Colophon")))))
> 		       ("it"
> 			(xmlgen
> 			 '(div
> 			   (div
> 			    (a :href "/" "Home")
> 			    (span :class "pre-sep" "|")
> 			    (a :href "/colophon.html" "Colophon"))))))
>
> --8<---------------cut here---------------end--------------->8---

OK the code above was included as part of <<sites_config>> in a list
like this:

--8<---------------cut here---------------start------------->8---

      (setq org-publish-project-alist
	  '(
	    <<sites_config>>))

--8<---------------cut here---------------end--------------->8---

In this way all the sites_config part is _quoted_ (see the quote ad the
beginning of the org-publish-project-alist).

If I want the xmlgen code above to be evaluated, I have to backquote the
list and use the evaluator symbol (",") for the (xmlgen ...) block; this
way:

--8<---------------cut here---------------start------------->8---

      (setq org-publish-project-alist
	  `(
	    [OMISSIS]
            :html-preamble-format (("en"
            			,(xmlgen
            			 '(div
            			   (div
            			    (a :href "/" "Home")
            			    (span :class "pre-sep" "|")
            			    (a :href "/colophon.html" "Colophon")))))
            		       ("it"
            			,(xmlgen
            			 '(div
            			   (div
            			    (a :href "/" "Home")
            			    (span :class "pre-sep" "|")
            			    (a :href "/colophon.html" "Colophon"))))))))
           
--8<---------------cut here---------------end--------------->8---

...OK, lesson learned! :-D


Happy hacking!
Giovanni.

-- 
Giovanni Biscuolo

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 865 bytes --]

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

end of thread, other threads:[~2021-03-23 10:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-22 15:26 org-publish: can I use a function in :html-preamble-format? Giovanni Biscuolo
2021-03-23 10:36 ` Giovanni Biscuolo

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.