From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id IPdRFEowQmayXQAAe85BDQ:P1 (envelope-from ) for ; Mon, 13 May 2024 17:22:50 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id IPdRFEowQmayXQAAe85BDQ (envelope-from ) for ; Mon, 13 May 2024 17:22:50 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=WGWQ04KD; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1715613770; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=bxsGlHcAC8o7d53zZY+ba27XCPP6iUFcX6Z9Fk3xQWA=; b=fB+laeCEp4i1ozjbVGRQELQZV36KvlByU1AXnNhkmBQRlo8GKw+5TTbg8kmJ6JziHGf14f pX5pL3GyEWmSdhAdl8i85TCJBDTwFrK52bdU4vZHo0gMf86cSX8nvBkcZghMehxe0ID0Xw +fMYncMy2NO9rZSlORBEJAF2LHgwSXG7UgOgRiYsofgy+fWCjPP6sdu/WtYy7iZffS25M7 znoEajodqxaSjeVAGAo3T9ALbyKDKOntgPROM9aAfL8VsZ9Eo3vgY+f3Fk7nE56XZp866R du3xFbEgZGspoGH2uWcuZhSUxjiqJL18H4UZq0NHeJ1FLi4bK+tx6F/G/sinfA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=WGWQ04KD; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net ARC-Seal: i=1; s=key1; d=yhetil.org; t=1715613770; a=rsa-sha256; cv=none; b=HHpfMrFpOEAk9twxroiD3b6+8uG2DAS61OIdzA1htltpBIQmcwaAqMEKoCJoDA4mv8EQPJ msdoNkaWm33c3CfILHE5tIlAEbw3AQpftWJQKNgDBK+Uz+raSB/t2GH0SVDIHGcXzgbaMW s/22l+Kbyj4tORKP7Sm6UabeW95QGoDDqn7tIVXn3Lhr9m2zMzspWzzEBLrmhpBjuGl3Qw BCp6hJ8mStUW9BApe9O942SqwhugNHPWBiYukNThEaOE4Qk7oZdmKk0XI8H4RdFNZdZ7nZ GgcGm2Nyu17lnSF7QlcG4qLKoLfBBqejHAGbntlQUK08owj0/jbQsfiQ4tJ+Aw== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id E8D08741D8 for ; Mon, 13 May 2024 17:22:48 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s6XV7-0001qy-Ly; Mon, 13 May 2024 11:22:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s6XUl-0001mf-A1 for emacs-orgmode@gnu.org; Mon, 13 May 2024 11:21:43 -0400 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s6XUi-0004ev-HO for emacs-orgmode@gnu.org; Mon, 13 May 2024 11:21:42 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 82310240103 for ; Mon, 13 May 2024 17:21:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1715613698; bh=N1/P97fDhzjK5j7D1p0gKssrjGBJSqK1AR+uAFvHHWU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=WGWQ04KDtvBC0ewFZLjcFRSi3wZDhklLctkNriigroBnTQo2Sgxmv2eKM+sN/pu4w XitSGef50ebvC49EvDF5gIwZd6yJz0TuPR9ekYzKVYlgcHC5WfFdrJBX4nVgKMuLPb TyrjdP02QOXsSfuGHHCk7UxMFptaCdysfru+zr8MJCUIpRUJP7OKhAgrqc2PBrgy7I tap7+a97FZH09LSy9SESPaqUC4IbbTBPm6laUWvaKKTDrXXY/NFqK+MvpnpY1516Gb yB3VLyrIRJ1YPAycAtpB1VmModSZIUPyuHmEt4Yccd9jvW0P3fsK36E6Y1lWZna4SY WaUlluquNswuw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4VdNW54Zj9z6twC; Mon, 13 May 2024 17:21:37 +0200 (CEST) From: Ihor Radchenko To: Nathan Nichols Cc: emacs-orgmode@gnu.org Subject: Re: [PATCH] Ability to specify :html-head as a function In-Reply-To: References: Date: Mon, 13 May 2024 15:23:11 +0000 Message-ID: <87zfstenxc.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Spam-Score: -9.59 X-Migadu-Queue-Id: E8D08741D8 X-Migadu-Scanner: mx10.migadu.com X-Migadu-Spam-Score: -9.59 X-TUID: syO/J/X+9wPy Nathan Nichols writes: > Here's a patch that adds the ability to specify :html-head as a function. I > think this is a logical change because: > > 1. It provides a wider range of options for how to use :html-head (before > :html-head could only be a string, now it can also be a function.) > 2. It is consistent with the behavior of :html-preamble and > :html-postamble, which can both either be a string or a function. Thanks! This addition makes sense. > I probably did this wrong but anyway here's my attempt at a patch > submission. Please let me know if you need any additional information or > have any questions. > > Thanks, > > --- a/lisp/org-element.el > +++ b/lisp/org-element.el > @@ -5578,9 +5578,8 @@ If there is no affiliated keyword, return the empty string." > ;; global indentation from the contents of the current element. > > (defun org-element-normalize-string (s) > - "Ensure string S ends with a single newline character. > - > -If S isn't a string return it unchanged. If S is the empty > + "Return S, or evaluate to a string ending with a single newline character. > +If S isn't a string or a function, return it unchanged. If S is the empty > string, return it. Otherwise, return a new string with a single > newline character at its end." > (cond > @@ -5589,6 +5588,21 @@ newline character at its end." > (t (and (string-match "\\(\n[ \t]*\\)*\\'" s) > (replace-match "\n" nil nil s))))) Please, do not remove existing functions. Also, please do not modify org-element library when it is just for the purposes of a single exporter. org-element library is the Org mode parser, used by all parts of Org mode. Instead, you can simply define a helper function inside ox-html.el. > +;; Test cases for `org-element-normalize-str-or-fn' > +(cl-assert (string= (org-element-normalize-str-or-fn (lambda (_res) "abcdefg") nil) "abcdefg\n")) > +(cl-assert (string= (org-element-normalize-str-or-fn "abcdefg") "abcdefg\n") nil) > +(cl-assert (= (org-element-normalize-str-or-fn 123 nil) 123)) Tests should go to testing/lisp/..., which see. > (defun org-element-normalize-contents (element &optional ignore-first) > "Normalize plain text in ELEMENT's contents. > > diff --git a/lisp/ox-html.el b/lisp/ox-html.el > index ec0add65e..72a8590c4 100644 > --- a/lisp/ox-html.el > +++ b/lisp/ox-html.el > @@ -131,7 +131,11 @@ > (:html-equation-reference-format "HTML_EQUATION_REFERENCE_FORMAT" nil org-html-equation-reference-format t) > (:html-postamble nil "html-postamble" org-html-postamble) > (:html-preamble nil "html-preamble" org-html-preamble) > - (:html-head "HTML_HEAD" nil org-html-head newline) > + ;; You should be able to use multiple headline properties "#+EXPORT_HTML_HEAD" in a file. > + ;; The results of each occurrence will be joined by a newline to form the final string > + ;; included in the section. > + ;; TODO: Test/verify this works still. See: `org-export-options-alist'. > + (:html-head "HTML_HEAD" "html-head" org-html-head newline) What is the purpose of "html-head" #+options keyword addition? Also, is TODO comment for you or for others? -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at