From a2fae2c3c7f38ee8d22a4fedbce25d046c8a818d Mon Sep 17 00:00:00 2001 From: TEC Date: Mon, 14 Dec 2020 17:50:15 +0800 Subject: [PATCH 2/2] lisp/ox-html.el: make html meta tags customizable * lisp/ox-html.el (org-html-meta-tags): Introduce this as a new option which can be modified to set the meta tags added in HTML exports. (org-html--build-meta-info): Make use of `org-html-meta-tags' instead of hardcoded meta tags. This is leveraging the earlier restructuring of `org-html--build-meta-info' into a much DRYer form, such that this modification has a negligible impact on complexity and readability. --- lisp/ox-html.el | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index e774b53ac..35e056557 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -1425,6 +1425,31 @@ not be modified." ;;;; Template :: Styles +(defcustom org-html-meta-tags + '((lambda (_title author _info) + (when (org-string-nw-p author) + (list "name" "author" author))) + (lambda (_title _author info) + (when (org-string-nw-p (plist-get info :description)) + (list "name" "description" + (plist-get info :description)))) + (lambda (_title _author info) + (when (org-string-nw-p (plist-get info :keywords)) + (list "keywords" (plist-get info :keywords)))) + ("name" "generator" "Org Mode")) + "A list of arguments to be passed to `org-html--build-meta-entry'. +Each argument can either be an list which is applied, or a function which +generates such a list with signature (TITLE AUTHOR INFO) where TITLE and AUTHOR +are strings, and INFO a communication plist." + :group 'org-export-html + :package-version '(Org . "9.5") + :type '(repeat + (choice + (list (string :tag "Meta label") + (string :tag "label value") + (string :tag "Content value")) + function))) + (defcustom org-html-head-include-default-style t "Non-nil means include the default style in exported HTML files. The actual style is defined in `org-html-style-default' and @@ -1893,16 +1918,14 @@ INFO is a plist used as a communication channel." (format "%s\n" title) - (when (org-string-nw-p author) - (org-html--build-meta-entry "name" "author" author)) - - (when (org-string-nw-p (plist-get info :description)) - (org-html--build-meta-entry "name" "description" (plist-get info :description))) - - (when (org-string-nw-p (plist-get info :keywords)) - (org-html--build-meta-entry "keywords" (plist-get info :keywords))) - - (org-html--build-meta-entry "name" "generator" "Org Mode")))) + (apply #'concat + (mapcar + (lambda (form) + (when (functionp form) + (setq form (funcall form title author info))) + (when form + (apply #'org-html--build-meta-entry form))) + org-html-meta-tags))))) (defun org-html--build-head (info) "Return information for the .. of the HTML output. -- 2.29.2