From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id QOAvGbgtbl+CCwAA0tVLHw (envelope-from ) for ; Fri, 25 Sep 2020 17:49:44 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id yLDqFLgtbl9HbAAAB5/wlQ (envelope-from ) for ; Fri, 25 Sep 2020 17:49:44 +0000 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 E808394042F for ; Fri, 25 Sep 2020 17:49:43 +0000 (UTC) Received: from localhost ([::1]:60374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLrqo-0002vB-VN for larch@yhetil.org; Fri, 25 Sep 2020 13:49:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40574) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLrq9-0002ud-1j for emacs-orgmode@gnu.org; Fri, 25 Sep 2020 13:49:01 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]:46804) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kLrq6-0001Le-Sl for emacs-orgmode@gnu.org; Fri, 25 Sep 2020 13:49:00 -0400 Received: by mail-pf1-x42d.google.com with SMTP id b124so3855905pfg.13 for ; Fri, 25 Sep 2020 10:48:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:message-id :date:mime-version:content-transfer-encoding; bh=S5aV5D1XlfuXYhcbC06avgaR531DnQvZD+3mCUQmftk=; b=CFZf/vurEIHrcdKTky2udaMYprsq4sTTtJyC4DP9QCrFR8B9IWutfIKq6lhvKhaFmC ilSyW6cyyKJh6lvy5NlhOvc6LXoSwZQ3TADWgYO0vGAwOmIswNyetEnhX7CPxB9sOOv5 CN6DoRdjnsSszPctXfXbbjlwMQ+ymfeNUpnWXX3DpzfZd2YrcyC4wWqjtqxECwljRAKK 2X58yrL6dhOWk/fmvj6IiaOmMsxk2l87Zp3LjBQQ+y3QTI90Y45VaWWgVfhKS2UTbvpQ ZCYZU7T8eZI/fZXG8pVKPiEg2EcLXFVJ35UpDmzpSiBpiN9EkQz8Dh3trCa1ZY9PJja3 fbgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:message-id:date:mime-version:content-transfer-encoding; bh=S5aV5D1XlfuXYhcbC06avgaR531DnQvZD+3mCUQmftk=; b=Je8lXrB2Ci9f+NFWTIlzDCZUxmsBJq4oSfKZI4hKCc9lcAg0plKUh1sOwi3I9xNCwB 4ExCjoebvipYy81vB+93DgunLiNFyt8E45xPRvTJeuhAkg2or+lRj7KViub2Z3Xsp5MZ YxPqNdbruYsb/7oHTqGq3fEUF8Nayqlt13VcCbo14Xvo6Ujxilcjs3jis2xB2USdn08v Tj7oJD8MB25jxRFpSiO+vo81wXcRAKggRj/joJieYMBrWq5blxFEcsmuXWtBfdUXHuE4 UUdYOic3cuDt2ZgEpbJGa2q+wxP96mpwNmXaRBdkMt/5SvPVeeIYAHiz8VaQn8pJolW6 xP1w== X-Gm-Message-State: AOAM532JyCO3gxk5wWJzmsW9bBWDJkc0qDgKZ6NL7CWHspZa1viDR5l6 8mJonmw2b+KDDb9NzuR5Z9u9PNVBNEc= X-Google-Smtp-Source: ABdhPJw8zvjLmYBVSo09ba0T7gWe5fMLDH4F1Xq1+XBZutBtT/yw8rhm+1rE7/1ChsNQbHOh4aYqEg== X-Received: by 2002:aa7:8a46:0:b029:142:2501:398a with SMTP id n6-20020aa78a460000b02901422501398amr333224pfa.79.1601056128302; Fri, 25 Sep 2020 10:48:48 -0700 (PDT) Received: from localhost (180-150-91-8.b4965b.per.nbn.aussiebb.net. [180.150.91.8]) by smtp.gmail.com with ESMTPSA id w192sm3287056pfd.156.2020.09.25.10.48.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Sep 2020 10:48:47 -0700 (PDT) References: <87pn6kfr19.fsf@gmail.com> <87v9gcz9ge.fsf@wi.uni-muenster.de> <87lfh8fkj1.fsf@gmail.com> <87zh5n1p3s.fsf@wi.uni-muenster.de> User-agent: mu4e 1.4.13; emacs 27.1 From: TEC To: Jens Lechtenboerger Subject: Re: [PATCH] Enhance org-html--build-meta-info In-reply-to: <87zh5n1p3s.fsf@wi.uni-muenster.de> Message-ID: <87tuvl3fyc.fsf@gmail.com> Date: Sat, 26 Sep 2020 01:48:44 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=tecosaur@gmail.com; helo=mail-pf1-x42d.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: org-mode-email Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=fail (body hash did not verify) header.d=gmail.com header.s=20161025 header.b=CFZf/vur; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: 0.09 X-TUID: quMNUUHq1fwO @Maintainers I think this is ready for a review. Jens Lechtenboerger writes: > My suggestion would be to go with the handling of description in all > cases, including the title. Currently the only element handled differently to `org-html-encode-plain-text' is "author". I don't know why so I don't want to touch it. > I added keywords to my OER presentations because some crawlers use > them to extract topics for classification of documents. I=E2=80=99d like= to > keep that. Re-added. Let me know if there's anything else, Timothy. ----- Updated patch below: >From da3878493a8c7097bf44add925696ede86ede661 Mon Sep 17 00:00:00 2001 From: TEC Subject: [PATCH] lisp/ox-html.el: make html meta func nicer * lisp/ox-html.el (org-html--build-meta-info): Multi-line repeated structure extracted to new function `org-html--build-meta-entry'. The opportunity was taken to extract most metadata info to custom variable `org-html-meta-tags', allowing for easy end-user modification. --- lisp/ox-html.el | 115 +++++++++++++++++++++++++++--------------------- 1 file changed, 65 insertions(+), 50 deletions(-) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index d2f24f5c6..6efb76e12 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -1425,6 +1425,28 @@ not be modified." =20 ;;;; Template :: Styles =20 +(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)))) + ("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 A= UTHOR +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 @@ -1835,23 +1857,32 @@ INFO is a plist used as a communication channel." ;;; Template =20 +(defun org-html--build-meta-entry (label identity &optional content-format= &rest content-formatters) + "Construct tag with LABEL=3D\"IDENTITY\" and content from CONTENT= -FORMAT and CONTENT-FORMATTER." + (concat "\n")) + (defun org-html--build-meta-info (info) "Return meta tags for exported document. INFO is a plist used as a communication channel." - (let* ((protect-string - (lambda (str) - (replace-regexp-in-string - "\"" """ (org-html-encode-plain-text str)))) - (title (org-export-data (plist-get info :title) info)) + (let* ((title (org-html-encode-plain-text (plist-get info :title) info)) ;; Set title to an invisible character instead of leaving it ;; empty, which is invalid. (title (if (org-string-nw-p title) title "‎")) (author (and (plist-get info :with-author) (let ((auth (plist-get info :author))) - ;; Return raw Org syntax. + ;; Return raw Org syntax. (and auth (org-element-interpret-data auth))))) - (description (plist-get info :description)) - (keywords (plist-get info :keywords)) + (keywords (plist-get info :keywords)) (charset (or (and org-html-coding-system (fboundp 'coding-system-get) (coding-system-get org-html-coding-system @@ -1863,50 +1894,34 @@ INFO is a plist used as a communication channel." (concat "\n"))) - (format - (if (org-html-html5-p info) - (org-html-close-tag "meta" "charset=3D\"%s\"" info) - (org-html-close-tag - "meta" "http-equiv=3D\"Content-Type\" content=3D\"text/html;charset=3D%s= \"" - info)) - charset) "\n" + + (if (org-html-html5-p info) + (org-html--build-meta-entry "charset" charset) + (org-html--build-meta-entry "http-equiv" "Content-Type" + (concat "text/html;charset=3D" charset))) + (let ((viewport-options - (cl-remove-if-not (lambda (cell) (org-string-nw-p (cadr cell))) - (plist-get info :html-viewport)))) - (and viewport-options - (concat - (org-html-close-tag - "meta" - (format "name=3D\"viewport\" content=3D\"%s\"" - (mapconcat - (lambda (elm) (format "%s=3D%s" (car elm) (cadr elm))) - viewport-options ", ")) - info) - "\n"))) + (cl-remove-if-not (lambda (cell) (org-string-nw-p (cadr cell))) + (plist-get info :html-viewport)))) + (if viewport-options + (org-html--build-meta-entry "name" "viewport" + (mapconcat + (lambda (elm) (format "%s=3D%s" (c= ar elm) (cadr elm))) + viewport-options ", ")))) + (format "%s\n" title) - (org-html-close-tag "meta" "name=3D\"generator\" content=3D\"Org mode= \"" info) - "\n" - (and (org-string-nw-p author) - (concat - (org-html-close-tag "meta" - (format "name=3D\"author\" content=3D\"%s\"" - (funcall protect-string author)) - info) - "\n")) - (and (org-string-nw-p description) - (concat - (org-html-close-tag "meta" - (format "name=3D\"description\" content=3D\"%s\"\n" - (funcall protect-string description)) - info) - "\n")) - (and (org-string-nw-p keywords) - (concat - (org-html-close-tag "meta" - (format "name=3D\"keywords\" content=3D\"%s\"" - (funcall protect-string keywords)) - info) - "\n"))))) + + (when keywords + (org-html--build-meta-entry "keywords" keywords)) + + (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))))) =20 (defun org-html--build-head (info) "Return information for the .. of the HTML output. --=20 2.28.0